-
Notifications
You must be signed in to change notification settings - Fork 103
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
lib/runtime: improve not-master error #1712
base: master
Are you sure you want to change the base?
Conversation
For unclear reasons, there was an environment where the master was running, but the clients did not believe it was the master. kernel.hostname returned the unqualified hostname, as expected, but the master check was looking for the FQDN. Improve the error message as a start on making it easier to debug. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
raise errors.OpPrereqError("This node, '%s', is not the master node, | ||
" please connect to node '%s' and rerun " | ||
" the command" % | ||
% (myself, master), errors.ECODE_INVAL) |
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.
Looks like there is an extra %
at the start of the line. Otherwise LGTM.
master, errors.ECODE_INVAL) | ||
# print our own name to aid debugging, esp. re FQDN | ||
# common error is: hostname != hostname.domain.tld | ||
raise errors.OpPrereqError("This node, '%s', is not the master node, |
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.
Also there seems a missing double quote at the end:
Exception occurred:
File "/tmp/gntbuild.kZnFQSGG/ganeti/cli.py", line 62, in <module>
from ganeti.runtime import (GetClient)
File "/tmp/gntbuild.kZnFQSGG/ganeti/runtime.py", line 291
raise errors.OpPrereqError("This node, '%s', is not the master node,
^
SyntaxError: EOL while scanning string literal
raise errors.OpPrereqError("This node, '%s', is not the master node, | ||
" please connect to node '%s' and rerun " | ||
" the command" % | ||
% (myself, master), errors.ECODE_INVAL) |
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.
In such cases I personally prefer f-strings
raise errors.OpPrereqError("This node, '%s', is not the master node, | |
" please connect to node '%s' and rerun " | |
" the command" % | |
% (myself, master), errors.ECODE_INVAL) | |
raise errors.OpPrereqError(f"This node, {myself}, is not the master node, " | |
f"please connect to node {master} and rerun " | |
"the command", | |
errors.ECODE_INVAL) |
Perhaps the old %-style should be replaced by f-strings, which are supported in version 3.6?
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 for your suggestion. f-strings look pretty readable. However for the moment we stay with the old %
style to align with existing code. Maybe in future we can adopt to follow the language authorities standards.
For unclear reasons, there was an environment where the master was running, but the clients did not believe it was the master.
kernel.hostname returned the unqualified hostname, as expected, but the master check was looking for the FQDN.
Improve the error message as a start on making it easier to debug.
Signed-off-by: Robin H. Johnson robbat2@gentoo.org