Ensure CPU quota/period updates are sent to runc

Fixes an issue where if cpu quota/period is sent via the update API, the
values are updated in the stored container data but not actually sent to
the running container.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 86ba63db82e87c943c9dee52559118e46f23defc
Component: engine
This commit is contained in:
Brian Goff
2018-01-16 11:50:14 -05:00
parent a9d5589889
commit fe856d6a3e
2 changed files with 115 additions and 0 deletions
+7
View File
@@ -30,6 +30,13 @@ func toContainerdResources(resources container.Resources) *libcontainerd.Resourc
period = uint64(100 * time.Millisecond / time.Microsecond)
quota = resources.NanoCPUs * int64(period) / 1e9
}
if quota == 0 && resources.CPUQuota != 0 {
quota = resources.CPUQuota
}
if period == 0 && resources.CPUPeriod != 0 {
period = uint64(resources.CPUPeriod)
}
r.CPU.Period = &period
r.CPU.Quota = &quota