-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Fix: adding new ips with inventory builder (#7577) #7583
Fix: adding new ips with inventory builder (#7577) #7583
Conversation
Hi @VladMasarik. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
af3f9c8
to
88db844
Compare
88db844
to
78185ef
Compare
Please check the fmt issue in the CI job |
/ok-to-test |
try: | ||
for host in self.yaml_config['all']['hosts']: | ||
# Read configuration of an existing host | ||
existing_hosts[host] = self.yaml_config['all']['hosts'][host] |
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.
pep8 detects invalid coding style like"
pep8 run-test: commands[0] | bash -c 'find /builds/kargo-ci/kubernetes-sigs-kubespray/contrib/inventory_builder/* -type f -name '"'"'*.py'"'"' -print0 | xargs -0 flake8'
/builds/kargo-ci/kubernetes-sigs-kubespray/contrib/inventory_builder/inventory.py:179:80: E501 line too long (81 > 79 characters)
existing_hosts[host] = self.yaml_config['all']['hosts'][host]
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.
yes, I wanted to know how to resolve it properly, as I couldn't find any good solution, ie. something that would look better than ignoring the warnings. I fixed it though.
except OSError as e: | ||
# I am assuming we are catching "cannot open file" exceptions | ||
print(e) | ||
sys.exit(1) |
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.
Is this mandatory for adding add
option?
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.
Will the add
work without it? Yes, in that case it is not mandatory.
However, not having it, means that a user can specify incorrect config path, and reading the file might fail. In that case, the exception is just ignored, and yaml_config
is not read. Meaning, a user expected the script to use a config file, but it silently failed, and user doesn't even know something went wrong.
to after checking whether the config should be loaded, and added check for whether the config should be loaded
if the user wants to remove a node, we need to load the config
While using the script, I noticed and fixed a few mistakes I made.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: floryut, VladMasarik The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Sorry for my late response.
/lgtm
@VladMasarik Added this to the release note for 2.17, again sorry this took time to merge, great work man. |
Indeed, not whining at all but the hard part is managing time between work and family 😄 |
…bernetes-sigs#7583) * Fix: adding new ips with inventory builder (kubernetes-sigs#7577) * moved conflig loading logic to after checking whether the config should be loaded, and added check for whether the config should be loaded * added check for removing nodes from config if the user wants to remove a node, we need to load the config * Fix tox errors
…bernetes-sigs#7583) * Fix: adding new ips with inventory builder (kubernetes-sigs#7577) * moved conflig loading logic to after checking whether the config should be loaded, and added check for whether the config should be loaded * added check for removing nodes from config if the user wants to remove a node, we need to load the config * Fix tox errors
What type of PR is this?
/kind bug
What this PR does / why we need it:
load_all()
function call to justload()
.HOST_PREFIX
string(ie. we can assume that the hostname was automatically created). Additionally, I have at least added a print out of the exceptions, and the script exits with1
when they are raised.help
command, and also added a few comments to help with understanding. It is up for a discussion whether they are helpful, or whether we should remove them. As for the other documentation, I searched for the word "inventory", but couldn't find any text that would need a change. I managed to find only one instance in Getting started.add
command for the script. The previously expected behavior was that if you had an inventory config with 4 nodes, the:would add a new node with the
10.0.0.3
IP address, thus you would have 5 nodes, or 4 if it was a duplicate IP address. However, this would actually overwrite the original inventory configs, so you would end up with just 1 node. I am not sure if people use this script, but I assume that not changing the original behavior (whether intended or not) would be better, as this issue was introduced a year ago #5373 . Although, they seem to be doing the exact opposite of what this PR does. They never show the structure of their config file, and are using.ini
files, which I am assuming are different from YAML, so what they were doing, beats me. So in order to keep the old functionality, but also allow the already existing one that did not work, this PR adds anadd
command. Example, you have 4 nodes in your inventory and execute:This adds 5th and 6th node called "gpuvm1" and "gpuvm2" into the existing inventory YAML file.
Which issue(s) this PR fixes:
Fixes #7577
Special notes for your reviewer:
Lots of text, sorry for that, but I wanted to mention things I have considered so that you can point out something if I have missed a thing.
Does this PR introduce a user-facing change?: