-
Notifications
You must be signed in to change notification settings - Fork 39.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
Bugfix: Use local JSON log buffer in parseDockerJSONLog. #50381
Conversation
Hi @sczizzo. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. 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. I understand the commands that are listed here. |
/ok-to-test |
/test pull-kubernetes-e2e-gce-etcd3 |
This seems horribly broken to start with, which makes me suspicious of whether something deeper is happening. |
/lgtm |
/cc @Random-Liu |
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.
Sorry for the stupid bug. Don't know what I was thinking at that time...
@sczizzo Thanks for the fix!
dockerJSONLog.Reset() | ||
l := dockerJSONLog | ||
var l = &jsonlog.JSONLog{} | ||
l.Reset() |
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 reset is not needed then.
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.
@sczizzo could you fix this? Thanks!
We should cherry-pick this to 1.7 and 1.6. |
/retest |
/lgtm Let's get this merged. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: feiskyer, sczizzo, yujuhong Associated issue: 47800 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
/test pull-kubernetes-unit |
/retest |
Automatic merge from submit-queue (batch tested with PRs 50381, 51307, 49645, 50995, 51523) |
oops, my pull request was much earlier than this. Thanks for fix it as well. 👍 |
Will this get cherry-picked into 1.6 and 1.7? Causing a bunch of problems for us ... |
Automatic merge from submit-queue Automated cherry pick of #50381 to release-1.6 **What this PR does / why we need it**: Use local JSON log buffer in parseDockerJSONLog. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #47800 **Special notes for your reviewer**: **Release note**: ```release-note Fixed an issue (#47800) where `kubectl logs -f` failed with `unexpected stream type ""`. ```
Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked. |
What this PR does / why we need it:
The issue described in #47800 is due to a race condition in
ReadLogs
: Because the JSON log buffer (dockerJSONLog
) is package-scoped, any two goroutines modifying the buffer could race and overwrite the other's changes. In particular, one goroutine could unmarshal a JSON log line into the buffer, then another goroutine couldReset()
the buffer, and the resultingStream
would be empty (""
). This emptyStream
is caught in acase
block and raises anunexpected stream type
error.This PR creates a new buffer for each execution of
parseDockerJSONLog
, so each goroutine is guaranteed to have a local instance of the buffer.Which issue this PR fixes: fixes #47800
Release note: