Repository navigation
fix(upgrade): drain pods holding AMD GPUs through DRA ResourceClaims - #687
Open
beengineer-moreh wants to merge 1 commit into
Open
beengineer-moreh wants to merge 1 commit into
beengineer-moreh wants to merge 1 commit into
Conversation
getPodsToDrainOrDelete only finds GPU pods by an amd.com/ request or a /dev/dri mount. The DRA driver injects devices through CDI, so a pod that gets its GPU from a ResourceClaim usually has neither and is left on the node during a driver upgrade, where it can keep amdgpu busy. Also select a pod when one of its claims has a device allocated by gpu.amd.com. Claims come from spec.resourceClaims, the generated template claims, and the claim the scheduler creates for a DRA extended resource request. They are read with the highest resource.k8s.io version that serves resourceclaims. A claim that is already deleted is skipped; any other error fails the drain. Grant the manager role get on resource.k8s.io resourceclaims. Signed-off-by: been-son <been.son@moreh.io>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The DRA driver has been supported since v1.5.0 (release notes, guide). When the operator manages the driver and upgrades it under
spec.driver.upgradePolicy, workload pods that get their GPU from a ResourceClaim are not drained. They stay on the node while the old module is unloaded.This covers claims set in
spec.resourceClaims(by name or from a template) and the claim the scheduler creates for the implicit extended resourcedeviceclass.resource.kubernetes.io/gpu.amd.com. The AutoPartition path creates thegpu.amd.comclass withoutextendedResourceName, so that request is not anamd.com/name. Pods that requestamd.com/gputhrough the class mapping are already drained.A pod left behind can keep
amdgpuin use. If the unload never finishes andrebootRequiredis true,handleNodeRebootwaits up to an hour for the new image and then reboots anyway, so the pod is killed by the reboot instead of going through the drain or delete policy.Root cause
getPodsToDrainOrDeletelooks for the GPU in the container spec: anamd.com/request or a/dev/drimount. The DRA driver injects devices through CDI, so a claim-based pod often has neither. Which driver owns the device is only recorded in the claim'sstatus.allocation.devices.results[].driver.What changed
After the existing checks, a pod is also selected when one of its claims has a device allocated by
gpu.amd.com. The class selector isdevice.driver == 'gpu.amd.com', so this reusesdeviceClassName. Claims come fromspec.resourceClaims,status.resourceClaimStatusesandstatus.extendedResourceClaimStatus. A template claim that has not been generated yet is skipped.The check is per pod. If a claim is shared and a container only uses its NIC request, the pod is still selected.
Claims are read with the highest
resource.k8s.ioversion fromdraAPIVersionPrioritywhose discovery list hasresourceclaims. Discovery only runs when a pod has a claim, at most once per call. A claim that is already gone is skipped, since a terminating pod's claim can be deleted first. Any other error is returned, so the node ends inDrain-Failedrather than rebooting with the pod running.The manager role gets
getonresource.k8s.io/resourceclaims.config/rbac/role.yamlis regenerated with controller-gen v0.17.0. The same rule is added by hand to the Helmmanager-rbac.yamland the bundle CSV, becausemake manifestswould also rewrite image tags and versions.Out of scope & compatibility
No change to the device plugin, the DRA driver,
DeviceConfig, CRDs, validators or Helm values, so older images are not affected. Nodes without claim-based pods make no new API calls.Nodes with claim-based pods, including pods of other DRA drivers, now need the new RBAC rule. Helm and OLM ship it. If RBAC is managed some other way, the operator must already have
getonresourceclaimsbefore the image is switched. Otherwise the node goes toDrain-Failed, counts againstmaxUnavailableNodes, and stays there until it is relabeled withoperator.amd.com/gpu-driver-upgrade-state=upgrade-required(recovery).Left for later:
handleNodeRebootstill reboots without an error state when the new image never shows up, and the version probe is not shared withdiscoverDRAAPIVersion, which builds its own in-cluster client and only checks the group version.Testing
go vet ./internal/controllers/,go test -count=1 ./internal/...andgolangci-lint run ./internal/controllers/...(v2.15.0) pass.New specs in
upgrademgr_test.gouse a fake clientset with discovery resource lists. They cover direct, template and extended-resource claims allocated bygpu.amd.com, a claim from another driver, a template claim not generated yet, falling back to v1beta2 when v1 has noresourceclaims, a v1beta1-only cluster, a deleted claim, and Forbidden from both the claim read and discovery. The DRA positive specs fail onmain. The fixtures do not setcontainers[].resources.claims.Not run against a live driver upgrade or an OpenShift cluster serving only v1beta2. On a Kubernetes v1.37 cluster I found a pod of this shape: a
gpu.amd.comclaim, noamd.com/request, no/dev/drimount.#606 drains the operator's own DRA driver pod; this is about workload pods. The
amd.com/check from #663 is kept as is.