-
Notifications
You must be signed in to change notification settings - Fork 4
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
Pipe ka-clone's logging to stdout and stderr depending on level so other scripts can parse non-fatal errors #21
Draft
lillialexis
wants to merge
6
commits into
master
Choose a base branch
from
error-to-stderr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1ad5945
[error-exit-code] Return non-zero if something wrong happens, even if…
lillialexis ad4e69e
[error-exit-code] fr
lillialexis d35e2a5
[error-exit-code] g
lillialexis 0a3dc74
[error-to-stderr] omg maybe working
lillialexis dc5f881
[error-to-stderr] clean up
lillialexis c2d6e33
[error-to-stderr] lint
lillialexis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this PR. Won't it print "The git config file is not installed" twice, once due to this line and once due to line 466?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah, you're right. 🤦♀️
It doesn't print twice if you call ka-clone through the OLC module, as the module uses
inherit
forstdout/stdin
, when calling ka-clone, andpipe
forstderr
. That means that it is able to dump thestdout
-stream to the console as it runs, but capture thestderr
separately to be able to display to the user after the command finishes (whenstderr
not empty). Here is the PR that complements this one and does that: https://github.com/Khan/our-lovely-cli/pull/893There's actually an even worse issue with this PR and PR 893, that hit me as I was drifting off to sleep last night. As it currently stands, there is a sort-of race condition, where a user could be on post-893-OLC and pre-21-ka-clone. In that rare-but-possible case, because the default behavior of Python's
logging
is to output tostderr
, then it will appear to the user that ka-clone hit issues no matter what. It looks like this:That's the normal output of ka-clone.
When I originally used a
version
flag to make sure ka-clone was on the correct version for OLC, I could have just bumped that from 1 to 2 in this PR and PR 893 to close this gap. But then we switched to using presence-of-command-line-args instead.But, I think that actually ends up working out better, given this feedback! Maybe I can just add a new arg that OLC has and checks for (closing the race-condition-gap) that only outputs to
stderr
whentrue
(fixing the double-output-bug).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your goal is to have ka-clone emit output that can be parsed by another script, you should just support this directly. Have a
--json
flag or something, that emits the results of ka-clone as a json blob, to stdout, and have OLC parse that blob and do what it needs to do. And when--json
is set, you can change the way that_cli_log_step_indented_info
behaves, maybe it saves its data to a buffer somewhere, and you can format and emit that buffer at program exit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree that that's the most "right" way of doing things, I think that it isn't worth the time it will take to implement. I'm trying to limit the amount of new code, as I need to wrap this project up. But I also want a quick and easy way to flag to the user that something isn't quite right, as the warnings from the
ka-clone
output get lost. And the only thing I'm doing with the output is piping it to the user; I'm not parsing it any more than just seeing if something is instderr
versusstdout
. (The OLC tools do this with thegit
output too.)