Skip to content

Commit 6ddb28f

Browse files
committed
Set default CPU period and quota for LCOW containers
For LCOW containers, if the CPU Period and Quota are not set in the Linux Resource Limits, then we set the default values for the same. This commit adds the change. Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
1 parent f042cd0 commit 6ddb28f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/hcsoci/hcsdoc_lcow.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ import (
1616
)
1717

1818
func createLCOWSpec(ctx context.Context, coi *createOptionsInternal) (*specs.Spec, error) {
19+
// Set default CPU period and quota if not set for LCOW containers.
20+
if coi.Spec.Linux != nil &&
21+
coi.Spec.Linux.Resources != nil &&
22+
coi.Spec.Linux.Resources.CPU != nil {
23+
24+
if coi.Spec.Linux.Resources.CPU.Period != nil && *coi.Spec.Linux.Resources.CPU.Period == 0 {
25+
*coi.Spec.Linux.Resources.CPU.Period = 100000 // Default CPU period
26+
}
27+
if coi.Spec.Linux.Resources.CPU.Quota != nil && *coi.Spec.Linux.Resources.CPU.Quota == 0 {
28+
*coi.Spec.Linux.Resources.CPU.Quota = -1 // No CPU limit
29+
}
30+
}
31+
1932
// Remarshal the spec to perform a deep copy.
2033
j, err := json.Marshal(coi.Spec)
2134
if err != nil {

0 commit comments

Comments
 (0)