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.
This commit is contained in:
Patrick Ohly 2024-02-20 14:01:24 +01:00
parent bf7fcfdc7f
commit eb1470d60d

View File

@ -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 {