Skip to content

Commit b0b5a0c

Browse files
author
Kathryn Baldauf
authored
Add build version block for pod CPU limits updating (#2321)
Signed-off-by: Kathryn Baldauf <[email protected]>
1 parent 9cf7c1c commit b0b5a0c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

internal/uvm/cpulimits_update.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ import (
77

88
"github.com/Microsoft/hcsshim/internal/hcs/resourcepaths"
99
hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
10+
"github.com/Microsoft/hcsshim/osversion"
11+
"github.com/containerd/errdefs"
1012
)
1113

1214
// UpdateCPULimits updates the CPU limits of the utility vm
1315
func (uvm *UtilityVM) UpdateCPULimits(ctx context.Context, limits *hcsschema.ProcessorLimits) error {
16+
// Support for updating CPU limits was not added until 20H2 build
17+
if osversion.Get().Build < osversion.V20H2 {
18+
return errdefs.ErrNotImplemented
19+
}
1420
req := &hcsschema.ModifySettingRequest{
1521
ResourcePath: resourcepaths.CPULimitsResourcePath,
1622
Settings: limits,

test/cri-containerd/pod_update_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import (
1010
"testing"
1111

1212
"github.com/Microsoft/hcsshim/internal/memory"
13+
"github.com/Microsoft/hcsshim/osversion"
1314
"github.com/Microsoft/hcsshim/pkg/annotations"
1415
"github.com/Microsoft/hcsshim/test/pkg/definitions/cpugroup"
1516
"github.com/Microsoft/hcsshim/test/pkg/definitions/processorinfo"
17+
"github.com/Microsoft/hcsshim/test/pkg/require"
1618
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
1719
)
1820

@@ -132,6 +134,7 @@ func Test_Pod_UpdateResources_Memory_PA(t *testing.T) {
132134

133135
func Test_Pod_UpdateResources_CPUShares(t *testing.T) {
134136
requireAnyFeature(t, featureWCOWHypervisor)
137+
require.Build(t, osversion.V20H2)
135138

136139
type config struct {
137140
name string

0 commit comments

Comments
 (0)