Skip to content
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

Merged
merged 1 commit into from
Apr 14, 2017

Conversation

cgtexmex
Copy link
Contributor

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

@cgtexmex
Copy link
Contributor Author

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...

@jzt
Copy link
Contributor

jzt commented Apr 11, 2017

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
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Run stats with no-stream on a container that doesn't exist
  2. Run stats with no-stream <running container ID>
  3. Run stats with no-stream <non-running container ID>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added...

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

memory

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully not...

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

seconds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

percent -- comment added

@cgtexmex cgtexmex force-pushed the del-boca-vista branch 2 times, most recently from 20db5d8 to a2b5126 Compare April 13, 2017 16:57
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
Copy link
Contributor

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[]
Copy link
Contributor

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.

Copy link
Contributor

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}

Copy link
Contributor Author

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]
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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...

Copy link
Contributor

@mhagen-vmware mhagen-vmware left a 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
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