Skip to content

Commit e983d3f

Browse files
committed
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 <[email protected]>
1 parent 88e9d8f commit e983d3f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/kubelet/kubelet_getters.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ func (kl *Kubelet) ListPodsFromDisk() ([]types.UID, error) {
120120
// user namespaces.
121121
func (kl *Kubelet) HandlerSupportsUserNamespaces(rtHandler string) (bool, error) {
122122
rtHandlers := kl.runtimeState.runtimeHandlers()
123-
if rtHandlers == nil {
124-
return false, fmt.Errorf("runtime handlers are not set")
123+
if len(rtHandlers) == 0 {
124+
// The slice is empty if the runtime is old and doesn't support this message.
125+
return false, nil
125126
}
126127
for _, h := range rtHandlers {
127128
if h.Name == rtHandler {

0 commit comments

Comments
 (0)