DRA scheduler unit test: fix race with ResourceSlice informer

The test started without waiting for the ResourceSlice informer to have
synced. As a result, the "CEL-runtime-error-for-one-of-three-nodes" test case
failed randomly with a very low flake rate (less than 1% in local runs) because
CEL expressions never got evaluated due to not having the slices (yet).

Other tests also were less reliable, but not known to fail.
This commit is contained in:
Patrick Ohly 2025-11-06 18:02:03 +01:00
parent 789f06544d
commit 1c4cab9dda
3 changed files with 3 additions and 3 deletions

View file

@ -2493,7 +2493,7 @@ func setup(t *testing.T, args *config.DynamicResourcesArgs, nodes []*v1.Node, cl
// is synced, we need to wait until HasSynced of the handler returns
// true, this ensures that the assume cache is in sync with the informer's
// store which has been informed by at least one full LIST of the underlying storage.
cache.WaitForCacheSync(tc.ctx.Done(), registeredHandler.HasSynced)
cache.WaitForCacheSync(tc.ctx.Done(), registeredHandler.HasSynced, resourceSliceTracker.HasSynced)
for _, node := range nodes {
nodeInfo := framework.NewNodeInfo()

View file

@ -145,7 +145,7 @@ func (a *Allocator) Allocate(ctx context.Context, node *v1.Node, claims []*resou
result: make([]internalAllocationResult, len(claims)),
allocatingCapacity: NewConsumedCapacityCollection(),
}
alloc.logger.V(5).Info("Starting allocation", "numClaims", len(alloc.claimsToAllocate))
alloc.logger.V(5).Info("Starting allocation", "numClaims", len(alloc.claimsToAllocate), "numSlices", len(alloc.slices))
defer func() {
alloc.logger.V(5).Info("Done with allocation", "success", len(finalResult) == len(alloc.claimsToAllocate), "err", finalErr)
}()

View file

@ -116,7 +116,7 @@ func (a *Allocator) Allocate(ctx context.Context, node *v1.Node, claims []*resou
requestData: make(map[requestIndices]requestData),
result: make([]internalAllocationResult, len(claims)),
}
alloc.logger.V(5).Info("Starting allocation", "numClaims", len(alloc.claimsToAllocate))
alloc.logger.V(5).Info("Starting allocation", "numClaims", len(alloc.claimsToAllocate), "numSlices", len(alloc.slices))
defer func() {
alloc.logger.V(5).Info("Done with allocation", "success", len(finalResult) == len(alloc.claimsToAllocate), "err", finalErr)
}()