Skip to content

Commit 89c1925

Browse files
authored
Merge pull request kubernetes#128582 from pohly/dra-resourceslice-unit-test-fix
DRA resource slice controller: fix unit test flake
2 parents 3dcad5f + 3086b58 commit 89c1925

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

staging/src/k8s.io/dynamic-resource-allocation/resourceslice/resourceslicecontroller_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestControllerSyncPool(t *testing.T) {
145145
},
146146
"remove-pool": {
147147
nodeUID: nodeUID,
148-
syncDelay: ptr.To(time.Duration(0)),
148+
syncDelay: ptr.To(time.Duration(0)), // Ensure that the initial object causes an immediate sync of the pool.
149149
initialObjects: []runtime.Object{
150150
MakeResourceSlice().Name(resourceSlice1).UID(resourceSlice1).
151151
NodeOwnerReferences(ownerName, string(nodeUID)).NodeName(ownerName).
@@ -683,6 +683,11 @@ func TestControllerSyncPool(t *testing.T) {
683683
// from informer event handler).
684684
actualState := queue.State()
685685
actualState.Later = nil
686+
// If we let the event handler schedule syncs immediately, then that also races
687+
// and then Ready cannot be compared either.
688+
if test.syncDelay != nil && *test.syncDelay == 0 {
689+
actualState.Ready = nil
690+
}
686691
var expectState workqueue.MockState[string]
687692
assert.Equal(t, expectState, actualState)
688693
})

0 commit comments

Comments
 (0)