kubernetes: Pods that consume "devices" via Device Plugin always fail when Node reboots even if it implements `plugins_registry` interface

What happened?

When node reboots, Pods that consume devices via Device Plugin always fail.

Even if I implement device plugin with ability to use /var/lib/kubelet/plugins_registry directory, it fails too.

Below is my flow of inspection to understand current implementation of kubelet related to the device plugin interface.


I tested below cases:

  • Only kubelet restarts
  • Only containerd restarts
  • Both kubelet and containerd restart

All of 3 cases do not make any error. It only happens when node reboots.


Device Health status is provided using healthDevices.

About Device Plugin Registration


About PluginManager and plugins_registry

pluginmanager runs a set of asynchronous loops that figure out which plugins need to be registered/unregistered based on this node and makes it so.

All of above steps are executed BEFORE entering syncLoop().


So my thought was, If I implement device plugin to deal with plugins_registry, it can be registered to kubelet before other pod run.

However, even if I implemented above things, same problem happens.

  • When node reboots, all containers are in stopped state.
  • kubelet is in charge of re-run stopped containers in that node.
  • Before entering syncLoop(), 2 GRPC interface will be called.
    • However, because device plugin pod is in stopped state, above GRPC call fails.
    • Due to failure of above GRPC call, device plugin registration before entering syncLoop() also fails too.

To solve this problem, I have to run the device plugin using other method (e.g. systemd daemon), that can’t be managed by kubelet.

What did you expect to happen?

To be honest, I know the current problem but don’t know the nice solution.

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

Prepare device plugin (e.g. NVIDIA/k8s-device-plugin) and run any Pod consumes that device (e.g. NVIDIA GPU).

After Pod successfully created and run without any problem, DO node reboot (e.g. just type sudo reboot).

After node reboots, you can see error message like below.

Allocate failed due to no healthy devices present; cannot allocate unhealthy devices nvidia.com/gpu, which is unexpected

Anything else we need to know?

This issue has been discussed in this Slack thread.

Kubernetes version

$ kubectl version
Client Version: v1.30.4
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.5

Cloud provider

Bare Metal

OS version

# On Linux:
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.5 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

$ uname -a
Linux MS03-CEO-008 6.8.0-45-generic #45~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Sep 11 15:25:05 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Install tools

kubeadm version: &version.Info{Major:"1", Minor:"30", GitVersion:"v1.30.5", GitCommit:"74e84a90c725047b1328ff3d589fedb1cb7a120e", GitTreeState:"clean", BuildDate:"2024-09-12T00:17:07Z", GoVersion:"go1.22.6", Compiler:"gc", Platform:"linux/amd64"}

Container runtime (CRI) and version (if applicable)

containerd containerd.io 1.7.22 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I was thinking of various pod admissions issues around Device Plugin. Besides looking deeper how device manager initializes, I think we can do improvement around the pod admission.

The big and scary way to improve pod admission is to run a KEP that will allow to distinguish permanent failures and retries. And have some policies on how to handle those.

Short term however, I believe this change will be acceptable without the need to run a full KEP. The idea is to run a single retry of each Pod admission after x second (5?) if a pod Admission failed (not rejected, but failed). I discussed this with @tallclair and it feels like this small change wouldn’t require a KEP. Also it will be easily expandable to the full-blown support of various policies.

More details:

  1. In syncLoopIteration have a admission retry channel
  2. When Pod failed the admission, put it into that channel after a 5 seconds delay without calling rejectPod nor UpdatePod.
  3. On admission from the retry channel, any failure to admit will result in call to rejectPod
  4. PodAdmitHandler interface will change the Admit func signature to ALSO return an error.
  5. The only handler that will return not nil error will be Device Manager’s one.

This will not solve the problem. But it will give extra 5 seconds for device plugin to start.

@ffromani @mrunalp any feedback on extending the pod admission this way?

/triage accepted cc @ffromani

I need to ask my fellow WG Device Management members, but I suspect that issues that are related to the device plugin are not of interest for the group.