KubeGlanceDownload
Multi-Attach error for volume: why the new pod waits for the old one

troubleshooting

Multi-Attach error for volume: why the new pod waits for the old one

Multi-Attach error for volume means a ReadWriteOnce disk is still attached to another node. Why rolling updates deadlock on it, and the fix.

· 9 min read

Multi-Attach error for volume means a pod needs a ReadWriteOnce volume on one node, and the attach/detach controller can see that volume still attached to a different node. It refuses to attach it a second time and waits for the first attachment to go away.

It is not a storage failure. Nothing is broken. Almost always, the pod that holds the volume is still running, and something in your rollout is waiting for the new pod before it will stop the old one.

The fastest check

The message arrives as a FailedAttachVolume event on the new pod:

kubectl get events -n <ns> --field-selector reason=FailedAttachVolume

On Kubernetes 1.36.1 during a stuck rolling update:

LAST SEEN   TYPE      REASON               OBJECT                    MESSAGE
6s          Warning   FailedAttachVolume   pod/db-6b6d6cc987-5ckvj   Multi-Attach error for volume "pvc-55aac890-c932-46c5-b528-3e7345cc55ff" Volume is already used by pod(s) db-68bb65fcf7-5bzjz

The message comes in two forms, and they mean different things:

  • Volume is already used by pod(s) <names> — a pod that still exists, on another node, is using the volume. The names are the answer. This is the rollout deadlock below, or two replicas sharing one RWO claim.
  • Volume is already exclusively attached to one node and can't be attached to another — no pod on the other node wants the volume any more, but it has not been detached yet. Usually transient: the old pod is terminating and the unmount has not finished. If it persists, the old node is the problem.

Then see where the volume actually is, and who is asking for it:

kubectl get volumeattachment -o custom-columns=PV:.spec.source.persistentVolumeName,NODE:.spec.nodeName,ATTACHED:.status.attached
PV                                         NODE                     ATTACHED
pvc-55aac890-c932-46c5-b528-3e7345cc55ff   glance-blog-k19-worker   true
kubectl get pods -n <ns> -o json | jq -r '.items[] | select(any(.spec.volumes[]?; .persistentVolumeClaim.claimName=="<claim>")) | [.metadata.name, .spec.nodeName, .status.phase, (.metadata.deletionTimestamp // "-")] | @tsv'
db-68bb65fcf7-5bzjz	glance-blog-k19-worker	Running	-
db-6b6d6cc987-5ckvj	glance-blog-k19-control-plane	Pending	-

Two pods, one claim, two nodes, and the old one is Running with no deletion timestamp. Nothing is going to move on its own.

Two things about the event that catch people out. It is emitted once per pod: the controller sets a flag after reporting and then skips the pod silently (reconciler.go lines 349–356), so LAST SEEN just keeps ageing and it looks as if nothing is happening. And the pod shows ContainerCreating, not an error status, so kubectl get pods alone will not tell you this is a volume problem. The kubelet on the new node logs unmounted volumes=[data], unattached volumes=[data], failed to process volumes=[]: context deadline exceeded roughly every two minutes, but on 1.36 it does not turn that timeout into an event (kubelet.go lines 2203–2204 only records Unable to attach or mount volumes for errors that are not a wait timeout). If you have seen that string before, it came from a different failure or an older cluster.

On 1.37, 1.36.4+ and 1.35.9+ the message says Waiting for detach

The same event was reworded in #138837 (“Clarify multi-attach events”), released in v1.37.0 and backported to v1.36.4 and v1.35.9. The reason is still FailedAttachVolume, but the prefix changed:

Up to 1.36.3 / 1.35.81.36.4+, 1.35.9+, 1.37
Multi-Attach error for volume "…" Volume is already used by pod(s) …Waiting for detach for volume "…" Volume is already used by pod(s) …
Multi-Attach error for volume "…" Volume is already exclusively attached to one node and can't be attached to anotherWaiting for detach for volume "…" Volume is already exclusively attached to one node, waiting on detach before it can be attached to another node

Source: reconciler.go at v1.36.1, lines 396 and 432 against release-1.36, lines 396 and 433. Everything in this article applies to both wordings. The output above is from 1.36.1; the new wording is source-checked on release-1.36 and release-1.37, not reproduced.

Why it happens

