diff --git a/scripts/ha/cluster-init.sh b/scripts/ha/cluster-init.sh index 59335a7..9f1271b 100755 --- a/scripts/ha/cluster-init.sh +++ b/scripts/ha/cluster-init.sh @@ -165,7 +165,7 @@ fi log "Mounting ${DRBD_DEVICE} at ${XFS_MOUNT}..." mkdir -p "${XFS_MOUNT}" -mount "${DRBD_DEVICE}" "${XFS_MOUNT}" +mountpoint -q "${XFS_MOUNT}" || mount "${DRBD_DEVICE}" "${XFS_MOUNT}" # ── 4. NFS dataset directories ──────────────────────────────────────────── log "Creating NFS dataset directories..." @@ -181,21 +181,33 @@ fi # ── 6. LIO iSCSI target ─────────────────────────────────────────────────── log "Configuring LIO iSCSI target via targetcli..." +# Note: do NOT bind portal to ${VIP} here — the VIP isn't assigned yet (Pacemaker +# creates it). The default portal (all IPs, port 3260) is correct; Pacemaker's +# VIP resource will make the target reachable at the VIP address. +# +# 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 + log "Clearing existing LIO targets before reconfiguration..." + echo "clearconfig confirm=yes" | targetcli 2>/dev/null || true +fi targetcli </dev/null || warn "LIO clearconfig had errors — umount may fail" + log "Distributing iSCSI saveconfig to $NODE2..." n2_scp /etc/target/saveconfig.json /etc/target/saveconfig.json log "Unmounting ${XFS_MOUNT} — Pacemaker manages it..." -umount "${XFS_MOUNT}" +umount "${XFS_MOUNT}" || { sync; umount -l "${XFS_MOUNT}"; } log "Demoting DRBD to Secondary — Pacemaker manages primary role..." drbdadm secondary ha-data @@ -277,7 +289,7 @@ cibadmin --replace --scope resources --xml-text " " log "Adding ordering and colocation constraints..." -cibadmin --create --scope constraints --xml-text " +cibadmin --replace --scope constraints --xml-text "