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

Refactor start_extension_command to handle subprocess completion or timeout #1623

Merged
merged 5 commits into from
Sep 12, 2019

Conversation

pgombar
Copy link
Contributor

@pgombar pgombar commented Aug 27, 2019

Description

Before, it was the responsibility of ExtHandlerInstance's launch_command to wait for the subprocess to terminate or timeout, parse its output and raise exceptions if needed.

Since the actual invocation of the subprocess is done in the CGroup API layer, if systemd-run times out, we wouldn't know until the ExtHandlerInstance layer, at which point we wouldn't retry invoking the subprocess using Popen and we would erroneously raise an ExtensionError which would be counted against the extension's SLA.

This PR refactors the code so that these responsibilities are done in the start_extension_command in the CGroup API layer instead of inlaunch_command. Helper functions for waiting for process completion are added to process_utils.py and corresponding unit tests are added or updated.


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • Except for special cases involving multiple contributors, the PR is started from a fork of the main repository, not a branch.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made and Travis.CI is passing.

Quality of Code and Contribution Guidelines


This change is Reviewable

@codecov
Copy link

codecov bot commented Aug 27, 2019

Codecov Report

❗ No coverage uploaded for pull request base (develop@1c453e8). Click here to learn what that means.
The diff coverage is 92%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop    #1623   +/-   ##
==========================================
  Coverage           ?   66.58%           
==========================================
  Files              ?       78           
  Lines              ?    11200           
  Branches           ?     1572           
==========================================
  Hits               ?     7458           
  Misses             ?     3413           
  Partials           ?      329
Impacted Files Coverage Δ
azurelinuxagent/ga/env.py 52.38% <0%> (ø)
...urelinuxagent/common/utils/extensionprocessutil.py 100% <100%> (ø)
azurelinuxagent/ga/exthandlers.py 82.04% <100%> (ø)
azurelinuxagent/common/cgroupconfigurator.py 91.35% <100%> (ø)
azurelinuxagent/common/cgroupapi.py 79.77% <87.8%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c453e8...b2f367f. Read the comment docs.

Copy link
Contributor

@larohra larohra left a comment

Choose a reason for hiding this comment

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

LGTM

@pgombar pgombar mentioned this pull request Sep 10, 2019
6 tasks
azurelinuxagent/common/utils/processutil.py Show resolved Hide resolved
tests/utils/test_process_util.py Outdated Show resolved Hide resolved
tests/utils/test_process_util.py Outdated Show resolved Hide resolved
tests/utils/test_process_util.py Outdated Show resolved Hide resolved
tests/utils/test_process_util.py Outdated Show resolved Hide resolved
azurelinuxagent/common/utils/processutil.py Outdated Show resolved Hide resolved
azurelinuxagent/common/utils/processutil.py Show resolved Hide resolved
azurelinuxagent/common/cgroupapi.py Outdated Show resolved Hide resolved
azurelinuxagent/common/cgroupapi.py Show resolved Hide resolved
tests/common/test_cgroupapi.py Outdated Show resolved Hide resolved
tests/common/test_cgroupapi.py Show resolved Hide resolved
tests/common/test_cgroupapi.py Show resolved Hide resolved
tests/common/test_cgroupapi.py Outdated Show resolved Hide resolved
Copy link
Contributor

@larohra larohra left a comment

Choose a reason for hiding this comment

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

Minor suggestion else LGTM

@pgombar pgombar merged commit 650e9ae into Azure:develop Sep 12, 2019
@pgombar pgombar deleted the improve_launch_command branch September 12, 2019 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants