-
Notifications
You must be signed in to change notification settings - Fork 250
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
Use the /var/lib/calico/nodename file if it exists #480
Use the /var/lib/calico/nodename file if it exists #480
Conversation
8804973
to
af68821
Compare
af68821
to
f82f8dc
Compare
f82f8dc
to
92d9149
Compare
calico.go
Outdated
} | ||
logrus.Debug("/var/lib/calico/nodename exists") | ||
} | ||
|
||
// Allow the nodename to be overridden by the network config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that nodename is being instantiated here, I don't think this comment is right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the comment was ever right.
return nodename | ||
} | ||
|
||
// nodenameFromFile reads the /var/lib/calico/nodename file if it exists and | ||
// returns the nodename within. | ||
func nodenameFromFile() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nodeNameFile that exists but is empty takes an interesting path through this code, but I suppose it is ok...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, yeah. I suspect we probably want to error in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, let's leave this as it is for now. I think the code will do the right thing and I'm not sure how we'd end up with an empty file anyway.
if nff := nodenameFromFile(); nff != "" { | ||
logrus.Debugf("Read node name from file: %s", nff) | ||
nodename = nff | ||
} | ||
if conf.Nodename != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an else if
? If multiple methods are provided (albeit an unusual edge case), the lowest priority would take precedence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the code is structured now is acting as designed - the conf.Nodename
takes priority over the /var/lib/calico/nodename
file.
92d9149
to
e370cf7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆒
e370cf7
to
a697959
Compare
a697959
to
a1c071f
Compare
Description
In combination with projectcalico/calico#1722, will make it much harder to accidentally end up with mismatched node names between the two components.
Fixes projectcalico/calico#1093
Todos
Release Note