Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

pkg/oci: honour CPU period and quota #541

Merged
merged 1 commit into from Jan 6, 2018

Conversation

devimc
Copy link
Collaborator

@devimc devimc commented Jan 4, 2018

the number of vCPUs must be calculated using CPU period and quota
doesn't matter if a memory limit was specified or not

fixes #540

Signed-off-by: Julio Montes julio.montes@intel.com

@sboeuf
Copy link
Collaborator

sboeuf commented Jan 4, 2018

Thanks for fixing the semantic here !
LGTM

Approved with PullApprove Approved with PullApprove

@sboeuf
Copy link
Collaborator

sboeuf commented Jan 4, 2018

@jodh-intel @sameo please merge if you're fine with that.

@jodh-intel
Copy link
Collaborator

Good catch. The code looks good, but we clearly need some tests for this.

Could you add some to TestVmConfig()? We might also (separately) want a .bats test for asserting the Docker args over in https://github.com/clearcontainers/tests too.

@devimc
Copy link
Collaborator Author

devimc commented Jan 5, 2018

@jodh-intel yes, I'm going to add a test in https://github.com/clearcontainers/tests

@jodh-intel
Copy link
Collaborator

@devimc - thanks. I think we do need a unit test too though as TestVmConfig() was updated for quota/period but clearly is missing some cases as we would have expected that test to fail without your fix on this PR.

@devimc
Copy link
Collaborator Author

devimc commented Jan 5, 2018

@jodh-intel sure, working on that

the number of vCPUs must be calculated using CPU period and quota
doesn't matter if a memory limit was specified or not

fixes containers#540

Signed-off-by: Julio Montes <julio.montes@intel.com>
@devimc
Copy link
Collaborator Author

devimc commented Jan 5, 2018

@jodh-intel done, thanks

@jodh-intel
Copy link
Collaborator

jodh-intel commented Jan 5, 2018

Thanks @devimc - I've tested this and with your new test and the old code, TestVmConfig() fails as we'd expect.

lgtm

Approved with PullApprove Approved with PullApprove

@sameo
Copy link
Collaborator

sameo commented Jan 5, 2018

LGTM

Approved with PullApprove Approved with PullApprove

@sameo
Copy link
Collaborator

sameo commented Jan 5, 2018

coveralls shows a 3.5% drop in coverage with this PR. @devimc Could you please look at it?

@devimc
Copy link
Collaborator Author

devimc commented Jan 5, 2018

Hi @sameo , I can't see coveralls results

coverage/coveralls — Waiting for status to be reported 

@jodh-intel
Copy link
Collaborator

Hi @devimc - something odd is up with coveralls today. If you look at the 16.04 log file, you can see https://coveralls.io/jobs/32558455, but like #539 I think it's probably lying about the drop in coverage (you could test that locally I guess).

@devimc
Copy link
Collaborator Author

devimc commented Jan 5, 2018

@jodh-intel yep, I think the same (coverall lied)
@sameo I don't see any drop in the coverage

cd $GOPATH/src/github.com/containers/virtcontainers/pkg/oci
go test -run TestVmConfig -cover -coverprofile cover.txt
go tool cover -html=cover.txt -o coverage.html

@sameo
Copy link
Collaborator

sameo commented Jan 6, 2018

LGTM then

@sameo sameo merged commit 812dac3 into containers:master Jan 6, 2018

if period == 0 {
return vc.Resources{}, fmt.Errorf("Invalid OCI cpu period %d", period)
// round up to 1 CPU
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting - we discussed in a call that we should ensure we understood what this was doing iirc (in particular when it was written in the original/expanded form with real values - like 10000 + (20000 - 1) / 20000. I had a stare and think, and yes, this does the expected and works out how many 'whole cpus' the given quota gets us given the period - but the above round up to 1 CPU comment is slightly misleading - it is really rounding up to ensure we have at least 1 CPU aiui. Just for the record.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the analysis @grahamwhaley. I think you should submit a PR to fix the comment and maybe be more verbose about the reason why this is the right way to compute the number of CPUs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually that comment was add in #344
/cc @wcwxyz

@devimc devimc deleted the constraint/cpu branch March 6, 2018 14:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cpu period and quota aren't honoured
5 participants