From eb1470d60d54612fdb3955916fe0c707e9895fd9 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 20 Feb 2024 14:01:24 +0100 Subject: [PATCH] scheduler: fix assume cache with no index The assume cache in the volumbinding plugin can be created with no separate index, but List then failed because it tried to use the empty index name instead of using the store's List function. --- .../plugins/volumebinding/assume_cache.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/scheduler/framework/plugins/volumebinding/assume_cache.go b/pkg/scheduler/framework/plugins/volumebinding/assume_cache.go index 77b78d172b1..945c7a3efff 100644 --- a/pkg/scheduler/framework/plugins/volumebinding/assume_cache.go +++ b/pkg/scheduler/framework/plugins/volumebinding/assume_cache.go @@ -283,10 +283,16 @@ func (c *assumeCache) List(indexObj interface{}) []interface{} { defer c.rwMutex.RUnlock() allObjs := []interface{}{} - objs, err := c.store.Index(c.indexName, &objInfo{latestObj: indexObj}) - if err != nil { - c.logger.Error(err, "List index error") - return nil + var objs []interface{} + if c.indexName != "" { + o, err := c.store.Index(c.indexName, &objInfo{latestObj: indexObj}) + if err != nil { + c.logger.Error(err, "List index error") + return nil + } + objs = o + } else { + objs = c.store.List() } for _, obj := range objs {