Don't refuse recreating the canonical already-deployed target itself
Check NixOS configurations / eval-hosts (pull_request) Failing after 11m13s

The duplicate-host check in create-proxmox-resource.sh compared by
hostName only, so it fired even when the target being created was
exactly the one variables.nix's deployedTargets already names (e.g.
rebuilding lxc-nix-cache after destroying its old container to pick up
new sops secrets) -- there's no other machine at risk of an identity
collision in that case, just the normal redeploy workflow. Skip the
check when dt == flake_target; the later VMID-existence check still
guards against clobbering a resource that's actually live on the node.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
root
2026-07-20 09:49:31 +00:00
co-authored by Claude Sonnet 5
parent fe8693b0e5
commit 6522a35115
+7 -1
View File
@@ -289,11 +289,17 @@ fi
# --- refuse to duplicate a host that's already really deployed ----------
# Checked by hostName, not exact flake target: proxmox-server being
# deployed also blocks --type lxc --host server, since both would carry
# the same hosts/server/host.nix identity (hostName, hostId).
# the same hosts/server/host.nix identity (hostName, hostId). But skip the
# check when dt == flake_target -- that's not a duplicate, it's recreating
# the canonical deployed target itself (e.g. redeploying nix-cache after
# destroying its old VM/container to pick up new sops secrets), and the
# later VMID-existence check already guards against clobbering a live
# resource.
if [[ "$allow_duplicate_host" -eq 0 ]]; then
deployed_targets_json="$(nix eval --json --no-use-registries --no-accept-flake-config \
--file "${repo_root}/variables.nix" deployedTargets)"
for dt in $(echo "$deployed_targets_json" | jq -r '.[]'); do
[[ "$dt" == "$flake_target" ]] && continue
dt_hostname="$(nix eval --raw --no-use-registries --no-accept-flake-config \
"${repo_root}#nixosConfigurations.${dt}.config.networking.hostName" 2>/dev/null || true)"
if [[ "$dt_hostname" == "$host" ]]; then