Skip to content

Commit 35ce93b

Browse files
committed
1/ allowed Assume() to add an object that is not present in the cache (assumce_cache.go).
2/ returned the err from Assume() in PreBind phase (dynamicresources.go) 3/ added wait for informer in postFilter verification test (dynamicresources_test.go).
1 parent 032142c commit 35ce93b

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ func (pl *DynamicResources) bindClaim(ctx context.Context, state *stateData, ind
14471447
// This can fail, but only for reasons that are okay (concurrent delete or update).
14481448
// Shouldn't happen in this case.
14491449
if err := pl.draManager.ResourceClaims().AssumeClaimAfterAPICall(claim); err != nil {
1450-
logger.V(5).Info("Claim not stored in assume cache", "err", finalErr)
1450+
logger.V(5).Info("Claim not stored in assume cache", "err", err)
14511451
}
14521452
}
14531453
for _, claimUID := range claimUIDs {

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ func TestPlugin(t *testing.T) {
13171317
},
13181318
postfilter: result{
13191319
status: fwk.NewStatus(fwk.Unschedulable, `deletion of ResourceClaim completed`),
1320-
removed: []metav1.Object{extendedResourceClaimNode2},
1320+
removed: []metav1.Object{extendedResourceClaim},
13211321
},
13221322
},
13231323
},
@@ -1326,6 +1326,7 @@ func TestPlugin(t *testing.T) {
13261326
pod: podWithExtendedResourceName,
13271327
claims: []*resourceapi.ResourceClaim{extendedResourceClaimNode2},
13281328
classes: []*resourceapi.DeviceClass{deviceClassWithExtendResourceName},
1329+
objs: []apiruntime.Object{workerNodeSlice, podWithExtendedResourceName},
13291330
want: want{
13301331
filter: perNodeResult{
13311332
workerNode.Name: {
@@ -1844,6 +1845,10 @@ func TestPlugin(t *testing.T) {
18441845
result, status := testCtx.p.PostFilter(testCtx.ctx, testCtx.state, tc.pod, nil /* filteredNodeStatusMap not used by plugin */)
18451846
t.Run("postfilter", func(t *testing.T) {
18461847
assert.Equal(t, tc.want.postFilterResult, result)
1848+
// in case we delete the claim API object
1849+
// wait for assumed cache to sync with informer
1850+
// then assumed cache should be empty
1851+
time.Sleep(800 * time.Millisecond)
18471852
testCtx.verify(t, tc.want.postfilter, initialObjects, nil, status)
18481853
})
18491854
}

pkg/scheduler/util/assumecache/assume_cache.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,13 @@ func (c *AssumeCache) Assume(obj interface{}) error {
436436

437437
objInfo, err := c.getObjInfo(name)
438438
if err != nil {
439-
return err
439+
if !errors.Is(err, ErrNotFound) {
440+
return err
441+
} else {
442+
c.add(obj)
443+
c.logger.V(4).Info("Added object", "description", c.description, "cacheKey", name)
444+
return nil
445+
}
440446
}
441447

442448
newVersion, err := c.getObjVersion(name, obj)

0 commit comments

Comments
 (0)