Archived
fix(ha/cluster-init): use targetcli delete commands for LIO teardown
clearconfig does not reliably clear kernel LIO configfs state — the kernel still holds backing-file references, blocking umount. Replace clearconfig with explicit targetcli delete commands (/iscsi delete, /backstores/fileio delete) which do release kernel state. Also make DRBD secondary demote idempotent (skip if already Secondary). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HaH1cSGvhogRP5ExoF6nD8
This commit is contained in:
@@ -186,9 +186,14 @@ log "Configuring LIO iSCSI target via targetcli..."
|
|||||||
# VIP resource will make the target reachable at the VIP address.
|
# VIP resource will make the target reachable at the VIP address.
|
||||||
#
|
#
|
||||||
# Clear any existing LIO state first (idempotent: re-run after a partial failure).
|
# Clear any existing LIO state first (idempotent: re-run after a partial failure).
|
||||||
if ls /sys/kernel/config/target/iscsi/ 2>/dev/null | grep -q iqn; then
|
# Use specific delete commands — clearconfig does not reliably clear kernel state.
|
||||||
log "Clearing existing LIO targets before reconfiguration..."
|
if ls /sys/kernel/config/target/iscsi/ 2>/dev/null | grep -q "${ISCSI_IQN}"; then
|
||||||
echo "clearconfig confirm=yes" | targetcli 2>/dev/null || true
|
log "Clearing existing LIO target ${ISCSI_IQN} before reconfiguration..."
|
||||||
|
targetcli "/iscsi delete ${ISCSI_IQN}" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
if ls /sys/kernel/config/target/core/ 2>/dev/null | grep -q "fileio"; then
|
||||||
|
log "Clearing existing LIO backstore ha-lun0 before reconfiguration..."
|
||||||
|
targetcli "/backstores/fileio delete ha-lun0" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
targetcli <<EOF
|
targetcli <<EOF
|
||||||
/backstores/fileio create name=ha-lun0 file_or_dev=${ISCSI_LUN_FILE} size=0 write_back=false
|
/backstores/fileio create name=ha-lun0 file_or_dev=${ISCSI_LUN_FILE} size=0 write_back=false
|
||||||
@@ -201,7 +206,9 @@ EOF
|
|||||||
|
|
||||||
log "Tearing down LIO kernel objects — Pacemaker will restore via targetctl on the Active node..."
|
log "Tearing down LIO kernel objects — Pacemaker will restore via targetctl on the Active node..."
|
||||||
# LIO holds the backing file open; clear kernel state now so the XFS unmount succeeds.
|
# LIO holds the backing file open; clear kernel state now so the XFS unmount succeeds.
|
||||||
echo "clearconfig confirm=yes" | targetcli 2>/dev/null || warn "LIO clearconfig had errors — umount may fail"
|
# Use specific delete commands (clearconfig does not reliably clear kernel configfs state).
|
||||||
|
targetcli "/iscsi delete ${ISCSI_IQN}" 2>/dev/null || warn "LIO iscsi delete failed — umount may fail"
|
||||||
|
targetcli "/backstores/fileio delete ha-lun0" 2>/dev/null || warn "LIO backstore delete failed"
|
||||||
|
|
||||||
log "Distributing iSCSI saveconfig to $NODE2..."
|
log "Distributing iSCSI saveconfig to $NODE2..."
|
||||||
n2_scp /etc/target/saveconfig.json /etc/target/saveconfig.json
|
n2_scp /etc/target/saveconfig.json /etc/target/saveconfig.json
|
||||||
@@ -210,7 +217,7 @@ log "Unmounting ${XFS_MOUNT} — Pacemaker manages it..."
|
|||||||
umount "${XFS_MOUNT}" || { sync; umount -l "${XFS_MOUNT}"; }
|
umount "${XFS_MOUNT}" || { sync; umount -l "${XFS_MOUNT}"; }
|
||||||
|
|
||||||
log "Demoting DRBD to Secondary — Pacemaker manages primary role..."
|
log "Demoting DRBD to Secondary — Pacemaker manages primary role..."
|
||||||
drbdadm secondary ha-data
|
[[ "$(drbdadm role ha-data 2>/dev/null)" == "Primary/Secondary" ]] && drbdadm secondary ha-data || true
|
||||||
|
|
||||||
# ── 7. Pacemaker resources ────────────────────────────────────────────────
|
# ── 7. Pacemaker resources ────────────────────────────────────────────────
|
||||||
log "Configuring Pacemaker cluster properties..."
|
log "Configuring Pacemaker cluster properties..."
|
||||||
|
|||||||
Reference in New Issue
Block a user