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

Use files instead of pipes to capture stdout/stderr #1434

Merged
merged 2 commits into from Jan 4, 2019

Conversation

narrieta
Copy link
Member

@narrieta narrieta commented Dec 31, 2018

  • Use files instead of pipes to capture stdout/stderr
  • Test fixes for ExtensionTestCase (test_extension.py)
  • Added a few assert methods to AgentTestCase (tools.py)

Addresses #1357


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

Copy link
Contributor

@pgombar pgombar left a comment

Choose a reason for hiding this comment

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

LGTM for this iteration

time.sleep(1)
retry -= 1

def read_output():
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, it would be a good idea to use try/catch for this method in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, @pgombar. Added error handling and also limited the amount of data we load into memory.

Copy link
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

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

LGTM. Left some comments.

@@ -78,7 +68,7 @@ def to_s(captured_stdout, stdout_offset, captured_stderr, stderr_offset):
return to_s(stdout, -1*max_len_each, stderr, -1*max_len_each)


def _destroy_process(process, signal_to_send=signal.SIGKILL):
def destroy_process(process, signal_to_send=signal.SIGKILL):
Copy link
Member

Choose a reason for hiding this comment

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

With the capture_from_process_no_timeout and capture_from_process_raw now gone, is this method used anymore? I can see its imported in exthandlers.py but os.killpg() is used in it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing this out, @vrdmr. I reviewed the code and confirmed the functionality on this function is no longer needed so I removed it.

if env is None:
env = {}
env.update(os.environ)
with tempfile.TemporaryFile(dir=base_dir, mode="w+b") as stdout:
Copy link
Member

Choose a reason for hiding this comment

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

Something to discuss - I would recommend redirecting the stdout/stderr in the /var/log/azure/(EXTN)/ directory - If in case the file becomes too large, the user should be able to delete the file forcefully, and need not be root.

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed offline - the log directory is also restricted to root (for writes), and also deleting the file has no effect since the extension still holds a handle to it. When the extension completes, the file will be deleted by the OS.

@narrieta
Copy link
Member Author

narrieta commented Jan 3, 2019

@vrdmr @pgombar - I addressed your comments in a new commit, would you take a look at the diffs? Thanks

@vrdmr vrdmr added this to the v2.2.35 milestone Jan 3, 2019
Copy link
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks.

@narrieta narrieta merged commit 66dfc94 into Azure:master Jan 4, 2019
@narrieta narrieta deleted the command-output branch January 4, 2019 19:00
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.

None yet

3 participants