diff --git a/daemon/cluster/executor/container/controller.go b/daemon/cluster/executor/container/controller.go index 32c95f203d..0ecf58e62b 100644 --- a/daemon/cluster/executor/container/controller.go +++ b/daemon/cluster/executor/container/controller.go @@ -205,7 +205,7 @@ func (r *controller) Start(ctx context.Context) error { } // no health check - if ctnr.Config == nil || ctnr.Config.Healthcheck == nil { + if ctnr.Config == nil || ctnr.Config.Healthcheck == nil || len(ctnr.Config.Healthcheck.Test) == 0 || ctnr.Config.Healthcheck.Test[0] == "NONE" { if err := r.adapter.activateServiceBinding(); err != nil { log.G(ctx).WithError(err).Errorf("failed to activate service binding for container %s which has no healthcheck config", r.adapter.container.name()) return err @@ -213,12 +213,6 @@ func (r *controller) Start(ctx context.Context) error { return nil } - healthCmd := ctnr.Config.Healthcheck.Test - - if len(healthCmd) == 0 || healthCmd[0] == "NONE" { - return nil - } - // wait for container to be healthy eventq := r.adapter.events(ctx) diff --git a/integration-cli/docker_api_swarm_test.go b/integration-cli/docker_api_swarm_test.go index 048e6e63b7..07d0434e5a 100644 --- a/integration-cli/docker_api_swarm_test.go +++ b/integration-cli/docker_api_swarm_test.go @@ -16,6 +16,7 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/daemon" @@ -1384,3 +1385,26 @@ func (s *DockerSwarmSuite) TestAPIDuplicateNetworks(c *check.C) { c.Assert(r2.Scope, checker.Equals, "swarm") } + +// Test case for 30178 +func (s *DockerSwarmSuite) TestAPISwarmHealthcheckNone(c *check.C) { + d := s.AddDaemon(c, true, true) + + out, err := d.Cmd("network", "create", "-d", "overlay", "lb") + c.Assert(err, checker.IsNil, check.Commentf(out)) + + instances := 1 + d.CreateService(c, simpleTestService, setInstances(instances), func(s *swarm.Service) { + s.Spec.TaskTemplate.ContainerSpec.Healthcheck = &container.HealthConfig{} + s.Spec.TaskTemplate.Networks = []swarm.NetworkAttachmentConfig{ + {Target: "lb"}, + } + }) + + waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances) + + containers := d.ActiveContainers() + + out, err = d.Cmd("exec", containers[0], "ping", "-c1", "-W3", "top") + c.Assert(err, checker.IsNil, check.Commentf(out)) +}