An open-source, faster Devin alternative
TypeScript
vector: drop Wants=cloud-final from populator to break systemd ordering cycle (#254)
Mohamed Habib614413ad8e42
diff --git a/deploy/vector/populate-vector-env.service b/deploy/vector/populate-vector-env.serviceindex 6cab5bf3..a24069a9 100644--- a/deploy/vector/populate-vector-env.service+++ b/deploy/vector/populate-vector-env.service@@ -10,17 +10,27 @@## Ordering note: on Azure workers, cloud-init's final stage writes# /etc/opensandbox/worker.env from a base64 payload baked by the control-# plane (internal/compute/azure.go). Without `After=cloud-final.service`-# the populator races cloud-init, reads an empty environ, exits 0 on-# the "OPENSANDBOX_AZURE_KEY_VAULT_NAME not set" branch, and never-# retries (Restart=on-failure doesn't fire on exit 0). Vector then can't-# start because vector.env was never written. Ordering after cloud-final-# guarantees worker.env exists by the time we read it.+# plane (internal/compute/azure.go). The populator races cloud-init and+# may run before worker.env exists.+#+# #249 tried to solve this with `After=cloud-final.service` + `Wants=`.+# That broke prod: on Azure, both `cloud-final.service` and+# `cloud-init.target` declare `After=multi-user.target` — so ANY ordering+# dependency on a cloud-init unit from a unit WantedBy=multi-user.target+# creates a systemd cycle. systemd resolves it by silently deleting+# vector.service/start, and Vector never boots. Observed on a prod+# worker after #249 merged: load=10, vector inactive, journal contained+# "Job vector.service/start deleted to break ordering cycle".+#+# The fix lives in populate-vector-env.sh: when neither worker.env nor+# server.env exists, the script exits 1, Restart=on-failure here retries+# (10s × 5 = 50s budget) until cloud-init writes the file. No new+# systemd dependencies needed → no cycle.[Unit]Description=Populate /etc/opensandbox/vector.env from Key Vault-After=network-online.target cloud-final.service-Wants=network-online.target cloud-final.service+After=network-online.target+Wants=network-online.targetBefore=vector.serviceDefaultDependencies=no# Retry budget for the Restart= below. StartLimit* belongs in [Unit] perdiff --git a/deploy/vector/populate-vector-env.sh b/deploy/vector/populate-vector-env.shindex 89b2b4a2..4f6dafe2 100755--- a/deploy/vector/populate-vector-env.sh+++ b/deploy/vector/populate-vector-env.sh@@ -49,6 +49,22 @@ CELL_ID_SECRET=shared-cell-idlog() { logger -t populate-vector-env "$*"; echo "$*"; }if [ -z "$VAULT_NAME" ]; then+ # Distinguish "cloud-init hasn't written the env file yet" (transient,+ # retry) from "this host genuinely has no KV configured" (permanent,+ # accept). On prod Azure workers, cloud-init writes worker.env from a+ # base64 payload baked by the control plane (internal/compute/azure.go)+ # in its final stage — we may race ahead of it. Exit 1 so+ # Restart=on-failure (10s × 5 = 50s budget) gives cloud-init time to+ # land the file. After that budget, treat KV as truly absent and exit 0.+ #+ # We can't use After=cloud-final.service in the unit because cloud-init+ # on Azure declares cloud-final After=multi-user.target — any ordering+ # dep on it from a unit WantedBy=multi-user.target creates a systemd+ # cycle and Vector never boots (#249 hit this, see PR-todo to revert).+ if [ ! -f /etc/opensandbox/worker.env ] && [ ! -f /etc/opensandbox/server.env ]; then+ log "no role env file at /etc/opensandbox/{worker,server}.env yet — cloud-init may still be running; exiting 1 to trigger systemd retry"+ exit 1+ filog "OPENSANDBOX_AZURE_KEY_VAULT_NAME not set — skipping (Vector will start without a token)"exit 0fi