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(lte): Fixed detect_init_system #14034

Merged

Conversation

MoritzThomasHuebner
Copy link
Contributor

@MoritzThomasHuebner MoritzThomasHuebner commented Sep 29, 2022

Closes #14033

Signed-off-by: Moritz Huebner moritz.huebner@tngtech.com

Summary

  • Added exec_command_capture_output to allow running commands that return non-zero status codes without raising an exception.
  • Moved _is_installed function outside detect_init_system.
  • Simplified docker/systemd_magmad_running logic.
  • Renamed MagmadUtil._data to MagmadUtil._credentials and removed "command" key.
  • No longer write "command" to MagmadUtil._credentials, as this was not used anyway.

Test Plan

See if an integration test can be started

  • with a dockerized setup
  • with a systemd setup

@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines. label Sep 29, 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 29, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2022

feg-workflow

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

Results for commit 1ab0f7b.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2022

dp-workflow

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

Results for commit 1ab0f7b.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2022

agw-workflow

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

Results for commit 1ab0f7b.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@nstng nstng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this - I was sure I checked the service not running case :( but yeah, I can reproduce the issue.

Refactoring also lgtm.

NIT I would have preferred a prior check if the tool is installed (was done via type before the change). It feels a little hacky that a 'command not found' is basically ignored and the empty stdout is compared in that case. Raw return of subprocess.run:

CompletedProcess(args=['sshpass', '-p', 'vagrant', 'ssh', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', '-o', 'LogLevel=ERROR', 'vagrant@192.168.60.142', "docker ps --filter 'name=magmad' --format '{{.Names}}'"], returncode=127, stdout=b'', stderr=b'bash: docker: command not found\n')

@nstng
Copy link
Contributor

nstng commented Sep 29, 2022

restarted failing required jobs - looks like a connection hiccup

@MoritzThomasHuebner
Copy link
Contributor Author

Thank you for fixing this - I was sure I checked the service not running case :( but yeah, I can reproduce the issue.

Refactoring also lgtm.

NIT I would have preferred a prior check if the tool is installed (was done via type before the change). It feels a little hacky that a 'command not found' is basically ignored and the empty stdout is compared in that case. Raw return of subprocess.run:

CompletedProcess(args=['sshpass', '-p', 'vagrant', 'ssh', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', '-o', 'LogLevel=ERROR', 'vagrant@192.168.60.142', "docker ps --filter 'name=magmad' --format '{{.Names}}'"], returncode=127, stdout=b'', stderr=b'bash: docker: command not found\n')

I'll have another look at this next week, but I think this is out of scope for this PR.

- Added `exec_command_capture_output` to have an option to capture stdout and continue on non-zero exit codes.
- Removed `_is_installed` function.
- Simplified docker/systemd_magmad_running logic.
- Renamed `MagmadUtil._data` to `MagmadUtil._credentials` and removed "command" key.
- No longer write "command" to `MagmadUtil._credentials`, as this was not used anyway.

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>
@MoritzThomasHuebner
Copy link
Contributor Author

@nstng I added the _is_installed back in as you suggested.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2022

Oops! Looks like you failed the Python Format Check.

Howto

♻️ Updated: ✅ The check is passing the Python Format Check after the last commit.

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>
- replace `&` with `and` in magmad running checks so that second condition is only evaluated if the first suceeds
- Improved docstring of `exec_command_capture_output`
- Added type hints to `exec_command`, `exec_command_output`, and `exec_command_capture_output` to highlight how these methods are different

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>
- Perform sequential checks for installation and if magma is running
- Remove exec_command_capture_output again as it is now unused

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

Oops! Looks like you failed the DCO check. Be sure to sign all your commits.

Howto

♻️ Updated: ✅ The check is passing the DCO check after the last commit.

This reverts commit 2bb7908.

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>
Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>
@nstng nstng self-requested a review October 4, 2022 07:56
Copy link
Member

@VinashakAnkitAman VinashakAnkitAman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please rebase the code as some ci check is failing.

@MoritzThomasHuebner MoritzThomasHuebner merged commit eb377c0 into magma:master Oct 5, 2022
pruthvihebbani pushed a commit to pruthvihebbani/magma that referenced this pull request Oct 10, 2022
* fix(lte): Fixed `detect_init_system`

- Added `exec_command_capture_output` to have an option to capture stdout and continue on non-zero exit codes.
- Removed `_is_installed` function.
- Simplified docker/systemd_magmad_running logic.
- Renamed `MagmadUtil._data` to `MagmadUtil._credentials` and removed "command" key.
- No longer write "command" to `MagmadUtil._credentials`, as this was not used anyway.

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>

* fix(lte): Added _is_installed check back in

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>

* fix(lte): Improve changes in previous commits

- replace `&` with `and` in magmad running checks so that second condition is only evaluated if the first suceeds
- Improved docstring of `exec_command_capture_output`
- Added type hints to `exec_command`, `exec_command_output`, and `exec_command_capture_output` to highlight how these methods are different

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>

* fix(lte): Improve changes in previous commits

- Perform sequential checks for installation and if magma is running
- Remove exec_command_capture_output again as it is now unused

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>

* Revert "fix(lte): Improve changes in previous commits"

This reverts commit 2bb7908.

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>

* fix(lte): Properly moved installation checks first

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>

Signed-off-by: Moritz Huebner <moritz.huebner@tngtech.com>
@MoritzThomasHuebner MoritzThomasHuebner deleted the fix_detect_init_system branch February 23, 2023 01:19
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/M Denotes a PR that changes 30-99 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

detect_init_system is broken for the dockerized AGW
3 participants