-
Notifications
You must be signed in to change notification settings - Fork 173
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
Fixed race and added support for all option in docker stats #4671
Conversation
3e5fa1a
to
7308f25
Compare
FYI - The integration tests appear out of order since they are named 1-39 and there's currently no 1-38 -- that's because #4339 has integration tests with the 1-38 prefix... |
2. Run Stats with no-stream which will return stats for any running container | ||
3. Run Stats with no-stream all which will return stats for all containers | ||
4. Verify the API memory output against govc | ||
5. Verify the API CPU output against govc |
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.
- Run stats with no-stream on a container that doesn't exist
- Run stats with no-stream <running container ID>
- Run stats with no-stream <non-running container ID>
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.
added...
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.
tests look good, can you add them here to the md as well? I am not seeing them...
#Expected Outcome: | ||
1. Fails if two containers are not created | ||
2. Return stats for a single container and validate memory -- will fail if there's too | ||
much variation in the memroy |
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.
memory
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.
fixed
|
||
#Possible Problems: | ||
Stats are created by the ESXi host every 20s -- if there are long pauses between calls | ||
in a single test the results could be incorrect and a failure could occur. |
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 going to cause intermittent failures in the CI?
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.
Hopefully not...
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.
hah, 🤞
Stats No Stream | ||
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} stats --no-stream | ||
Should Be Equal As Integers ${rc} 0 | ||
${output}= Get Line ${output} 1 |
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.
Get line -1 would be safer, as I think you want the last line of the output?
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 want the first container -- which should be the last line of output. I'm using Get Line ${output} 1
because I understand it to return a specific array element by ordinal position. Which in all my tests it does.
How would Get Line -1
work or be safer?
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.
-1 grabs the last line of output. so in case for some reason there was a hangover container or something it would be safer as it would always grab the last line
# convert to percent and move decimal | ||
${percent}= Evaluate (${vmomiMemory}/2048000)*100 | ||
${diff}= Evaluate ${percent}-${vicMemory} | ||
# due to timing we could see some variation, but shouldn't exceed 5 |
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.
seconds?
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.
percent -- comment added
20db5d8
to
a2b5126
Compare
Stats No Stream | ||
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} stats --no-stream | ||
Should Be Equal As Integers ${rc} 0 | ||
${output}= Get Line ${output} 1 |
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.
-1 grabs the last line of output. so in case for some reason there was a hangover container or something it would be safer as it would always grab the last line
Should Be Equal As Integers ${rc} 0 | ||
${stress}= Get Container ShortID %{STRESSED} | ||
${rc} ${vmomiCPU}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run And Return Rc And Output govc metric.sample -json vm/*${stress} cpu.usagemhz.average | jq -r .Sample[].Value[0].Value[] | ||
${rc} ${vmomiCPU}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run And Return Rc And Output govc metric.sample -json */%{VCH-NAME}/*${stress} cpu.usagemhz.average | jq -r .Sample[].Value[0].Value[] |
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.
can't do this var assignment like this, with esxi it will always get overwritten to null.
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.
easier to just do something like this:
Run keyword if host_type == ESXi Set test variable ${my_path} vm/*${stress}
Run keyword if host_type == VC Set test variable ${my_path} /%{VCH-NAME}/${stress}
Then just a single run and return command with the ${my_path}
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.
cool..that's what I thought about doing originally...but then punted...thanks!
Should Be Equal As Integers ${rc} 0 | ||
${stress}= Get Container ShortID %{STRESSED} | ||
${rc} ${vmomiMemory}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run And Return Rc And Output govc metric.sample -n 1 -json vm/*${stress} mem.active.average | jq -r .Sample[].Value[].Value[0] | ||
${rc} ${vmomiMemory}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run And Return Rc And Output govc metric.sample -n 1 -json */%{VCH-NAME}/*${stress} mem.active.average | jq -r .Sample[].Value[].Value[0] |
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.
same as below
|
||
#Possible Problems: | ||
Stats are created by the ESXi host every 20s -- if there are long pauses between calls | ||
in a single test the results could be incorrect and a failure could occur. |
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.
hah, 🤞
2. Run Stats with no-stream which will return stats for any running container | ||
3. Run Stats with no-stream all which will return stats for all containers | ||
4. Verify the API memory output against govc | ||
5. Verify the API CPU output against govc |
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.
tests look good, can you add them here to the md as well? I am not seeing them...
a2b5126
to
16fda6e
Compare
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.
lgtm
In some cases a race could be encountered when executing docker stats. The race would result in an orphaned go routine that would be a memory leak. In addition if stats --no-stream -all was requested the persona would hang on any stopped containers. Stats now will consider the container state when processing these requests. Finally, the unit testing coverage was increased to just over 90% and integration tests were created. Fixes vmware#4549, vmware#4585, vmware#4421
16fda6e
to
3a12638
Compare
In some cases a race could be encountered when executing docker
stats. The race would result in an orphaned go routine that
would be a memory leak.
In addition if stats --no-stream -all was requested the persona
would hang on any stopped containers. Stats now will consider
the container state when processing these requests.
Finally, the unit testing coverage was increased to just over
90% and integration tests were created.
Fixes #4549, #4585, #4421