kubernetes: Kubelet restart cause running pod restart with UnexpectedAdmissionError when pods have initContainers and external devices like GPU

What happened?

When restarting kubelet, it will restart the running pods with UnexpectedAdmissionError when pods’ initContainers and containers both use external devices like GPU

What did you expect to happen?

Restart kubelet should not cause running pods to restart

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

  1. create some pods with nvidia.com/gpu and initContainers which also use GPUs
  2. wait until initContainers exit
  3. restart kubelet

Anything else we need to know?

there was an issue and a fix for running pods with devices, but it looks like the initContainers is not counted as should skip containers.

the fix has cherry-picked to v1.25.16

Related Issues:

Kubernetes version

$ kubectl version
# 1.25.16

Cloud provider

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 26 (19 by maintainers)

Most upvoted comments

Also, can you please confirm if the fix #126343 addresses this issue?

This is the change I was hinting at (and which I didn’t have handy, yet). There could be further work to be done in this area though, which we need to check. This is what I meant in https://github.com/kubernetes/kubernetes/issues/124345#issuecomment-2685931651

@zwpaper can you try this on a newer k8s version?

Of cause, but maybe need some another time, once done, i will update it here. But we have checked the kubelet logic and added some logs to make sure the position, and double checked the master branch is still not changed, so that it should be easy to reproduce.

Why is the pod failing with an admission error if the device is still available?

The is a bug related in nv device plugins that may crash when kubelet restarts, but i have not yet deep dived into it. But even without that bug, a kubelet restart will ask all the device plugins to restart and register their socks by design, so that there will be a chance there will be no healthy devices when kubelet starts. The main problem is that kubelet should not allocate devices for the completed containers like completed jobs and init containers