etcd quorum loss from multipathd grabbing Longhorn volumes
Date: 2026-05-27
Duration: ~8 hours
Severity: High — All APISIX-proxied services returning 502
Environment: K3s single-node cluster, APISIX v3.6, Longhorn storage, Ubuntu 22.04
Summary¶
The APISIX etcd cluster lost quorum after the Longhorn CSI plugin restarted on the node. When the CSI plugin restarted, it briefly released all iSCSI block devices. The multipathd daemon, which monitors for new block devices, grabbed the released Longhorn iSCSI volumes before the CSI plugin could remount them. This caused mke2fs format failures on every remount attempt, leaving etcd-0 crashed, etcd-1 permanently stuck in ContainerCreating, and etcd-2 running but unable to achieve Raft quorum. With no quorum, APISIX could not sync configuration and all proxied services returned 502.
Timeline¶
| Time | Event |
|---|---|
| ~5 days before incident | etcd cluster deployed fresh, all 3 members healthy |
| T-8h (trigger) | Longhorn CSI plugin pod longhorn-csi-plugin-pv88n restarted on the node |
| T-8h | CSI plugin released all iSCSI volumes momentarily during restart |
| T-8h | multipathd grabbed iSCSI volumes sdb, sdf, sdk via mpatha/mpathb/mpathc |
| T-8h | Longhorn CSI tried to remount volumes — failed with mke2fs: device in use |
| T-8h | etcd-0 crashed (Exit Code 1), etcd-1 stuck in ContainerCreating |
| T-8h | etcd-2 running but isolated — no quorum, cluster frozen |
| T-8h | APISIX loaded last known config into memory, stopped syncing |
| T-0 (discovery) | All services returning 502, etcd pods in Error/ContainerCreating state |
Root Cause¶
Primary Cause: multipathd conflicting with Longhorn iSCSI devices¶
Longhorn uses iSCSI to present virtual block devices to the node. The multipathd daemon is designed to manage multipath I/O for iSCSI/FC storage and automatically claims any iSCSI device it detects.
Longhorn creates iSCSI device → /dev/sdb (IET VIRTUAL-DISK)
│
▼
multipathd sees /dev/sdb → "iSCSI disk, I'll manage this"
multipathd grabs /dev/sdb → creates /dev/mapper/mpathb
│
▼
Longhorn CSI tries mkfs.ext4 /dev/sdb
kernel: "device already in use by multipathd"
mke2fs: exit status 1
Why It Worked Before¶
When etcd was first deployed 5 days prior, Longhorn formatted and mounted the volumes before multipathd could claim them. The volumes stayed mounted continuously, so multipathd saw them as "already in use" and skipped them.
When the CSI plugin restarted, it released all volume mounts momentarily — giving multipathd the window it needed to claim the devices.
Contributing Factor: Single-path iSCSI with no benefit¶
Each Longhorn iSCSI device had only one path, so multipathd provided zero HA benefit while causing the conflict:
sdb → mpathb (1 path only, no redundancy gained)
sdf → mpatha (1 path only, no redundancy gained)
sdk → mpathc (1 path only, no redundancy gained)
Longhorn already handles redundancy through its own replica system across nodes, making multipathd completely unnecessary and harmful in this setup.
Impact¶
- etcd-0: Crashed with Exit Code 1, unable to restart
- etcd-1: Stuck in
ContainerCreatingfor 7+ hours, never started - etcd-2: Running but frozen — no Raft quorum, all reads/writes timed out
- APISIX: Operating on stale in-memory config, no new config changes possible
- All services: Returning 502 Bad Gateway after APISIX pod restarted and lost in-memory state
- Data loss: None — etcd-2 retained all data throughout the incident
Diagnosis Steps¶
1. Check pod status¶
2. Check etcd-2 logs — confirmed DNS resolution failure for peers¶
kubectl logs -n ingress-apisix apisix-etcd-2 --tail=50
# Key error: "dial tcp: lookup apisix-etcd-0...no such host"
# Cause: etcd-0 pod was dead, no headless DNS entry existed
3. Confirm etcd cluster has no quorum¶
kubectl exec -n ingress-apisix apisix-etcd-2 -- etcdctl \
--endpoints=http://localhost:2379 member list
# Error: context deadline exceeded
4. Check mount events for etcd-1¶
kubectl get events -n ingress-apisix --sort-by='.lastTimestamp' | tail -20
# Key error: "MountVolume.MountDevice failed: format of disk failed:
# mke2fs: device is apparently in use by the system"
5. Check Longhorn volume health¶
kubectl get volumes.longhorn.io -n longhorn-system | grep bfb07b36
# Result: attached, healthy — Longhorn volume was fine
6. Identify stale mounts¶
ls -la /var/lib/kubelet/plugins/kubernetes.io/csi/driver.longhorn.io/
# Found directories with Input/output error = stale ghost mounts
7. Identify multipathd conflict¶
lsblk -o NAME,SIZE,TYPE,TRAN,VENDOR,MODEL
# Found: sdb → mpathb, sdf → mpatha, sdk → mpathc
# All Longhorn iSCSI devices grabbed by multipathd
multipath -ll
# Confirmed: mpatha/mpathb/mpathc all IET VIRTUAL-DISK devices
Fix Applied¶
Step 1 — Blacklist Longhorn devices from multipathd (permanent fix)¶
cat >> /etc/multipath.conf << 'EOF'
blacklist {
device {
vendor "IET"
product "VIRTUAL-DISK"
}
}
EOF
Step 2 — Release devices currently held by multipathd¶
Step 3 — Restart multipathd to apply blacklist¶
Step 4 — Verify multipath no longer holds Longhorn devices¶
Step 5 — Delete bad PVC for etcd-1 (had stale filesystem state)¶
kubectl delete pod -n ingress-apisix apisix-etcd-1 --force --grace-period=0
kubectl patch pvc data-apisix-etcd-1 -n ingress-apisix -p '{"metadata":{"finalizers":null}}'
kubectl delete pvc data-apisix-etcd-1 -n ingress-apisix
# Also delete the old Longhorn volume
kubectl delete volumes.longhorn.io pvc-bfb07b36-e0a7-450f-a71b-1ccc4fe74f82 -n longhorn-system
# Manually create fresh PVC
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-apisix-etcd-1
namespace: ingress-apisix
labels:
app.kubernetes.io/instance: apisix
app.kubernetes.io/name: etcd
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 4Gi
storageClassName: longhorn-db
EOF
Step 6 — Restart etcd-0¶
Step 7 — Verify etcd cluster health¶
kubectl exec -n ingress-apisix apisix-etcd-2 -- etcdctl \
--endpoints=http://apisix-etcd-0.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2379,http://apisix-etcd-1.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2379,http://apisix-etcd-2.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2379 \
endpoint health
Step 8 — Restore APISIX config sync¶
# Restart APISIX to reload config from etcd
kubectl rollout restart deployment apisix -n ingress-apisix
# Restart ingress controller to resync all Kubernetes resources
kubectl rollout restart deployment apisix-ingress-controller -n ingress-apisix
# Force resync all resources if routes/upstreams still missing
kubectl annotate apisixroute -A --all force-sync="$(date +%s)" --overwrite
kubectl annotate apisixupstream -A --all force-sync="$(date +%s)" --overwrite
kubectl annotate apisixtls -A --all force-sync="$(date +%s)" --overwrite
Recovery Steps¶
Complete ordered recovery procedure for future reference:
# 1. Add multipath blacklist
cat >> /etc/multipath.conf << 'EOF'
blacklist {
device {
vendor "IET"
product "VIRTUAL-DISK"
}
}
EOF
# 2. Flush and restart multipathd
multipath -f mpatha; multipath -f mpathb; multipath -f mpathc
systemctl restart multipathd
# 3. Restart failed etcd pods
kubectl delete pod -n ingress-apisix apisix-etcd-0 --force --grace-period=0
kubectl delete pod -n ingress-apisix apisix-etcd-1 --force --grace-period=0
# 4. Watch etcd recover
kubectl get pods -n ingress-apisix -w
# 5. Verify quorum
kubectl exec -n ingress-apisix apisix-etcd-2 -- etcdctl \
--endpoints=http://apisix-etcd-0.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2379,http://apisix-etcd-1.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2379,http://apisix-etcd-2.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2379 \
endpoint health
# 6. Restart APISIX
kubectl rollout restart deployment apisix -n ingress-apisix
kubectl rollout restart deployment apisix-ingress-controller -n ingress-apisix
# 7. Force resync if needed
kubectl annotate apisixroute -A --all force-sync="$(date +%s)" --overwrite
kubectl annotate apisixupstream -A --all force-sync="$(date +%s)" --overwrite
kubectl annotate apisixtls -A --all force-sync="$(date +%s)" --overwrite
Prevention¶
1. Multipath blacklist (already applied)¶
The /etc/multipath.conf blacklist ensures multipathd will never claim Longhorn iSCSI devices again, even after future CSI plugin restarts.
2. Verify blacklist persists after reboot¶
3. Retain policy on etcd PVs (already configured)¶
All etcd PVs use Retain reclaim policy — data is never deleted even if PVCs are accidentally removed.
# Verify
kubectl get pv | grep etcd
kubectl get storageclass longhorn-db -o jsonpath='{.reclaimPolicy}'
4. Monitor etcd health proactively¶
Set up alerts for:
- Any etcd pod not in Running state
- etcd endpoint health check failures
- Loss of quorum (less than 2/3 members healthy)
5. Ingress controller resync interval¶
Consider adding periodic resync to ingress controller to auto-recover from APISIX config loss:
Lessons Learned¶
| # | Lesson |
|---|---|
| 1 | multipathd conflicts with Longhorn on any node where both run. Always blacklist IET VIRTUAL-DISK in /etc/multipath.conf when using Longhorn |
| 2 | etcd quorum is fragile — losing 2 of 3 members freezes the entire cluster including reads |
| 3 | APISIX ingress controller does not auto-recover config pushed to APISIX — it only reacts to Kubernetes resource change events, not APISIX state |
| 4 | All routes should be Kubernetes resources (ApisixRoute, ApisixTLS) — manually configured routes via Admin API are lost on APISIX restart if etcd is wiped |
| 5 | kubectl annotate --all force-sync is the fastest way to force ingress controller to repush all config to APISIX |
| 6 | Longhorn volume healthy in Longhorn UI does not mean it can be mounted — the kubelet/CSI layer can still fail independently |
Health Check Command¶
Run this to verify full system health at any time:
echo "=== PODS ===" && kubectl get pods -n ingress-apisix
echo "=== ETCD HEALTH ===" && kubectl exec -n ingress-apisix apisix-etcd-2 -- etcdctl \
--endpoints=http://apisix-etcd-0.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2379,http://apisix-etcd-1.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2379,http://apisix-etcd-2.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2379 \
endpoint health
echo "=== ROUTES ===" && curl -s http://<APISIX_ADMIN_SERVICE_IP>:9180/apisix/admin/routes \
-H 'X-API-KEY: <APISIX_ADMIN_KEY>' | python3 -m json.tool | grep total
echo "=== UPSTREAMS ===" && curl -s http://<APISIX_ADMIN_SERVICE_IP>:9180/apisix/admin/upstreams \
-H 'X-API-KEY: <APISIX_ADMIN_KEY>' | python3 -m json.tool | grep total
echo "=== SSL ===" && curl -s http://<APISIX_ADMIN_SERVICE_IP>:9180/apisix/admin/ssls \
-H 'X-API-KEY: <APISIX_ADMIN_KEY>' | python3 -m json.tool | grep total
echo "=== MULTIPATH ===" && multipath -ll
echo "=== SERVICES ===" && \
curl -sk https://mashup.castis.io -o /dev/null -w "mashup.castis.io: %{http_code}\n" && \
curl -sk https://argo.castis.io -o /dev/null -w "argo.castis.io: %{http_code}\n" && \
curl -sk https://monitor.castis.io -o /dev/null -w "monitor.castis.io: %{http_code}\n" && \
curl -sk https://nexus.castis.io -o /dev/null -w "nexus.castis.io: %{http_code}\n" && \
curl -sk https://iam.castis.io -o /dev/null -w "iam.castis.io: %{http_code}\n"
Expected Healthy Output¶
PODS: all 1/1 Running
ETCD: all 3 healthy
ROUTES: "total": 18
UPSTREAMS: "total": 16
SSL: "total": 17
MULTIPATH: empty (no Longhorn devices grabbed)
SERVICES: all 200 or 302
Incident resolved by: Manual diagnosis and fix
Total recovery time: ~3 hours of active troubleshooting
Data loss: None