This fix tries to address the issue raised in 30178 where
service healthcheck is `{}` in remote API will result in
dns resolve failue.
The reason was that when service healthcheck is `{}`,
service binding was not done.
This fix fixes the issue.
An integration test has been added.
This fix fixes 30178.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
(cherry picked from commit 8feb5c5a48eaadc1686e3b370f7ef9be128dd3cb)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
| ... | ... |
@@ -205,7 +205,7 @@ func (r *controller) Start(ctx context.Context) error {
|
| 205 | 205 |
} |
| 206 | 206 |
|
| 207 | 207 |
// no health check |
| 208 |
- if ctnr.Config == nil || ctnr.Config.Healthcheck == nil {
|
|
| 208 |
+ if ctnr.Config == nil || ctnr.Config.Healthcheck == nil || len(ctnr.Config.Healthcheck.Test) == 0 || ctnr.Config.Healthcheck.Test[0] == "NONE" {
|
|
| 209 | 209 |
if err := r.adapter.activateServiceBinding(); err != nil {
|
| 210 | 210 |
log.G(ctx).WithError(err).Errorf("failed to activate service binding for container %s which has no healthcheck config", r.adapter.container.name())
|
| 211 | 211 |
return err |
| ... | ... |
@@ -213,12 +213,6 @@ func (r *controller) Start(ctx context.Context) error {
|
| 213 | 213 |
return nil |
| 214 | 214 |
} |
| 215 | 215 |
|
| 216 |
- healthCmd := ctnr.Config.Healthcheck.Test |
|
| 217 |
- |
|
| 218 |
- if len(healthCmd) == 0 || healthCmd[0] == "NONE" {
|
|
| 219 |
- return nil |
|
| 220 |
- } |
|
| 221 |
- |
|
| 222 | 216 |
// wait for container to be healthy |
| 223 | 217 |
eventq := r.adapter.events(ctx) |
| 224 | 218 |
|
| ... | ... |
@@ -15,6 +15,7 @@ import ( |
| 15 | 15 |
"time" |
| 16 | 16 |
|
| 17 | 17 |
"github.com/docker/docker/api/types" |
| 18 |
+ "github.com/docker/docker/api/types/container" |
|
| 18 | 19 |
"github.com/docker/docker/api/types/swarm" |
| 19 | 20 |
"github.com/docker/docker/pkg/integration/checker" |
| 20 | 21 |
"github.com/go-check/check" |
| ... | ... |
@@ -1365,3 +1366,26 @@ func (s *DockerSwarmSuite) TestAPIDuplicateNetworks(c *check.C) {
|
| 1365 | 1365 |
|
| 1366 | 1366 |
c.Assert(r2.Scope, checker.Equals, "swarm") |
| 1367 | 1367 |
} |
| 1368 |
+ |
|
| 1369 |
+// Test case for 30178 |
|
| 1370 |
+func (s *DockerSwarmSuite) TestAPISwarmHealthcheckNone(c *check.C) {
|
|
| 1371 |
+ d := s.AddDaemon(c, true, true) |
|
| 1372 |
+ |
|
| 1373 |
+ out, err := d.Cmd("network", "create", "-d", "overlay", "lb")
|
|
| 1374 |
+ c.Assert(err, checker.IsNil, check.Commentf(out)) |
|
| 1375 |
+ |
|
| 1376 |
+ instances := 1 |
|
| 1377 |
+ d.createService(c, simpleTestService, setInstances(instances), func(s *swarm.Service) {
|
|
| 1378 |
+ s.Spec.TaskTemplate.ContainerSpec.Healthcheck = &container.HealthConfig{}
|
|
| 1379 |
+ s.Spec.TaskTemplate.Networks = []swarm.NetworkAttachmentConfig{
|
|
| 1380 |
+ {Target: "lb"},
|
|
| 1381 |
+ } |
|
| 1382 |
+ }) |
|
| 1383 |
+ |
|
| 1384 |
+ waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, instances) |
|
| 1385 |
+ |
|
| 1386 |
+ containers := d.activeContainers() |
|
| 1387 |
+ |
|
| 1388 |
+ out, err = d.Cmd("exec", containers[0], "ping", "-c1", "-W3", "top")
|
|
| 1389 |
+ c.Assert(err, checker.IsNil, check.Commentf(out)) |
|
| 1390 |
+} |