kubernetes: kubelet panic due to invalid memory address or nil pointer dereference

What happened?

Jan 31 11:20:29 localhost kubelet[223329]: I0131 11:20:29.769456  223329 reconciler_common.go:258] "operationExecutor.VerifyControllerAttachedVolume started for volume \"sys\" (UniqueName: \"kubernetes.io/host-path/d1703176-903a-41cd-9fdb-cef54fd0cfad-sys\") pod \"device-plugin-jrxll\" (UID: \"d1703176-903a-41cd-9fdb-cef54fd0cfad\") " pod="kube-system/device-plugin-jrxll"
Jan 31 11:20:29 localhost kubelet[223329]: I0131 11:20:29.769504  223329 reconciler_common.go:258] "operationExecutor.VerifyControllerAttachedVolume started for volume \"data1\" (UniqueName: \"kubernetes.io/host-path/d1703176-903a-41cd-9fdb-cef54fd0cfad-data1\") pod \"device-plugin-jrxll\" (UID: \"d1703176-903a-41cd-9fdb-cef54fd0cfad\") " pod="kube-system/device-plugin-jrxll"
Feb 02 11:09:24 localhost kubelet[223329]: E0202 11:09:24.900919  223329 runtime.go:79] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
Feb 02 11:09:24 localhost kubelet[223329]: goroutine 155 [running]:
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/runtime.logPanic({0x3cf85c0?, 0x6d78160})
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:75 +0x99
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0xffffffffffffffff?})
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:49 +0x75
Feb 02 11:09:24 localhost kubelet[223329]: panic({0x3cf85c0, 0x6d78160})
Feb 02 11:09:24 localhost kubelet[223329]:         /usr/local/go/src/runtime/panic.go:884 +0x213
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/kubernetes/pkg/kubelet/volumemanager/cache.(*actualStateOfWorld).GetMountedVolumes(0xc000c404c0)
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/cache/actual_state_of_world.go:1001 +0x2b3
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).findAndAddNewPods(0xc000ae01c0)
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:187 +0xa2
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).populatorLoop(0xc002561e48?)
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:178 +0x1e
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc002561ea8?)
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:226 +0x3e
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0x46c86b9?, {0x4c0f640, 0xc000dae390}, 0x1, 0xc000142300)
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:227 +0xb6
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc000ae024c?, 0x5f5e100, 0x0, 0x0?, 0x0?)
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:204 +0x89
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/wait.Until(...)
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:161
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).Run(0xc000ae01c0, {0x4c1e548?, 0xc0007132c0}, 0x0?)
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:163 +0x1bf
Feb 02 11:09:24 localhost kubelet[223329]: created by k8s.io/kubernetes/pkg/kubelet/volumemanager.(*volumeManager).Run
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/volume_manager.go:288 +0x18e
Feb 02 11:09:24 localhost kubelet[223329]: panic: runtime error: invalid memory address or nil pointer dereference [recovered]
Feb 02 11:09:24 localhost kubelet[223329]:         panic: runtime error: invalid memory address or nil pointer dereference
Feb 02 11:09:24 localhost kubelet[223329]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x35d4673]
Feb 02 11:09:24 localhost kubelet[223329]: goroutine 155 [running]:
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0xffffffffffffffff?})
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:56 +0xd7
Feb 02 11:09:24 localhost kubelet[223329]: panic({0x3cf85c0, 0x6d78160})
Feb 02 11:09:24 localhost kubelet[223329]:         /usr/local/go/src/runtime/panic.go:884 +0x213
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/kubernetes/pkg/kubelet/volumemanager/cache.(*actualStateOfWorld).GetMountedVolumes(0xc000c404c0)
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/cache/actual_state_of_world.go:1001 +0x2b3
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).findAndAddNewPods(0xc000ae01c0)
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:187 +0xa2
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).populatorLoop(0xc002561e48?)
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:178 +0x1e
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc002561ea8?)
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:226 +0x3e
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0x46c86b9?, {0x4c0f640, 0xc000dae390}, 0x1, 0xc000142300)
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:227 +0xb6
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc000ae024c?, 0x5f5e100, 0x0, 0x0?, 0x0?)
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:204 +0x89
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/apimachinery/pkg/util/wait.Until(...)
Feb 02 11:09:24 localhost kubelet[223329]:         vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:161
Feb 02 11:09:24 localhost kubelet[223329]: k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).Run(0xc000ae01c0, {0x4c1e548?, 0xc0007132c0}, 0x0?)
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:163 +0x1bf
Feb 02 11:09:24 localhost kubelet[223329]: created by k8s.io/kubernetes/pkg/kubelet/volumemanager.(*volumeManager).Run
Feb 02 11:09:24 localhost kubelet[223329]:         pkg/kubelet/volumemanager/volume_manager.go:288 +0x18e
Feb 02 11:09:24 localhost systemd[1]: kubelet.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Feb 02 11:09:24 localhost systemd[1]: kubelet.service: Failed with result 'exit-code'.
Feb 02 11:10:47 localhost systemd[1]: Started Kubernetes Kubelet.

What did you expect to happen?

kubelet should not panic

How can we reproduce it (as minimally and precisely as possible)?

we found the panic occasionally happen in our prod env

Anything else we need to know?

No response

Kubernetes version

$ kubelet --version
Kubernetes v1.28.3

Cloud provider

OS version

# On Linux:
$ cat /etc/os-release
NAME="AlmaLinux"
VERSION="9.1 (Lime Lynx)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.1"
PLATFORM_ID="platform:el9"
PRETTY_NAME="AlmaLinux 9.1 (Lime Lynx)"
ANSI_COLOR="0;34"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:almalinux:almalinux:9::baseos"
HOME_URL="https://almalinux.org/"
DOCUMENTATION_URL="https://wiki.almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"

ALMALINUX_MANTISBT_PROJECT="AlmaLinux-9"
ALMALINUX_MANTISBT_PROJECT_VERSION="9.1"
REDHAT_SUPPORT_PRODUCT="AlmaLinux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.1"
$ uname -a
Linux localhost 5.14.0-162.6.1.el9_1.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Mar 6 08:54:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
</details>


### Install tools

<details>

</details>


### Container runtime (CRI) and version (if applicable)

<details>

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

it seems to be a problem with almalinux 9.1,we run kubelet on multiple os, such as centos 7.7, Oracle Linux 8.2 & 8.4, AlmaLinux 9.1, we checked the logs only Almalinux have the issue, we tried to upgrade glibc on some hosts, we will continue to see if the issue still exist, also we found a golang issue https://github.com/golang/go/issues/64781,we will try to add the godebug env later to find out if it works