-
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
calico_pool_blocksize must be cast as well in assertion when defined #8321
Merged
k8s-ci-robot
merged 2 commits into
kubernetes-sigs:master
from
emiran-orange:calico_pool_blocksize_cast_as_well
Dec 23, 2021
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't these be compared as
int
instead ofstring
?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.
Well, #8120 changed the comparison format from int to string.
To answer your question, if so, the referenced PR should be reverted and mine changed so that
calico_pool_conf.spec.blockSize
is cast as int as bothkube_network_node_prefix
andcalico_pool_blocksize
are intThere 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, I take back what I posted in my last comment, if so, the referenced PR should be reverted and mine deleted.
I took a look at #8119. I think the issue is a false positive as ansible key/val parser there does not do typing and passing
-e kube_network_node_prefix=26
will makekube_network_node_prefix
be a string whereas it is expected t be an int (in inventory)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.
@cristicalin What do you think ?
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.
You can always do the right thing ™️ in this PR and fix both the order and they type cast.
I have to admit that #8120 dropped off my radar after the premature merge.
PS: everything you pass to ansible via
-e var=value
ends up as a string, to pass different types likeint
orbool
you have to use the json syntax like-e '{bool_var: True, my_int_var: 23}'
.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.
@cristicalin
My point wasn't not to pass the parameter but to pass it the right way:
-e '{"kube_network_node_prefix": 26}'
instead of-e kube_network_node_prefix=26
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.
There are valid situations where you cannot control the type ansible assigns to this variable, especially if you embed kubespray as part of a larger project and call
cluster.yml
withinclude_playbook
and your variables are calculated or extracted from some other data source.It is a good practice to ensure types a properly set when variables are compared to avoid issues propagating silently. As was the case with the original PR #8120 this should be fixed by setting the proper types when comparing the variables since at least
kube_network_node_prefix
is user supplied input and all user input should be sanitized.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.
Fine by me. So my PR stands, it defaults
calico_pool_blocksize
tokube_network_node_prefix
and then applies type cast.LGTY?
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.
As said above, I think the typecast should be to
int
instead ofstring
but the change in logic is correct.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 I misunderstood your point enforcing int type. That should fixed now