diff --git a/client/driver/docker.go b/client/driver/docker.go index 81cffb44891..df6ee0fcacf 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -820,9 +820,6 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (*StartRespon // Detect container address ip, autoUse := d.detectIP(container) - if ip == "" { - d.logger.Printf("[DEBUG] driver.docker: task %s could not detect a container IP", d.taskName) - } // Create a response with the driver handle and container network metadata resp := &StartResponse{ @@ -863,11 +860,6 @@ func (d *DockerDriver) detectIP(c *docker.Container) (string, bool) { // Linux, nat on Windows) if name != "bridge" && name != "nat" { auto = true - d.logger.Printf("[INFO] driver.docker: task %s auto-advertising detected IP %s on network %q", - d.taskName, ip, name) - } else { - d.logger.Printf("[DEBUG] driver.docker task %s detect IP %s on network %q but not auto-advertising", - d.taskName, ip, name) } break diff --git a/client/task_runner.go b/client/task_runner.go index e01cc34cdd6..8befef0c327 100644 --- a/client/task_runner.go +++ b/client/task_runner.go @@ -1440,6 +1440,21 @@ func (r *TaskRunner) startTask() error { } + // Log driver network information + if sresp.Network != nil && sresp.Network.IP != "" { + if sresp.Network.AutoAdvertise { + r.logger.Printf("[INFO] client: alloc %s task %s auto-advertising detected IP %s", + r.alloc.ID, r.task.Name, sresp.Network.IP) + } else { + r.logger.Printf("[DEBUG] client: alloc %s task %s detected IP %s but not auto-advertising", + r.alloc.ID, r.task.Name, sresp.Network.IP) + } + } + + if sresp.Network == nil || sresp.Network.IP == "" { + r.logger.Printf("[DEBUG] client: alloc %s task %s could not detect a driver IP", r.alloc.ID, r.task.Name) + } + // Update environment with the network defined by the driver's Start method. r.envBuilder.SetDriverNetwork(sresp.Network)