fix: fail fast when terraform node IP outputs are empty
Some checks failed
Terraform Plan / Terraform Plan (push) Has been cancelled

This commit is contained in:
2026-03-01 18:00:59 +00:00
parent 9edb8f807d
commit 718a9930e8

View File

@@ -18,6 +18,28 @@ def map_to_pairs(items: dict[str, str]) -> str:
return " ".join(f"{k}={v}" for k, v in ordered)
def require_non_empty_ips(label: str, items: dict[str, str]) -> dict[str, str]:
cleaned: dict[str, str] = {}
missing: list[str] = []
for name, ip in items.items():
ip_value = (ip or "").strip()
if not ip_value:
missing.append(name)
continue
cleaned[name] = ip_value
if missing:
names = ", ".join(sorted(missing, key=natural_key))
raise SystemExit(
f"Missing IPv4 addresses for {label}: {names}. "
"Terraform outputs are present but empty. "
"This usually means Proxmox guest IP discovery is unavailable for these VMs yet."
)
return cleaned
def main() -> int:
payload = json.load(sys.stdin)
@@ -25,7 +47,10 @@ def main() -> int:
wk_map = payload.get("worker_vm_ipv4", {}).get("value", {})
if not cp_map or not wk_map:
raise SystemExit("Missing control_plane_vm_ipv4 or worker_vm_ipv4 in terraform output")
raise SystemExit("Missing control_plane_vm_ipv4 or worker_vm_ipv4 in terraform output")
cp_map = require_non_empty_ips("control planes", cp_map)
wk_map = require_non_empty_ips("workers", wk_map)
ssh_user = os.environ.get("KUBEADM_SSH_USER", "").strip() or "micqdf"