From 1ce4589830129e1590780dc24d49e08db8751703 Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Tue, 28 Jul 2026 19:41:13 +1000 Subject: [PATCH] =?UTF-8?q?fix(ha/deploy):=20remove=20=5Fpatch=5Ftargetctl?= =?UTF-8?q?=20=E2=80=94=20iscsi-target.nix=20now=20correct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The _patch_targetctl runtime dropin was a workaround for the wrong targetctl binary path in the original iscsi-target.nix (used pkgs.targetcli-fb, but targetctl is in rtslib-fb's python3 env). The module is now fixed to use \${python3}/bin/targetctl, so new VM images have the correct ExecStart/ExecStop baked in and the patch finds nothing — failing with exit 1 and killing the deploy. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01HaH1cSGvhogRP5ExoF6nD8 --- scripts/ha/deploy.sh | 52 -------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/scripts/ha/deploy.sh b/scripts/ha/deploy.sh index a02f235..2d35064 100755 --- a/scripts/ha/deploy.sh +++ b/scripts/ha/deploy.sh @@ -355,58 +355,6 @@ if ! $SKIP_CLUSTER_INIT; then "sudo mkdir -p /root/.ssh && sudo cp /tmp/cluster-init-key /root/.ssh/cluster-init-key && \ sudo chmod 600 /root/.ssh/cluster-init-key && rm -f /tmp/cluster-init-key" - # Fix targetctl.service on both nodes: the iscsi-target.nix module bakes - # pkgs.targetcli-fb for the targetctl binary, but targetctl is actually in - # rtslib-fb (a different store path). Apply a runtime dropin that corrects - # both ExecStart and ExecStop before Pacemaker ever touches the service. - # The fixed iscsi-target.nix module will make this redundant on next rebuild. - logn "Patching targetctl.service on both nodes..." - _patch_targetctl() { - local ip="$1" - ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no "${HA_USER}@${ip}" sudo bash << 'PATCH' -set -euo pipefail -TC=$(find /nix/store -maxdepth 4 -path '*/python3*env/bin/targetctl' 2>/dev/null | head -1) -PY=$(find /nix/store -maxdepth 4 -path '*/python3*env/bin/python3' -name 'python3' 2>/dev/null | \ - while IFS= read -r p; do "$p" -c "import rtslib_fb" 2>/dev/null && echo "$p" && break; done | head -1) -[[ -n "$TC" && -n "$PY" ]] || { echo "targetctl or python3+rtslib_fb not found"; exit 1; } -# Write stop script that saves LIO config then tears down kernel state -"$PY" - "$TC" "$PY" << 'PYEOF' -import sys, os, stat -tc, py = sys.argv[1], sys.argv[2] -script = f"""#!{py} -import subprocess, sys, rtslib_fb -root = rtslib_fb.RTSRoot() -targets = list(root.targets) -if targets: - r = subprocess.run(["{tc}", "save", "/etc/target/saveconfig.json"], capture_output=True) - print(f"saved {{len(targets)}} target(s); rc={{r.returncode}}") -else: - print("no active LIO targets") -for t in targets: - try: - for tpg in list(t.tpgs): tpg.enable = False - t.delete() - except Exception as e: print(f"warn: {{e}}", file=sys.stderr) -for so in list(root.storage_objects): - try: so.delete() - except Exception as e: print(f"warn: {{e}}", file=sys.stderr) -print("LIO kernel target cleared") -""" -path = "/run/ha-targetctl-stop.py" -with open(path, "w") as f: f.write(script) -os.chmod(path, 0o755) -print(f"wrote {path}") -PYEOF -mkdir -p /run/systemd/system/targetctl.service.d -printf '[Service]\nExecStart=\nExecStart=%s restore /etc/target/saveconfig.json\nExecStop=\nExecStop=/run/ha-targetctl-stop.py\n' \ - "$TC" > /run/systemd/system/targetctl.service.d/fix-exec.conf -systemctl daemon-reload -echo "patched on $(hostname)" -PATCH - } - _patch_targetctl "${NODE1_IP}" - _patch_targetctl "${NODE2_IP}" - logn "Uploading cluster-init.sh to ${NODE1_HOST}..." scp -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no \ "$CLUSTER_INIT" "${HA_USER}@${NODE1_IP}:/tmp/cluster-init.sh"