-
Notifications
You must be signed in to change notification settings - Fork 389
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
Set node_name to hostname if NODE_NAME envvar is not found #2123
Conversation
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.
LGTM minor comments on caching, errors, fixing tests and maybe add test to ensure that it returns /proc/sys/kernel/hostname if no envs are set.
pkg/reader/node/node.go
Outdated
} | ||
return os.Getenv("NODE_NAME") | ||
if nodeName == "" { | ||
nodeName, _ = os.Hostname() |
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.
l would cache this using a read once just to avoid extra calls in a global environment to be consistent too with k8s. The hostname may change during runtime but I don't think we care. cc @jrfastab
Also we need to report an error here if os.Hostname() fails for some reasons! and maybe use the old utsname but you have to convert then the output from int8 to byte then strings ... a bit complicated. the Hostname() seems to call explicitly /proc at this location where we may have it configured --procfs but this is an extreme case, so up to you, just warning on Hostname() errors should be enough.
Thank you @lambdanis
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.
Thanks! I added a warning log.
f5657ad
to
40f1937
Compare
40f1937
to
d803ecb
Compare
d803ecb
to
1e77057
Compare
This enables node_name field in the standalone (non-k8s) mode. Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
1e77057
to
2087f7e
Compare
Ok, merging it, the only CI failure is the known #2010 |
This enables node_name field in the standalone (non-k8s) mode.