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
kubeletrestarts - Only
containerdrestarts - Both
kubeletandcontainerdrestart
All of 3 cases do not make any error. It only happens when node reboots.
Device Health status is provided using healthDevices.
- When
kubeletstarts, it restores from checkpoint, but bothhealthDevicesandunhealthyDevicesset to empty set. healthyDeviceswill be supplied through this code block.- Right now, there is no other code block that supplies
healthyDevices.
- Right now, there is no other code block that supplies
About Device Plugin Registration
- Device Plugin can be registered to
kubeletthrough this code block.- Plugin sends request to
kubelet.
- Plugin sends request to
- After registration, dedicated client will be created and run at another goroutine.
- As I mentioned above,
healthyDevicescan only be injected through this code block.- However, initialization always happens at the beginning of this code block.
- To summarize it, there is no way to supply health devices before device plugin registration.
About PluginManager and plugins_registry
pluginmanagerruns a set of asynchronous loops that figure out which plugins need to be registered/unregistered based on this node and makes it so.
plugins_registryis used atPluginManager. The first usage can be found here.- In
PluginManager, registration of Device Plugin watcher (NOT the DEVICE PLUGIN) happens. - After registration of watcher,
PluginManagerruns.- Inside that code block, we can find
go pm.reconciler.Run(stopCh). We can jump to this section.
- Inside that code block, we can find
- In the
reconcile(), it syncsdesiredStateOfWorldandactualStateOfWorld. - In this code block, all unix sockets exist in the
/var/lib/kubelet/plugins_registryare managed throughAddOrUpdatePlugin()method.
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.
GetInfo(...)andNotifyRegistrationStatus(...)GRPC interface have to be implemented.
However, even if I implemented above things, same problem happens.
- When node reboots, all containers are in stopped state.
kubeletis 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
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
Container runtime (CRI) and version (if applicable)
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
- devicemanager: Allow failing to allocate devices to be retried This is a very coarse hack in the process of resolving https://github.com/kubernetes/kubernetes/issues/128043 I'm not happy with the re... — committed to endocrimes/kubernetes by endocrimes 2 years ago
- devicemanager: Allow failing to allocate devices to be retried This is a very coarse hack in the process of resolving https://github.com/kubernetes/kubernetes/issues/128043 I'm not happy with the re... — committed to endocrimes/kubernetes by endocrimes 2 years ago
- devicemanager: Allow failing to allocate devices to be retried This is a very coarse hack in the process of resolving https://github.com/kubernetes/kubernetes/issues/128043 I'm not happy with the re... — committed to endocrimes/kubernetes by endocrimes 2 years ago
- devicemanager: Allow failing to allocate devices to be retried This is a very coarse hack in the process of resolving https://github.com/kubernetes/kubernetes/issues/128043 I'm not happy with the re... — committed to endocrimes/kubernetes by endocrimes 2 years ago
- devicemanager: Allow failing to allocate devices to be retried This is a very coarse hack in the process of resolving https://github.com/kubernetes/kubernetes/issues/128043 I'm not happy with the re... — committed to endocrimes/kubernetes by endocrimes 2 years ago
- devicemanager: Allow failing to allocate devices to be retried This is a very coarse hack in the process of resolving https://github.com/kubernetes/kubernetes/issues/128043 I'm not happy with the re... — committed to endocrimes/kubernetes by endocrimes 2 years ago
- devicemanager: Allow failing to allocate devices to be retried This is a very coarse hack in the process of resolving https://github.com/kubernetes/kubernetes/issues/128043 I'm not happy with the re... — committed to endocrimes/kubernetes by endocrimes 2 years ago
- devicemanager: Allow failing to allocate devices to be retried This is a very coarse hack in the process of resolving https://github.com/kubernetes/kubernetes/issues/128043 I'm not happy with the re... — committed to bart0sh/kubernetes by endocrimes 2 years ago
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
xsecond (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:
syncLoopIterationhave a admission retry channel5seconds delay without callingrejectPodnorUpdatePod.rejectPodPodAdmitHandlerinterface will change the Admit func signature to ALSO return an error.nilerror 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.