Skip to content

Commit

Permalink
Improve driver network logging
Browse files Browse the repository at this point in the history
  • Loading branch information
schmichael committed Dec 21, 2017
1 parent cd92ae3 commit 9a1cb46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 0 additions & 8 deletions client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions client/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 9a1cb46

Please sign in to comment.