Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always advertise driver IP when in driver mode #3682

Merged
merged 6 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve driver network logging
  • Loading branch information
schmichael committed Jan 18, 2018
commit 6d77215f371569dce06196ba921656124df7a47e
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These DEBUG logs feel like they may be better suited for TRACE? They are more or less expected on all task. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glanced at the other DEBUG logs in TaskRunner and agree. These are pretty low level and could be needlessly confusing for people who never use this feature.

}

// Update environment with the network defined by the driver's Start method.
r.envBuilder.SetDriverNetwork(sresp.Network)

Expand Down