fix(e2e): load GCP_ZONE from ~/.config/spawn/gcp.json in E2E driver (#3017)

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 <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
A 2026-03-26 11:27:46 -07:00 committed by GitHub
parent 6d46a52f6f
commit defca448b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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