Skip to content
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

Merged
merged 1 commit into from
Sep 28, 2022

Conversation

nstng
Copy link
Contributor

@nstng nstng commented Sep 28, 2022

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 like fab my_function:my_bool_arg=False causes a call my_function("False"), i.e., a check if "False": would pass.

This is only relevant for public functions and not for (implicit) private function prefixed by _ (can not be called via fab).

Solution here: introduce a helper function that interprets such arguments.

Also here: use this solution for two existing functions

  • run_integ_tests on federated_mode (default is False) - this is just a precaution as only fab run_integ_tests:federated_mode=False causes problems. But this is currently not used as False is the default.
  • load_test on destroy_vm (default is True) - this does not work if fab load_test:destroy_vm=False is called. Currently not the case in workflows etc.

Test Plan

CI

Additional Information

  • This change is backwards-breaking

Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
@nstng nstng requested a review from a team as a code owner September 28, 2022 07:03
@nstng nstng requested a review from pshelar September 28, 2022 07:03
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines. label Sep 28, 2022
@github-actions
Copy link
Contributor

Thanks for opening a PR! 💯

A couple initial guidelines

Howto

  • Reviews. The "Reviewers" listed for this PR are the Magma maintainers who will shepherd it.
  • Checks. All required CI checks must pass before merge.
  • Merge. Once approved and passing CI checks, use the ready2merge label to indicate the maintainers can merge your PR.

More info

Please take a moment to read through the Magma project's

If this is your first Magma PR, also consider reading

@github-actions github-actions bot added the component: agw Access gateway-related issue label Sep 28, 2022
@github-actions
Copy link
Contributor

feg-workflow

    2 files  203 suites   40s ⏱️
374 tests 374 ✔️ 0 💤 0
388 runs  388 ✔️ 0 💤 0

Results for commit 43c1199.

@github-actions
Copy link
Contributor

dp-workflow

14 tests   14 ✔️  2m 13s ⏱️
  1 suites    0 💤
  1 files      0

Results for commit 43c1199.

@github-actions
Copy link
Contributor

agw-workflow

615 tests   611 ✔️  3m 45s ⏱️
    2 suites      4 💤
    2 files        0

Results for commit 43c1199.



def _to_boolean(value):
"""Fabric function arguments passed by calling fab from external are strings.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@MoritzThomasHuebner
Copy link
Contributor

Two other things:

@nstng
Copy link
Contributor Author

nstng commented Sep 28, 2022

Two other things:

* A similar function also exists in the cwf fabfile: https://github.com/magma/magma/blob/e736de238665e0f3041de2400a121697b1fc0a6e/cwf/gateway/fabfile.py#L280
   -> Perhaps there could be a more uniform solution for this issue.

* The same issue also clearly exists in the fabfile for the federated integ tests, e.g. the `clear_orc8r` variable is not correctly converted to a boolean: https://github.com/magma/magma/blob/e736de238665e0f3041de2400a121697b1fc0a6e/lte/gateway/python/integ_tests/federated_tests/fabfile.py#L66

@MoritzThomasHuebner

  • I agree this should be aligned among the fabfiles
  • agree, this looks damaged

I can create an issue to refactor this - but I see it out of scope for this bug/fix.

@MoritzThomasHuebner
Copy link
Contributor

Alright, let's keep the scope smaller for this PR and create a follow-up issue.

@nstng nstng merged commit 8028302 into magma:master Sep 28, 2022
@nstng
Copy link
Contributor Author

nstng commented Sep 28, 2022

Alright, let's keep the scope smaller for this PR and create a follow-up issue.

see #14031

pruthvihebbani pushed a commit to pruthvihebbani/magma that referenced this pull request Oct 10, 2022
…ma#14030)

Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>

Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: agw Access gateway-related issue size/S Denotes a PR that changes 10-29 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants