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

Conversation

schmichael
Copy link
Member

@schmichael schmichael commented Dec 20, 2017

Fixes #3681

When in driver address mode Nomad should always advertise the driver's IP
in Consul even when no network exists. This matches the 0.6 behavior.

When in host address mode Nomad advertises the alloc's network's IP if
one exists. Otherwise it lets Consul determine the IP.

I also added some much needed logging around Docker's network discovery.

Binaries from d1e2833

linux_amd64.zip
windows_amd64.zip

Old
Binaries from 9a1cb46 which include #3680:

linux_amd64.zip
windows_amd64.zip

Binaries from cd2e712:

linux_amd64.zip
windows_amd64.zip

@@ -860,13 +863,18 @@ 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",
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to invert these logs and log on the task driver?

Name: "EmptyIsOk",
Mode: structs.AddressModeHost,
Name: "NoPort_AutoMode",
Mode: structs.AddressModeHost,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is host not auto. Also shouldn't the auto be with a driver network

@schmichael
Copy link
Member Author

Pushed some more tests and an error message improvement to address #3681 (comment)

Could use a re-review

Copy link
Contributor

@dadgar dadgar left a comment

Choose a reason for hiding this comment

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

Changelog entry

}

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.

schmichael added a commit that referenced this pull request Jan 16, 2018
Fixes #3681

When in drive address mode Nomad should always advertise the driver's IP
in Consul even when no network exists. This matches the 0.6 behavior.

When in host address mode Nomad advertises the alloc's network's IP if
one exists. Otherwise it lets Consul determine the IP.

I also added some much needed logging around Docker's network discovery.
Related to #3681

If a user specifies an invalid port *label* when using
address_mode=driver they'll get an error message about the label being
an invalid number which is very confusing.

I also added a bunch of testing around Service.AddressMode validation
since I was concerned by the linked issue that there were cases I was
missing. Unfortunately when address_mode=driver is used there's only so
much validation that can be done as structs/structs.go validation never
peeks into the driver config which would be needed to verify the port
labels/map.
For people not using driver networks these log lines would just be
confusing.
@schmichael schmichael merged commit 6e96c81 into master Jan 23, 2018
@schmichael schmichael deleted the b-3681-always-set-driver-ip branch January 23, 2018 00:41
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants