mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
userns: Use len to handle empty non-nil slices
When using an old runtime like containerd 1.7, this message is not implemented and what we get here is an empty non-nil slice. Let's check the len of the slice instead. While we are there, let's just return false and no error. In the following commits we will wrap the error and we didn't find any more info to add here. Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
This commit is contained in:
parent
3f75cae603
commit
fd5862185f
@ -120,8 +120,9 @@ func (kl *Kubelet) ListPodsFromDisk() ([]types.UID, error) {
|
||||
// user namespaces.
|
||||
func (kl *Kubelet) HandlerSupportsUserNamespaces(rtHandler string) (bool, error) {
|
||||
rtHandlers := kl.runtimeState.runtimeHandlers()
|
||||
if rtHandlers == nil {
|
||||
return false, fmt.Errorf("runtime handlers are not set")
|
||||
if len(rtHandlers) == 0 {
|
||||
// The slice is empty if the runtime is old and doesn't support this message.
|
||||
return false, nil
|
||||
}
|
||||
for _, h := range rtHandlers {
|
||||
if h.Name == rtHandler {
|
||||
|
Loading…
Reference in New Issue
Block a user