From defca448b01b6445050f43c8217059993560b565 Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Thu, 26 Mar 2026 11:27:46 -0700 Subject: [PATCH] fix(e2e): load GCP_ZONE from ~/.config/spawn/gcp.json in E2E driver (#3017) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GCP E2E cloud driver defaulted to us-central1-a when GCP_ZONE was not set in the environment. The QA VM stores zone config in ~/.config/spawn/gcp.json (alongside GCP_PROJECT) but _gcp_validate_env only read GCP_PROJECT from the environment — it never loaded GCP_ZONE. This caused E2E failures when us-central1-a had insufficient resources: 3 agents (openclaw, opencode, kilocode) failed with "SSH port never opened" because GCP couldn't provision instances in that zone. Fix: load both GCP_PROJECT and GCP_ZONE from the config file in _gcp_validate_env when they are not already set in the environment, matching how key-request.sh loads GCP_PROJECT for provisioning. Verified: all 3 previously failing agents now pass on europe-west1-b. Co-authored-by: spawn-qa-bot Co-authored-by: Claude Sonnet 4.6 --- sh/e2e/lib/clouds/gcp.sh | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/sh/e2e/lib/clouds/gcp.sh b/sh/e2e/lib/clouds/gcp.sh index fe4686fb..b1d7dbbc 100644 --- a/sh/e2e/lib/clouds/gcp.sh +++ b/sh/e2e/lib/clouds/gcp.sh @@ -18,12 +18,49 @@ _GCP_INSTANCE_APP="" # _gcp_validate_env # # Check that the gcloud CLI is installed and credentials are valid. -# Requires GCP_PROJECT to be set. +# Requires GCP_PROJECT to be set. Loads GCP_PROJECT and GCP_ZONE from +# ~/.config/spawn/gcp.json if not already in the environment. # Returns 0 on success, 1 on failure. # --------------------------------------------------------------------------- _gcp_validate_env() { local missing=0 + # Load GCP_PROJECT and GCP_ZONE from ~/.config/spawn/gcp.json if not set. + # This allows the QA VM to configure the correct zone without env var exports. + local _gcp_config="${HOME}/.config/spawn/gcp.json" + if [ -f "${_gcp_config}" ]; then + if [ -z "${GCP_PROJECT:-}" ]; then + local _proj + if command -v jq >/dev/null 2>&1; then + _proj=$(jq -r '.GCP_PROJECT // "" | select(. != null)' "${_gcp_config}" 2>/dev/null) + else + _proj=$(_FILE="${_gcp_config}" bun -e " +import fs from 'fs'; +const d = JSON.parse(fs.readFileSync(process.env._FILE, 'utf8')); +process.stdout.write(d.GCP_PROJECT || ''); +" 2>/dev/null) + fi + if [ -n "${_proj}" ]; then + export GCP_PROJECT="${_proj}" + fi + fi + if [ -z "${GCP_ZONE:-}" ]; then + local _zone + if command -v jq >/dev/null 2>&1; then + _zone=$(jq -r '.GCP_ZONE // "" | select(. != null)' "${_gcp_config}" 2>/dev/null) + else + _zone=$(_FILE="${_gcp_config}" bun -e " +import fs from 'fs'; +const d = JSON.parse(fs.readFileSync(process.env._FILE, 'utf8')); +process.stdout.write(d.GCP_ZONE || ''); +" 2>/dev/null) + fi + if [ -n "${_zone}" ]; then + export GCP_ZONE="${_zone}" + fi + fi + fi + if ! command -v gcloud >/dev/null 2>&1; then log_err "gcloud CLI not found. Install from https://cloud.google.com/sdk/docs/install" missing=1