mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Add handling empty index key that may cause panic issue
This commit is contained in:
parent
03fe6b962c
commit
a9d631665e
3
pkg/client/cache/index.go
vendored
3
pkg/client/cache/index.go
vendored
@ -55,6 +55,9 @@ func IndexFuncToKeyFuncAdapter(indexFunc IndexFunc) KeyFunc {
|
|||||||
if len(indexKeys) > 1 {
|
if len(indexKeys) > 1 {
|
||||||
return "", fmt.Errorf("too many keys: %v", indexKeys)
|
return "", fmt.Errorf("too many keys: %v", indexKeys)
|
||||||
}
|
}
|
||||||
|
if len(indexKeys) == 0 {
|
||||||
|
return "", fmt.Errorf("unexpected empty indexKeys")
|
||||||
|
}
|
||||||
return indexKeys[0], nil
|
return indexKeys[0], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user