diff --git a/api/server/router/swarm/cluster_routes.go b/api/server/router/swarm/cluster_routes.go index b077b51590..1f3dc9bf31 100644 --- a/api/server/router/swarm/cluster_routes.go +++ b/api/server/router/swarm/cluster_routes.go @@ -220,6 +220,15 @@ func (sr *swarmRouter) createService(ctx context.Context, w http.ResponseWriter, } 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) if err != nil { log.G(ctx).WithFields(logrus.Fields{ diff --git a/daemon/cluster/convert/container.go b/daemon/cluster/convert/container.go index fb88eefe37..fcdf018f5b 100644 --- a/daemon/cluster/convert/container.go +++ b/daemon/cluster/convert/container.go @@ -436,22 +436,25 @@ func healthConfigFromGRPC(h *swarmapi.HealthConfig) *container.HealthConfig { interval, _ := gogotypes.DurationFromProto(h.Interval) timeout, _ := gogotypes.DurationFromProto(h.Timeout) startPeriod, _ := gogotypes.DurationFromProto(h.StartPeriod) + startInterval, _ := gogotypes.DurationFromProto(h.StartInterval) 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 { 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), } }