Multi-Attach Error

During a rollout the new Pod lands on another Node and hangs in ContainerCreating, while the old one still runs with the disk the new one needs. Who is waiting on whom, and what breaks the loop from outside?

Play the animation 7 steps, animated, plays on a computer or a tablet

Multi-Attach Error diagram: A Multi-Attach error, which Kubernetes 1

Multi-Attach Error, step by step

  1. A rollout begins. At one replica, RollingUpdate with its default settings creates the replacement Pod before it removes the old one, exactly as designed, and the Scheduler places it on Node-2. Node-1 stays healthy throughout. A second Pod now exists on the other Node, and it wants the same volume.

    Play from step 1
  2. The attach and detach controller now has to attach the volume to Node-2, which for this CSI disk means writing a second VolumeAttachment. The request stops there. PV web is ReadWriteOnce and still attached to Node-1, so the controller refuses before writing anything, and csi-2c9d stays wanted, not written.

    Play from step 2
  3. So the new Pod hangs in ContainerCreating. The controller records a FailedAttachVolume warning on the Pod, Waiting for detach for volume web, naming Pod web-7f9c8-tp8vd as the one using the volume. Up to 1.36.3 it read Multi-Attach error. Kubelet cannot mount a disk not attached to its Node, so the container cannot start.

    Play from step 3
  4. Only the old attachment going away unblocks the new Pod. The controller will not delete csi-7f3a while the old Pod runs, and at one replica the default maxUnavailable rounds down to zero, so the rollout keeps that Pod until the new one is ready. Each side waits on the other, and progressDeadlineSeconds only reports the rollout as stalled.

    Play from step 4
  5. Nothing inside the rollout breaks the deadlock, and deleting the old Pod alone does not either: its ReplicaSet recreates it at once. So someone outside the rollout switches the strategy to Recreate, which scales the old ReplicaSet to zero. Kubelet on Node-1 unmounts, the controller deletes csi-7f3a, the disk detaches, and for a moment the volume belongs to nobody.

    Play from step 5
  6. With the volume free the controller writes csi-2c9d, the driver attaches the disk to Node-2, Kubelet mounts it, and the new Pod starts. These storage operations did not cause the stall. The time went into waiting for the old Pod to leave.

    Play from step 6
  7. So with default settings a Deployment on ReadWriteOnce storage stalls whenever the replacement lands on another Node, because RollingUpdate creates the new Pod before deleting the old one. The way out is the Recreate strategy, which deletes the old Pod first, the way a StatefulSet replaces an ordinal. The new Pod may still wait briefly for the detach.

    Play from step 7

Sources