A ReadWriteOnce volume is exclusive per node, not per pod. Before the kubelet on a node can mount a block device such as a cloud disk, the attach/detach controller in kube-controller-manager has to attach it to that node — for CSI drivers, by creating a VolumeAttachment object that the driver’s external attacher acts on. Before it attaches, it asks whether the volume is allowed on several nodes at once. For a PersistentVolume, the answer is yes only if its access modes include ReadWriteMany or ReadOnlyMany (util.go, IsMultiAttachAllowed). If not, and the volume is already attached somewhere else, it reports the error and waits.

That is why you will never see this error with local-path, hostPath or NFS: those volumes are never attached by the controller at all. It belongs to cloud disks (EBS, Persistent Disk, Azure Disk), Longhorn, Ceph RBD, and any CSI driver whose CSIDriver object has attachRequired: true (the default).

The common way to get there is a Deployment with the default strategy:

RollingUpdate creates the new pod before deleting the old one. With an RWO volume on a different node, neither can make progress.

A Deployment defaults to RollingUpdate with maxSurge: 25% and maxUnavailable: 25%. With one replica, the surge rounds up to one pod and the unavailability rounds down to zero, so the controller must bring the new pod to Ready before it is allowed to remove the old one. If the scheduler puts the new pod on another node, the new pod needs the volume detached from the old node, and the old pod will not be removed until the new pod is Ready. That is a deadlock, and kubectl rollout status says so in its own words:

Waiting for deployment "db" rollout to finish: 1 old replicas are pending termination...

If the new pod happens to land on the same node, the rollout succeeds and nobody notices, because RWO allows any number of pods on the node that has the volume. I ran a kubectl rollout restart on the same Deployment with both pods pinned to one node, and it completed with the two pods briefly running side by side. This is why the error seems random: it depends on where the scheduler put the new pod.

Other routes to the same message:

  • A Deployment or ReplicaSet with more than one replica and one RWO claim. The second replica on another node will never start. There is no fix except not sharing the claim — this is what StatefulSet volumeClaimTemplates are for.
  • A node drain or a manually deleted pod. The replacement is created as soon as the old pod starts terminating, and can be scheduled elsewhere while the old one is still in its grace period. Depending on timing you see already used by pod(s) (the old pod still exists) or already exclusively attached (it is gone, the detach is not finished). Transient, unless the old pod gets stuck — see pod stuck in Terminating.
  • A node that died. The old pod is on a node that cannot unmount anything. The controller will not detach a volume the node still reports as mounted. It force detaches after six minutes if the node is unhealthy (ReconcilerMaxWaitForUnmountDuration), unless kube-controller-manager runs with --disable-force-detach-on-timeout, in which case you need the node.kubernetes.io/out-of-service taint (reconciler lines 231–240).

Fixing it

A stuck rollout: let the old pod go first

Change the strategy to Recreate. The Deployment controller then deletes every old pod and waits for it to disappear before creating new ones:

kubectl patch deploy db -p '{"spec":{"strategy":{"type":"Recreate","rollingUpdate":null}}}'

rollingUpdate: null is needed because the API rejects a rollingUpdate block on a Recreate Deployment, and a merge patch would otherwise keep the defaulted one. Applied to a stuck rollout, the old pod is deleted at once and the stuck new pod picks the volume up once the detach completes. Moving that Deployment between nodes under Recreate, kubectl get events --sort-by=.lastTimestamp read (trimmed):

15s         Normal    ScalingReplicaSet        deployment/db                Scaled down replica set db-74cc7ff9cc from 1 to 0
14s         Normal    SuccessfulCreate         replicaset/db-56b957966c     Created pod: db-56b957966c-fwb8p
14s         Normal    Scheduled                pod/db-56b957966c-fwb8p      Successfully assigned k19/db-56b957966c-fwb8p to glance-blog-k19-worker
14s         Warning   FailedAttachVolume       pod/db-56b957966c-fwb8p      Multi-Attach error for volume "pvc-55aac890-c932-46c5-b528-3e7345cc55ff" Volume is already exclusively attached to one node and can't be attached to another
11s         Normal    SuccessfulAttachVolume   pod/db-56b957966c-fwb8p      AttachVolume.Attach succeeded for volume "pvc-55aac890-c932-46c5-b528-3e7345cc55ff"
4s          Normal    Started                  pod/db-56b957966c-fwb8p      Container started

