Skip to content

etcd Multi-Attach errors and faulted Longhorn volumes

Summary

After the initial recovery (2026-05-22), a second outage occurred when etcd pods were rescheduled to a different node than where their Longhorn volumes resided. This document covers the issues found and the permanent fixes applied.


Issue 1: Longhorn Volume Multi-Attach Error

Symptom

Multi-Attach error for volume: Volume is already exclusively attached to one node
and can't be attached to another
volume is not ready for workloads

Root Cause - etcd pods were rescheduled to worker-node-a after a restart - Longhorn volumes (replicas) only existed on ubuntu-mashup-gitlab-haproxy - longhorn-db storage class had numberOfReplicas: "1" — data on only one node - RWO volumes cannot be attached to a different node than where the replica lives

Diagnosis

kubectl describe pod apisix-etcd-0 -n ingress-apisix | grep -A5 "Events"
kubectl get volume -n longhorn-system | grep -E "pvc-xxx"

Solution Delete faulted PVCs and recreate with new storage class (see permanent fix below).


Issue 2: Longhorn Volumes Faulted

Symptom

volume robustness: faulted
Engine of volume dead unexpectedly
disk is unschedulable for replica

Root Cause - Longhorn engine crashed while volumes were attached - Old Released PVs from previous recovery attempts were consuming scheduled storage on ubuntu-mashup-gitlab-haproxy, making the disk appear unschedulable (318GB scheduled out of 332GB max)

Diagnosis

kubectl get volume -n longhorn-system | grep -E "pvc-xxx"
kubectl get node.longhorn.io ubuntu-mashup-gitlab-haproxy -n longhorn-system \
  -o custom-columns="NODE:.metadata.name,SCHEDULED:.status.diskStatus.*.storageScheduled,MAX:.status.diskStatus.*.storageMaximum,AVAILABLE:.status.diskStatus.*.storageAvailable"

Solution 1. Find and delete old Released PVs

kubectl get pv | grep Released
kubectl delete pv <pv-name>
2. Remove finalizers from stuck PVCs
for pvc in data-apisix-etcd-0 data-apisix-etcd-1 data-apisix-etcd-2; do
  kubectl patch pvc $pvc -n ingress-apisix \
    --type merge -p '{"metadata":{"finalizers":null}}'
done
3. Delete faulted pods and PVCs
kubectl delete pod apisix-etcd-0 apisix-etcd-1 apisix-etcd-2 -n ingress-apisix --force --grace-period=0
kubectl delete pvc data-apisix-etcd-0 data-apisix-etcd-1 data-apisix-etcd-2 -n ingress-apisix


Issue 3: NFS Mount Failure on worker-node-a

Symptom

MountVolume.SetUp failed for volume "planka-avatar-pv": mount failed: exit status 32
Mounting command: mount

Root Cause - nfs-common package was not installed on worker-node-a - Planka pod was scheduled to that node and couldn't mount NFS volumes

Diagnosis

kubectl describe pod planka-xxx | grep -A5 "Events"
# On worker-node-a:
dpkg -l | grep nfs-common

Solution

# On worker-node-a
apt-get install -y nfs-common

The kubelet automatically retried the mount — no pod restart needed.


Permanent Fix — True HA etcd with Longhorn 3 Replicas

Step 1 — Create new storage class with 3 replicas

cat << 'YAML' | kubectl apply -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: longhorn-etcd
provisioner: driver.longhorn.io
allowVolumeExpansion: true
reclaimPolicy: Retain
volumeBindingMode: Immediate
parameters:
  dataLocality: disabled
  fromBackup: ""
  fsType: ext4
  numberOfReplicas: "3"
  staleReplicaTimeout: "30"
YAML

Step 2 — Upgrade Helm with new settings

kubectl delete statefulset apisix-etcd -n ingress-apisix --cascade=orphan

helm upgrade apisix apisix/apisix \
  -n ingress-apisix \
  --set apisix.ssl.enabled=true \
  --set apisix.replicaCount=3 \
  --set apisix.podAntiAffinityPreset=soft \
  --set "apisix.admin.allow.ipList[0]=127.0.0.1/24" \
  --set "apisix.admin.allow.ipList[1]=<POD_CIDR>" \
  --set etcd.enabled=true \
  --set etcd.image.registry=quay.io \
  --set etcd.image.repository=coreos/etcd \
  --set etcd.image.tag=v3.5.9 \
  --set etcd.replicaCount=3 \
  --set etcd.persistence.enabled=true \
  --set etcd.persistence.size=1Gi \
  --set etcd.persistence.storageClass=longhorn-etcd \
  --set etcd.livenessProbe.enabled=false \
  --set etcd.readinessProbe.enabled=false \
  --set etcd.podAntiAffinityPreset=hard \
  --set gateway.type=LoadBalancer \
  --set ingress-controller.enabled=false \
  --set global.security.allowInsecureImages=true \
  --no-hooks \
  --reuse-values

Step 3 — Delete old PVCs to use new storage class

kubectl delete pod apisix-etcd-0 apisix-etcd-1 apisix-etcd-2 -n ingress-apisix --force --grace-period=0
kubectl delete pvc data-apisix-etcd-0 data-apisix-etcd-1 data-apisix-etcd-2 -n ingress-apisix

# Remove finalizers if stuck
for pvc in data-apisix-etcd-0 data-apisix-etcd-1 data-apisix-etcd-2; do
  kubectl patch pvc $pvc -n ingress-apisix \
    --type merge -p '{"metadata":{"finalizers":null}}' 2>/dev/null || echo "$pvc already gone"
done

Step 4 — Verify

# Check PVCs use new storage class
kubectl get pvc -n ingress-apisix

# Check pods spread across nodes
kubectl get pods -n ingress-apisix -o wide

# Check etcd cluster health
kubectl exec -it apisix-etcd-1 -n ingress-apisix -- etcdctl endpoint health --cluster
kubectl exec -it apisix-etcd-1 -n ingress-apisix -- etcdctl member list

Result After Fix

etcd Pod Distribution

Pod Node
apisix-etcd-0 worker-node-a
apisix-etcd-1 ubuntu-mashup-gitlab-haproxy
apisix-etcd-2 ubuntu-24-04-lts-control-plane

Storage

Item Before After
Storage class longhorn-db (1 replica) longhorn-etcd (3 replicas)
PVC size 4Gi 1Gi (actual usage ~131MB)
Pod anti-affinity none hard (different node required)

Prevention Checklist

Item Action
etcd storage Use longhorn-etcd with 3 replicas
etcd scheduling podAntiAffinityPreset: hard forces pods to different nodes
etcd PVC size 1Gi is sufficient
NFS clients Install nfs-common on ALL nodes during provisioning
Old PV cleanup Regularly check and delete Released PVs
Storage monitoring Monitor Longhorn scheduled vs available storage

NFS Reference

Check NFS server status

systemctl status nfs-kernel-server
showmount -e localhost
cat /etc/exports

Check NFS clients

# On each node
dpkg -l | grep nfs-common

Install NFS client on new nodes

apt-get install -y nfs-common

How NFS works in this cluster

  • NFS Server: ubuntu-mashup-gitlab-haproxy (IP: <MASHUP_NODE_PRIVATE_IP>)
  • Exports: /data/gitlab, /data/planka, /data/planka_postgresql
  • Used by: GitLab, Planka (user avatars, attachments, PostgreSQL data)
  • Why NFS: These apps need ReadWriteMany — multiple pods on different nodes accessing same files simultaneously
  • Why NOT etcd on NFS: etcd requires fast local disk with reliable fsync — NFS adds latency and unreliable fsync which causes data corruption

Longhorn Storage Cleanup

Why storage fills up

Longhorn uses a Retain reclaim policy — when a PVC is deleted, the PV and Longhorn volume remain on disk consuming scheduled space. Over time, especially during incident recovery where PVCs are repeatedly created and deleted, orphaned volumes accumulate and fill up scheduled storage.

3-layer cleanup (correct order)

Step 1: Delete PV (Kubernetes layer)
Step 2: Delete Longhorn Volume (Longhorn layer)
Step 3: Replicas auto-deleted when volume is deleted
# Step 1 — Delete Released PVs
# NOTE: Only do this for PVs with reclaimPolicy=Delete, or PVs you have confirmed
# contain no data you need. Check the RECLAIM POLICY column first:
#   kubectl get pv | grep Released
# If policy is "Retain", the backing Longhorn volume must also be manually deleted (Step 2).
kubectl get pv | grep Released | awk '{print $1}' | xargs kubectl delete pv

# Step 2 — Delete orphaned Longhorn volumes (no PV bound to them)
# Uses kubernetesStatus — the authoritative source of truth for PV binding.
# Also filters to detached only — never deletes a live/attached volume.
kubectl get volumes -n longhorn-system -o json | jq -r '
  .items[] |
  select(
    (
      .status.kubernetesStatus.pvStatus == "" or
      .status.kubernetesStatus.pvStatus == null
    ) and
    .status.state == "detached"
  ) |
  .metadata.name' | while read vol; do
    echo "Deleting orphaned detached volume: $vol"
    kubectl delete volume "$vol" -n longhorn-system
done

# Step 3 — Replicas are auto-cleaned by Longhorn when the volume is deleted (no action needed)

Why kubernetesStatus instead of name-matching? A Longhorn volume name does not always match its PV name. Matching by name can produce false positives (miss real orphans) or false negatives (attempt to delete active volumes). kubernetesStatus.pvStatus is set by Longhorn itself and is the correct field to check. The state == "detached" guard ensures we never touch a volume that is currently in use.

Check storage usage per node

kubectl get node.longhorn.io -n longhorn-system \
  -o custom-columns="NODE:.metadata.name,SCHEDULED:.status.diskStatus.*.storageScheduled,MAX:.status.diskStatus.*.storageMaximum,AVAILABLE:.status.diskStatus.*.storageAvailable"

Find orphaned replicas safely

# Find stopped replicas with no valid PV
kubectl get replicas -n longhorn-system \
  | grep "stopped" \
  | awk '{print $1}' | while read replica; do
  vol=$(kubectl get replica $replica -n longhorn-system -o jsonpath='{.spec.volumeName}' 2>/dev/null)
  pv=$(kubectl get pv $vol 2>/dev/null | grep -v NAME | awk '{print $5}')
  if [ "$pv" = "Released" ] || [ -z "$pv" ]; then
    size=$(kubectl get replica $replica -n longhorn-system -o jsonpath='{.spec.volumeSize}' 2>/dev/null)
    echo "SAFE TO DELETE: $replica (volume: $vol, size: $((size/1024/1024/1024))Gi)"
  fi
done

Note: Longhorn will refuse to delete the last replica of a volume. Delete the Longhorn volume instead — it removes all replicas automatically.

Storage freed in this cleanup

Node Before After Freed
ubuntu-24-04-lts-control-plane 46GB scheduled 26GB ~20GB
ubuntu-mashup-gitlab-haproxy 300GB (97%) 95GB (29%) ~205GB
worker-node-a 51GB 33GB ~18GB

Periodic maintenance

Run monthly to keep storage healthy:

# 1. Check storage levels
kubectl get node.longhorn.io -n longhorn-system \
  -o custom-columns="NODE:.metadata.name,SCHEDULED:.status.diskStatus.*.storageScheduled,MAX:.status.diskStatus.*.storageMaximum,AVAILABLE:.status.diskStatus.*.storageAvailable"

# 2. Check for Released PVs (review RECLAIM POLICY column before deleting)
kubectl get pv | grep Released

# 3. Delete Released PVs
# WARNING: If reclaim policy is "Retain", also delete the backing Longhorn volume (step 5).
kubectl get pv | grep Released | awk '{print $1}' | xargs kubectl delete pv

# 4. Check for orphaned Longhorn volumes
# Uses kubernetesStatus.pvStatus — correct binding check; does NOT rely on name-matching.
kubectl get volumes -n longhorn-system -o json | jq -r '
  .items[] |
  select(
    .status.kubernetesStatus.pvStatus == "" or
    .status.kubernetesStatus.pvStatus == null
  ) |
  .metadata.name'

# 5. Delete orphaned Longhorn volumes (detached only — safe guard against live volumes)
kubectl get volumes -n longhorn-system -o json | jq -r '
  .items[] |
  select(
    (
      .status.kubernetesStatus.pvStatus == "" or
      .status.kubernetesStatus.pvStatus == null
    ) and
    .status.state == "detached"
  ) |
  .metadata.name' | while read vol; do
    echo "Deleting orphaned detached volume: $vol"
    kubectl delete volume "$vol" -n longhorn-system
done

# 6. Verify storage freed
kubectl get node.longhorn.io -n longhorn-system \
  -o custom-columns="NODE:.metadata.name,SCHEDULED:.status.diskStatus.*.storageScheduled,MAX:.status.diskStatus.*.storageMaximum,AVAILABLE:.status.diskStatus.*.storageAvailable"

Updated Prevention Checklist

Item Action Status
etcd storage class Use longhorn-etcd with 3 replicas
etcd HA scheduling Hard pod anti-affinity across nodes
etcd PVC size 1Gi is sufficient (actual usage ~131MB)
APISIX SSL ssl.enabled: true in Helm values
Admin API access Pod CIDR in allow_admin
Ingress controller Traefik scaled to 0, APISIX LoadBalancer
NFS support Install nfs-common on all nodes
Storage cleanup Delete Released PVs + orphaned Longhorn volumes monthly
Node provisioning Include nfs-common in node setup scripts Todo