-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix no logs in stdout/stderr if uses stdoutConfig #6162
Conversation
/kind bug |
/assign @wlynch |
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
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.
This will probably need a release-note
entry 👼🏼
thanks @vdemeester , i added the |
/test pull-tekton-pipeline-integration-tests |
@chengjoey thanks for this fix. As you pointed out, there is a test for this, which was already succeeding, which unfortunately means there is full coverage for this change - it could be inadvertently broken again and the tests would not catch it. |
@wlynch it would be nice if you could review this one since you changed this code last 🙏 |
used to only collect stdout and err to a file if the std{out/err}Path is specified, now add both os.std{out/err} and the std{out/err}Path to multiwriter to collect logs
2efb66d
to
4587a7f
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
Of course, i added verification in |
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.
One thing, otherwise LGTM!
oldStdout := os.Stdout // keep backup of the real stdout | ||
outReader, outWriter, _ := os.Pipe() | ||
os.Stdout = outWriter | ||
|
||
oldStderr := os.Stderr | ||
errReader, errWriter, _ := os.Pipe() | ||
os.Stderr = errWriter |
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.
This seems brittle since it modifies global state.
How about we:
- Modify realRunner to take in io.Writers
- Have main.go initialize the multiwriters if the flag is set.
- If the writers are nil, default to os.Stdout/Stderr
This way in tests we can just use a buffer and remove a bunch of the path manipulation?
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.
The test here is to verify that logs can be printed to standard output. If you modify realRunner to accept io.Writers, you need to pass in os.stdout, which is the same as the current situation.
/test pull-tekton-pipeline-alpha-integration-tests |
/assign |
return nil, fmt.Errorf("error creating pipe: %w", err) | ||
} | ||
|
||
// be used for multiple streams if desired. note that close after use |
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.
Is this docstring missing after "note that close after use"?
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.
It's not missing, I just modified the note here and added it to where it was used.
notes related to teaReader are no longer needed here
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vdemeester, Yongxuanzhang The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
@chengjoey @pritidesai @jerop should this be cherry-picked in the latest LTS ? (0.41 and 0.44) |
/cherry-pick release-v0.41.x |
@chengjoey: #6162 failed to apply on top of branch "release-v0.41.x":
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
…ektoncd#6162) used to only collect stdout and err to a file if the std{out/err}Path is specified, now add both os.std{out/err} and the std{out/err}Path to multiwriter to collect logs io/ioutil has been deprecaed in Go 1.16 Signed-off-by: chengjoey <zchengjoey@gmail.com>
when i try to cherry-pick to 0.41, there are some conflicts, I manually submitted a hotfix pr, is this the correct hotfix process |
…6162) used to only collect stdout and err to a file if the std{out/err}Path is specified, now add both os.std{out/err} and the std{out/err}Path to multiwriter to collect logs io/ioutil has been deprecaed in Go 1.16 Signed-off-by: chengjoey <zchengjoey@gmail.com>
/cherry-pick release-v0.44.x |
@chengjoey: new pull request created: #6506 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Changes
fix #6136
used to only collect stdout and err to a file if the std{out/err}Path is specified, now add both os.std{out/err} and the std{out/err}Path to multiwriter to collect logs.
there is a full test to verify the stdoutConfig, in addition, this pr adds the verification of whether to print the log to standard output in the
TestRealRunnerStdoutAndStderrPaths
testSubmitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes