Selaa lähdekoodia

Support for health start interval to swarm mode

Adds conversions for health start interval to/from grpc for swarmkit.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Brian Goff 2 vuotta sitten
vanhempi
commit
f93cfb2e31

+ 9 - 0
api/server/router/swarm/cluster_routes.go

@@ -220,6 +220,15 @@ func (sr *swarmRouter) createService(ctx context.Context, w http.ResponseWriter,
 		}
 		}
 		adjustForAPIVersion(v, &service)
 		adjustForAPIVersion(v, &service)
 	}
 	}
+
+	version := httputils.VersionFromContext(ctx)
+	if versions.LessThan(version, "1.44") {
+		if service.TaskTemplate.ContainerSpec != nil && service.TaskTemplate.ContainerSpec.Healthcheck != nil {
+			// StartInterval was added in API 1.44
+			service.TaskTemplate.ContainerSpec.Healthcheck.StartInterval = 0
+		}
+	}
+
 	resp, err := sr.backend.CreateService(service, encodedAuth, queryRegistry)
 	resp, err := sr.backend.CreateService(service, encodedAuth, queryRegistry)
 	if err != nil {
 	if err != nil {
 		log.G(ctx).WithFields(logrus.Fields{
 		log.G(ctx).WithFields(logrus.Fields{

+ 13 - 10
daemon/cluster/convert/container.go

@@ -436,22 +436,25 @@ func healthConfigFromGRPC(h *swarmapi.HealthConfig) *container.HealthConfig {
 	interval, _ := gogotypes.DurationFromProto(h.Interval)
 	interval, _ := gogotypes.DurationFromProto(h.Interval)
 	timeout, _ := gogotypes.DurationFromProto(h.Timeout)
 	timeout, _ := gogotypes.DurationFromProto(h.Timeout)
 	startPeriod, _ := gogotypes.DurationFromProto(h.StartPeriod)
 	startPeriod, _ := gogotypes.DurationFromProto(h.StartPeriod)
+	startInterval, _ := gogotypes.DurationFromProto(h.StartInterval)
 	return &container.HealthConfig{
 	return &container.HealthConfig{
-		Test:        h.Test,
-		Interval:    interval,
-		Timeout:     timeout,
-		Retries:     int(h.Retries),
-		StartPeriod: startPeriod,
+		Test:          h.Test,
+		Interval:      interval,
+		Timeout:       timeout,
+		Retries:       int(h.Retries),
+		StartPeriod:   startPeriod,
+		StartInterval: startInterval,
 	}
 	}
 }
 }
 
 
 func healthConfigToGRPC(h *container.HealthConfig) *swarmapi.HealthConfig {
 func healthConfigToGRPC(h *container.HealthConfig) *swarmapi.HealthConfig {
 	return &swarmapi.HealthConfig{
 	return &swarmapi.HealthConfig{
-		Test:        h.Test,
-		Interval:    gogotypes.DurationProto(h.Interval),
-		Timeout:     gogotypes.DurationProto(h.Timeout),
-		Retries:     int32(h.Retries),
-		StartPeriod: gogotypes.DurationProto(h.StartPeriod),
+		Test:          h.Test,
+		Interval:      gogotypes.DurationProto(h.Interval),
+		Timeout:       gogotypes.DurationProto(h.Timeout),
+		Retries:       int32(h.Retries),
+		StartPeriod:   gogotypes.DurationProto(h.StartPeriod),
+		StartInterval: gogotypes.DurationProto(h.StartInterval),
 	}
 	}
 }
 }