From f04cfdf6e766c88878608e19118ec3759e5f690f Mon Sep 17 00:00:00 2001 From: Cici Huang Date: Wed, 19 Mar 2025 23:21:30 +0000 Subject: [PATCH] Update gofmt. --- .../dynamicresources/dynamicresources.go | 4 +- .../dynamic-resource-allocation/api/types.go | 2 +- .../resourceslicecontroller_test.go | 65 +++++++++++++++++++ test/integration/scheduler_perf/dra.go | 2 +- 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go b/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go index 4d564f44073..dd1adfc5aa7 100644 --- a/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go +++ b/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go @@ -107,7 +107,7 @@ type DynamicResources struct { enablePrioritizedList bool enableSchedulingQueueHint bool enablePartitionableDevices bool - enableDeviceTaints bool + enableDeviceTaints bool fh framework.Handle clientset kubernetes.Interface @@ -460,7 +460,7 @@ func (pl *DynamicResources) PreFilter(ctx context.Context, state *framework.Cycl AdminAccess: pl.enableAdminAccess, PrioritizedList: pl.enablePrioritizedList, PartitionableDevices: pl.enablePartitionableDevices, - DeviceTaints: pl.enableDeviceTaints, + DeviceTaints: pl.enableDeviceTaints, } allocator, err := structured.NewAllocator(ctx, features, allocateClaims, allAllocatedDevices, pl.draManager.DeviceClasses(), slices, pl.celCache) if err != nil { diff --git a/staging/src/k8s.io/dynamic-resource-allocation/api/types.go b/staging/src/k8s.io/dynamic-resource-allocation/api/types.go index ad62dc7f7b0..1b3ea38ff22 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/api/types.go +++ b/staging/src/k8s.io/dynamic-resource-allocation/api/types.go @@ -62,7 +62,7 @@ type BasicDevice struct { NodeName *string NodeSelector *v1.NodeSelector AllNodes *bool - Taints []resourceapi.DeviceTaint + Taints []resourceapi.DeviceTaint } type DeviceCounterConsumption struct { diff --git a/staging/src/k8s.io/dynamic-resource-allocation/resourceslice/resourceslicecontroller_test.go b/staging/src/k8s.io/dynamic-resource-allocation/resourceslice/resourceslicecontroller_test.go index e65d350554f..226b998071a 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/resourceslice/resourceslicecontroller_test.go +++ b/staging/src/k8s.io/dynamic-resource-allocation/resourceslice/resourceslicecontroller_test.go @@ -731,6 +731,71 @@ func TestControllerSyncPool(t *testing.T) { Pool(resourceapi.ResourcePool{Name: poolName, Generation: 1, ResourceSliceCount: 1}).Obj(), }, }, + "add-shared-counters": { + nodeUID: nodeUID, + initialObjects: []runtime.Object{ + MakeResourceSlice().Name(generatedName1).GenerateName(generateName). + NodeOwnerReferences(ownerName, string(nodeUID)).NodeName(ownerName). + Driver(driverName).Devices([]resourceapi.Device{{ + Name: deviceName, + Basic: &resourceapi.BasicDevice{ + Taints: []resourceapi.DeviceTaint{{ + Effect: resourceapi.DeviceTaintEffectNoExecute, + TimeAdded: &timeAdded, + }}, + }}}). + Pool(resourceapi.ResourcePool{Name: poolName, Generation: 1, ResourceSliceCount: 1}). + Obj(), + }, + inputDriverResources: &DriverResources{ + Pools: map[string]Pool{ + poolName: { + Generation: 1, + Slices: []Slice{{Devices: []resourceapi.Device{{ + Name: deviceName, + Basic: &resourceapi.BasicDevice{ + Taints: []resourceapi.DeviceTaint{ + { + Effect: resourceapi.DeviceTaintEffectNoExecute, + // No time added here! Time from existing slice must get copied during update. + }, + { + Key: "example.com/tainted", + Effect: resourceapi.DeviceTaintEffectNoSchedule, + TimeAdded: &timeAddedLater, + }, + }, + }}}, + }}, + }, + }, + }, + expectedStats: Stats{ + NumUpdates: 1, + }, + expectedResourceSlices: []resourceapi.ResourceSlice{ + *MakeResourceSlice().Name(generatedName1).GenerateName(generateName). + ResourceVersion("1"). + NodeOwnerReferences(ownerName, string(nodeUID)).NodeName(ownerName). + Driver(driverName).Devices([]resourceapi.Device{{ + Name: deviceName, + Basic: &resourceapi.BasicDevice{ + Taints: []resourceapi.DeviceTaint{ + { + Effect: resourceapi.DeviceTaintEffectNoExecute, + TimeAdded: &timeAdded, + }, + { + Key: "example.com/tainted", + Effect: resourceapi.DeviceTaintEffectNoSchedule, + TimeAdded: &timeAddedLater, + }, + }, + }}}). + Pool(resourceapi.ResourcePool{Name: poolName, Generation: 1, ResourceSliceCount: 1}). + Obj(), + }, + }, } for name, test := range testCases { diff --git a/test/integration/scheduler_perf/dra.go b/test/integration/scheduler_perf/dra.go index 8cd7f0a2cfc..67b4c745428 100644 --- a/test/integration/scheduler_perf/dra.go +++ b/test/integration/scheduler_perf/dra.go @@ -341,7 +341,7 @@ claims: allocator, err := structured.NewAllocator(tCtx, structured.Features{ PrioritizedList: utilfeature.DefaultFeatureGate.Enabled(features.DRAPrioritizedList), AdminAccess: utilfeature.DefaultFeatureGate.Enabled(features.DRAAdminAccess), - DeviceTaints: utilfeature.DefaultFeatureGate.Enabled(features.DRADeviceTaints), + DeviceTaints: utilfeature.DefaultFeatureGate.Enabled(features.DRADeviceTaints), }, []*resourceapi.ResourceClaim{claim}, allocatedDevices, draManager.DeviceClasses(), slices, celCache) tCtx.ExpectNoError(err, "create allocator")