Note the already exclusively attached form in the middle: the old pod was gone, the detach had not finished, and three seconds later the attach succeeded. That one is normal.

If you would rather keep RollingUpdate semantics for other reasons, the equivalent is to forbid the surge:

kubectl patch deploy db -p '{"spec":{"strategy":{"rollingUpdate":{"maxSurge":0,"maxUnavailable":1}}}}'

Applied to the stuck rollout above, the old pod was deleted and the VolumeAttachment moved to the new node:

PV                                         NODE                            ATTACHED
pvc-55aac890-c932-46c5-b528-3e7345cc55ff   glance-blog-k19-control-plane   true

Both options mean downtime while the volume moves. That is not a side effect of the fix; it is the honest cost of a single-writer disk, which cannot be in two places at once.

Make the exclusivity explicit: ReadWriteOncePod

ReadWriteOncePod (GA since 1.29, CSI drivers only) restricts the claim to a single pod, cluster-wide. It does not fix the rollout deadlock — a surge pod still cannot have the volume — but it moves the failure to the scheduler, where it is visible straight away instead of hiding in ContainerCreating. With a RollingUpdate Deployment on an RWOP claim, the surge pod stays Pending:

0s          Warning   FailedScheduling   pod/db-rwop-5b87747dc5-8f8n6   0/2 nodes are available: 1 node(s) didn't match Pod's node affinity/selector, 1 node(s) unavailable due to PersistentVolumeClaim with ReadWriteOncePod access mode already in-use by another pod. no new claims to deallocate, preemption: 0/2 nodes are available: 1 No preemption victims found for incoming pod, 1 Preemption is not helpful for scheduling.

It also blocks the same-node case that RWO silently allows, which is what you want for a database that must never have two writers. Pair it with Recreate; with that change the same Deployment rolled out cleanly. Access modes on an existing claim are immutable, so adopting RWOP means a new PVC.

Several replicas on one RWO claim

Nothing to patch. Either the workload needs one volume per replica — a StatefulSet with volumeClaimTemplates — or it genuinely needs shared storage, which means a ReadWriteMany class (NFS, CephFS, EFS, Azure Files), not an RWO disk.

Not a Multi-Attach error: the driver itself failing

Once the attach goes through, the next failure is a different animal. In the lab for this article the driver ran on one node only, so after the rollout was unblocked the new pod attached and then failed at mount:

2s          Warning   FailedMount              pod/db-6b6d6cc987-5ckvj   MountVolume.MountDevice failed for volume "pvc-55aac890-c932-46c5-b528-3e7345cc55ff" : kubernetes.io/csi: attacher.MountDevice failed to create newCsiDriverClient: driver name hostpath.csi.k8s.io not found in the list of registered CSI drivers

The distinction matters. Multi-Attach error / Waiting for detach is Kubernetes declining to attach, by design, before it asks the storage anything. An AttachVolume.Attach failed or MountVolume.* failed event is the driver or the cloud API saying no — wrong zone, attach limit reached, driver pod missing on the node — and the fix lives in the storage layer, not in your rollout. A pod still waiting at this stage is the same ContainerCreating symptom covered in pod stuck in ContainerCreating.

Preventing it

  • Any Deployment with an RWO claim gets strategy: Recreate. Set it when you write the manifest, not during the first incident. Most Helm charts for single-instance databases expose it as a value.
  • Prefer a StatefulSet for anything that owns its data. It deletes a pod before creating its replacement by default, and gives each replica its own claim.
  • Use ReadWriteOncePod for single-writer data where your driver supports it, so a mistake shows up as an honest Pending rather than a quiet ContainerCreating.
  • Do not force-delete the old pod to get past it. Removing the record does not unmount anything, and on a node that is still alive the container may keep writing. Delete it normally, or fix the strategy, and let the detach happen.

A pod sitting in ContainerCreating with its one FailedAttachVolume event already minutes old is easy to miss. KubeGlance is a native Kubernetes client for iPhone and iPad, with a full Mac app on the same core — pod events, nodes and workload state straight from your kubeconfig.

Get KubeGlance
#volumes #persistentvolumes #csi #deployments #troubleshooting

The Kubernetes dashboard that fits in your pocket

KubeGlance is a native Kubernetes client for iPhone and iPad — the real dashboard, not a companion — with a full Mac app on the same core. Pods, workloads, logs and events, straight from your kubeconfig.

Download KubeGlance