Skip to content

cli: container: remove logging in wait-for-exit paths#1731

Open
cyphar wants to merge 1 commit into
docker:masterfrom
cyphar:error-logging
Open

cli: container: remove logging in wait-for-exit paths#1731
cyphar wants to merge 1 commit into
docker:masterfrom
cyphar:error-logging

Conversation

@cyphar
Copy link
Copy Markdown
Contributor

@cyphar cyphar commented Mar 12, 2019

The wait code can output log messages, which can end up with you seeing
"errors" due to not being able to get the exit code, when in reality the
context is timing our or being cancelled. I'm not sure how common this
is on x86, but I can see it all the time on arm64 -- and these error
messages seem quite noisy to me (they also cause the integration-cli
tests to become quite flaky in my testing).

Signed-off-by: Aleksa Sarai asarai@suse.de

@cyphar
Copy link
Copy Markdown
Contributor Author

cyphar commented Mar 12, 2019

This is touching some historically hairy code, sorry for awakening this beast again. :P

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #1731 into master will decrease coverage by <.01%.
The diff coverage is 40%.

@@            Coverage Diff             @@
##           master    #1731      +/-   ##
==========================================
- Coverage   56.14%   56.13%   -0.01%     
==========================================
  Files         306      306              
  Lines       21033    21035       +2     
==========================================
  Hits        11809    11809              
- Misses       8369     8370       +1     
- Partials      855      856       +1

@thaJeztah
Copy link
Copy Markdown
Member

Oh boy, this is indeed some hairy code; wondering if legacyWaitExitOrRemoved is still needed in this situation?

@cpuguy83 @mlaventure ptal

Comment thread cli/command/container/run.go Outdated
The wait code can output log messages, which can end up with you seeing
"errors" due to not being able to get the exit code, when in reality the
context is timing our or being cancelled. I'm not sure how common this
is on x86, but I can see it all the time on arm64 -- and these error
messages seem quite noisy to me (they also cause the integration-cli
tests to become quite flaky in my testing).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
@thaJeztah
Copy link
Copy Markdown
Member

@cpuguy83 ptal

statusChan := waitExitOrRemoved(ctx, dockerCli, createResponse.ID, copts.autoRemove)
// We don't need to wait if we're not attaching.
var statusChan <-chan int
if attach {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if attach is right here, but I really don't understand config.Attach* at all anyway. Right now we might get a panic if you do -a stdin (or in some of the error paths) because we might read from a nil chan -- but I don't see a nice way of solving that.

A simpler way of stopping the issue behind this problem is to just drop the logging code from waitExitOrRemoved.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reading from a nil chain would block forever, not panic.
So we either need another if attach before reading below (so as not to block forever) or make a channel and close it...

I agree waitExitOrRemoved should not be logging.
It could return a channel can handle both exit status and error messages.

I think removing logging, or some way to gate logging, might be a better approach.

@thaJeztah thaJeztah added this to the 29.5.1 milestone May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants