Default to utf-8 when no encoding type found parsing dogwrap output#268
Merged
yannmh merged 1 commit intoDataDog:masterfrom Jun 26, 2018
Merged
Default to utf-8 when no encoding type found parsing dogwrap output#268yannmh merged 1 commit intoDataDog:masterfrom
yannmh merged 1 commit intoDataDog:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Observation:
When using
dogwrap(via a Python 2pip install) to run commands viacron, in cases where thesubmit_modeis set to all, it was expected that bothstdoutandstderrwould appear in DataDog. This was not the case.The event would appear, but the
stdout/stderrwas lostThe output would appear correctly if the
dogwrapcommand was run in the shell, just not incronCause:
In Python 2, the string from the
OutputReaderwas being inspected for anencoding. If this command was run within a shell, an encoding was found (in this case,ANSI_X3.4-1968). However, when run fromcron, no encoding was detected. Thus, attempting to execute a string decode (line.decode(None)) resulted in an error.In Python 3, the encoding inspection defaults to UTF-8, which is a valid encoding type.
This meant the OutputReader would end up returning no values for
stdout/stderr, but the return code and command were still available and sent onto DataDog for client displayingSolution:
In cases where an encoding type is not identified, default to UTF-8
This will ensure the type is never None, and the default value is used.
An alternative solution to this PR is to not decode if no encoding type is identified, but that might cause more issues down the line.
Environment used for debugging and code testing: Ubuntu 16.04, Python 2.7.12/3.5.2