Bug fix: stats --no-stream always print zero values#20803
Bug fix: stats --no-stream always print zero values#20803cpuguy83 merged 1 commit intomoby:masterfrom
Conversation
|
I believe this must be a flaky test because I've seen this twice, and this PR didn't touch that part of code the tests are failing on. https://jenkins.dockerproject.org/job/Docker-PRs-WoW-TP4/1826/console This is a Windows test, so ping @jhowardmsft |
|
LGTM |
|
I'm not seeing the zeroed out stats on master. |
|
@cpuguy83 Just test on the latest master code, it happens all the time: This is a racy problem, go routines will collect stat information for each container, when docker stats try to print it on screen while go routine didn't finish and return, it will print zeros. For the streamed docker stats, you can see the first output is also all zeros, this is caused by same reason. That's why I want docker client to sleep a while when user tried to use PS: my machine is 4*CPU with 4G memory, if it helps. |
|
Since we already have a loop, could we check if the result contains actual data, and only print if it does? (or would that add too much complication) |
d675ca1 to
9ffa626
Compare
|
@thaJeztah I have improved it a little, add a Also I found a potential bug that if we are running ping @calavera , sorry that code is changed, please help take another look. Thank you! 😄 |
There was a problem hiding this comment.
Is this comment is necessary? It should be removed
There was a problem hiding this comment.
Yup, you are right. 👍
11a3c76 to
96e1c80
Compare
|
I just added some test cases, @cpuguy83 you can use these two test cases to verify, I hope it can help. Master branch will fail these two test cases. |
|
@cpuguy83 can you take a look? |
96e1c80 to
815a420
Compare
|
Just found a better way and updated the code. I think this bug is actually caused by this line: change it to Plus |
There was a problem hiding this comment.
Doesn't this conflict with the later calls to waitFirst.Done?
There was a problem hiding this comment.
I don't think so. This defer function is to make sure waitFirst.Done() will be called when the function returns, and getFirst is used to make sure waitFirst.Done() will be called only once, so that WaitGroup.Wait() won't block or error.
I would add a getFirst=true before this line to make it clearer, though it's OK without.
`docker stats --no-stream` always print zero values. ``` $ docker stats --no-stream CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O 7f4ef234ca8c 0.00% 0 B / 0 B 0.00% 0 B / 0 B 0 B / 0 B f05bd18819aa 0.00% 0 B / 0 B 0.00% 0 B / 0 B 0 B / 0 B ``` This commit will let docker client wait until it gets correct stat data before print it on screen. Signed-off-by: Zhang Wei <[email protected]>
815a420 to
ea86c30
Compare
|
Another problematic test? 😢 Edit: existing one: #19937 |
|
And looks like network-connection issues on win2lin https://jenkins.dockerproject.org/job/Docker-PRs-Win2Lin/22791/console |
|
@thaJeztah Yup, they must be problematic. Thank you for restarting tests for me 😆 |
|
LGTM |
Bug fix: stats --no-stream always print zero values



Please provide the following information:
docker stats --no-streamalways print zero values.This commit will let docker client sleep a while to get correct stat
data before print it on screen.
Let docker client sleep 1.5s before print it on screen
Run some containers, then run
docker stats --no-stream, you'll see it.Signed-off-by: Zhang Wei [email protected]