Skip to content

Commit

Permalink
Add build version block for pod CPU limits updating
Browse files Browse the repository at this point in the history
Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
  • Loading branch information
katiewasnothere committed Nov 14, 2024
1 parent c65b789 commit f186109
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/uvm/cpulimits_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import (

"github.com/Microsoft/hcsshim/internal/hcs/resourcepaths"
hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
"github.com/Microsoft/hcsshim/osversion"
"github.com/containerd/errdefs"
)

// UpdateCPULimits updates the CPU limits of the utility vm
func (uvm *UtilityVM) UpdateCPULimits(ctx context.Context, limits *hcsschema.ProcessorLimits) error {
// Support for updating CPU limits was not added until 20H2 build
if osversion.Get().Build < osversion.V20H2 {
return errdefs.ErrNotImplemented
}
req := &hcsschema.ModifySettingRequest{
ResourcePath: resourcepaths.CPULimitsResourcePath,
Settings: limits,
Expand Down
3 changes: 3 additions & 0 deletions test/cri-containerd/pod_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import (
"testing"

"github.com/Microsoft/hcsshim/internal/memory"
"github.com/Microsoft/hcsshim/osversion"
"github.com/Microsoft/hcsshim/pkg/annotations"
"github.com/Microsoft/hcsshim/test/pkg/definitions/cpugroup"
"github.com/Microsoft/hcsshim/test/pkg/definitions/processorinfo"
"github.com/Microsoft/hcsshim/test/pkg/require"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

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

func Test_Pod_UpdateResources_CPUShares(t *testing.T) {
requireAnyFeature(t, featureWCOWHypervisor)
require.Build(t, osversion.V20H2)

type config struct {
name string
Expand Down

0 comments on commit f186109

Please sign in to comment.