-
Notifications
You must be signed in to change notification settings - Fork 592
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: boolean arguments in fabric calls are interpreted correctly #14030
Conversation
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Thanks for opening a PR! 💯
Howto
More infoPlease take a moment to read through the Magma project's
If this is your first Magma PR, also consider reading
|
|
||
|
||
def _to_boolean(value): | ||
"""Fabric function arguments passed by calling fab from external are strings. |
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.
We are already using the following pattern throughout the fabfile:
destroy_vm = bool(strtobool(destroy_vm))
provision_vm = bool(strtobool(provision_vm))
see e.g. line 494-495.
I think this would also do for the variables we are fixing in this PR. Otherwise, there does not seem to be a reason not to just use _to_boolean
for every instance of a string representing a bool in this file.
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.
This only works here because the default is already a string - e.g., destroy_vm='True'
. This is not consistent in this fabfile and should be aligned. But I see this out of scope for a bug/fix PR.
Two other things:
|
I can create an issue to refactor this - but I see it out of scope for this bug/fix. |
Alright, let's keep the scope smaller for this PR and create a follow-up issue. |
see #14031 |
…ma#14030) Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com> Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock nils.semmelrock@tngtech.com
Summary
In #13984
lte/gateway/fabric.py
was refactored to provide boolean arguments to a public function. A script call likefab my_function:my_bool_arg=False
causes a callmy_function("False")
, i.e., a checkif "False":
would pass.This is only relevant for public functions and not for (implicit) private function prefixed by
_
(can not be called viafab
).Solution here: introduce a helper function that interprets such arguments.
Also here: use this solution for two existing functions
run_integ_tests
onfederated_mode
(default isFalse
) - this is just a precaution as onlyfab run_integ_tests:federated_mode=False
causes problems. But this is currently not used asFalse
is the default.load_test
ondestroy_vm
(default isTrue
) - this does not work iffab load_test:destroy_vm=False
is called. Currently not the case in workflows etc.Test Plan
CI
Additional Information