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

Improve handling of json output (#43138) #48658

Merged
merged 1 commit into from Jul 20, 2018
Merged

Improve handling of json output (#43138) #48658

merged 1 commit into from Jul 20, 2018

Conversation

wyardley
Copy link
Contributor

What does this PR do?

(This is #48492, but cherry-picked against 2017.7)
Rather than look for [ or { at the beginning of a line, it looks for equality. Since the JSON output of npm install seems to have the first character on its own, this seems to work, at least for the npm version I looked at -- however, I'm open to better / other approaches that would be better. I think the previous approach was a bit too limited, since there could be other output in the future that matches ^[ or ^{.

Not sure if we could just ignore either stdout or stderr (I think some versions of node send the json output to stdout), or if there's another way this could be fixed. I am guessing the json output is reasonably consistent, but haven't tested older versions. [edit, checked, and currently, the message is going to stdout as well as the json output, so that won't work here]

What issues does this PR fix or reference?

Idempotency issue - first run will "fail" with an error, even when packages get installed, if the output has a string like:
[grpc] Success: "/usr/lib/node_modules/@google-cloud/monitoring/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node" is installed via remote, the first run will fail because the json parsing routine fails.

More details in #43138; replaces #48492

Tests written?

Yes

Commits signed with GPG?

Yes

Rather than look for [ or { at the beginning of a line to identify the json
output, just use salt.utils(.json).findjson.
Copy link
Contributor

@terminalmage terminalmage left a comment

Choose a reason for hiding this comment

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

blind-review

@rallytime rallytime merged commit 93d2f51 into saltstack:2017.7 Jul 20, 2018
@wyardley wyardley deleted the wyardley-npm-json-output-2017 branch July 20, 2018 14:40
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