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

Make nodenames unique in Gossip cluster #1451

Merged
merged 1 commit into from
Sep 19, 2016
Merged

Make nodenames unique in Gossip cluster #1451

merged 1 commit into from
Sep 19, 2016

Conversation

sanimej
Copy link

@sanimej sanimej commented Sep 16, 2016

Conflicting names in the cluster can lead to silent failures in the service discovery, routing mesh etc. When joining the cluster make sure the nodenames are unique.

Signed-off-by: Santhosh Manohar santhosh@docker.com


var nodeName string
if len(hostname)+len(id) > 63 {
nodeName = hostname[:63-len(id)] + "-" + id
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if len(hostname) == 63, the extra - will make nodename 64 bytes long.

Copy link
Author

Choose a reason for hiding this comment

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

Its similar to an fqdn where individual components are 63 bytes with a . in between.

Copy link
Author

Choose a reason for hiding this comment

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

IOW, with - the length can be 64 bytes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, ok I did not read well the comment, I thought you wanted to keep the 63 length restriction for the nodename as well, but it actually says hostname.


var nodeName string
if len(hostname)+len(id) > 63 {
nodeName = hostname[:63-len(id)] + "-" + id
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, ok I did not read well the comment, I thought you wanted to keep the 63 length restriction for the nodename as well, but it actually says hostname.

id := stringid.TruncateID(stringid.GenerateRandomID())

var nodeName string
if len(hostname)+len(id) > 63 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you trying to truncate nodeName to < 64 bytes?

Copy link
Author

Choose a reason for hiding this comment

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

Since we have the random ID now the names are guaranteed to be unique. So there is no need to use the entire hostname which could be of different lengths across hosts. Truncating is just to keep the nodename length consistent across the cluster.

Copy link
Contributor

Choose a reason for hiding this comment

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

But hostnames are more meaningful and if somebody used hostnames in their cluster with same prefix then there is a potential that we truncate the differentiating parts and keep the same part and it would be hard to read logs if that is the case. Do we really need to keep node name length consistent across the cluster?

Copy link
Contributor

Choose a reason for hiding this comment

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

It does not keep it consistent becasue if a hostname is 10 chars long and another is 12 chars long, the cluster seens nodenames will be 23 and 25 chars long.

Copy link
Author

Choose a reason for hiding this comment

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

Neither memberlist or nor our code has restriction on the node name length. Since keeping the hosntame fully is the preferred option I will change it.

Copy link
Author

Choose a reason for hiding this comment

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

@mrjana @aboch Removed the truncation & verified that on a daemon restart other nodes are marking the previous node name as a suspicious node and eventually marking it failed.

@@ -247,9 +248,12 @@ func (c *controller) agentInit(bindAddrOrInterface, advertiseAddr string) error

keys, tags := c.getKeys(subsysGossip)
hostname, _ := os.Hostname()
nodeName := hostname + "-" + stringid.TruncateID(stringid.GenerateRandomID())
logrus.Infof("Gossip cluster hostname ", nodeName)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to keep this log, please add : %s

Signed-off-by: Santhosh Manohar <santhosh@docker.com>
@aboch
Copy link
Contributor

aboch commented Sep 19, 2016

LGTM

Copy link
Contributor

@mrjana mrjana left a comment

Choose a reason for hiding this comment

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

LGTM

@mrjana mrjana merged commit 011cc73 into moby:master Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants