Skip to content

feat(ci): add dynamic region selection and minor CI stability fixes - #538

Open
alizaidis wants to merge 3 commits into
mainfrom
feat/ci-region-shuffling
Open

feat(ci): add dynamic region selection and minor CI stability fixes#538
alizaidis wants to merge 3 commits into
mainfrom
feat/ci-region-shuffling

Conversation

@alizaidis

@alizaidis alizaidis commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

PR: Dynamic CI Region Selection and minor CI stability fixes

Overview

This PR addresses the CI failures we've been experiencing due to ZONE_RESOURCE_POOL_EXHAUSTED errors in us-central1. By dynamically shuffling our candidate deployment regions and validating their quota capacity for our baseline requirements, we statistically spread our CI load and prevent immediate cluster / system node pool creation failures.

Additionally, this PR addresses critical review feedback by fixing the sequencing of project bootstrapping, bypassing region-specific Custom Compute Class health checks, and bulletproofing our token injection scripts.

Key Changes

1. Dynamic Region Shuffling (select_best_ci_region.sh)

  • Randomized Load Balancing: Replaced the static, top-down region evaluation with a shuf -e command. We now randomize the array of candidate regions on every single run, which inherently acts as a retry mechanism across regions when rerunning failed jobs.
  • n4-standard-4 Offerings Check: Added a strict precondition check. Candidate regions are now actively verified to ensure they offer the n4-standard-4 instance type required by our system node pools before being considered.

2. Ephemeral Project Sequencing (configure_build_environment.sh & create_project.sh)

  • Corrected Pipeline Order: Relocated the execution of create_project.sh to occur before region selection. This allows the script to pass $NEW_PROJECT_ID into the selection logic, guaranteeing that quotas are evaluated against the actual ephemeral CI project rather than a generic parent.
  • Fixed Billing & API Enablement: Corrected a chicken-and-egg bootstrap bug in create_project.sh where the Compute Engine API was being enabled before the project was attached to a billing account, which was silently failing the region selection script.

3. Custom Compute Class Health Checks Bypass

  • Added export TF_VAR_cluster_check_custom_compute_classes_healthy="false" into the generated build.env payload.
  • Because our Custom Compute Classes define massive instances (like a3-megagpu-8g) that only exist in select zones, GKE's auto-provisioner flags the CRDs as unhealthy in alternative regions (like europe-west4). Bypassing this health check in CI prevents the pipeline from failing on non-central regions.

4. Robust Hugging Face Token Population

  • Bulletproofed populate_huggingface_token_secrets.sh across all use-cases (inference, training, and RL).
  • The script now safely ensures the secretmanager.googleapis.com API is enabled and explicitly checks if the secret container exists (creating it if necessary) before attempting to add the token payload version. This prevents crashes during secret population on fresh CI projects.

5. Code Maintenance & Documentation

  • Added explanatory documentation inside validate_kustomize.sh regarding the LOCAL_CRDS_FLAG to clarify that kubectl validate inherently requires local schemas for CRDs like Prometheus ServiceMonitor because there is no live cluster during the manifest generation phase to query for the CRD.

@alizaidis
alizaidis force-pushed the feat/ci-region-shuffling branch from 18ee383 to daebf8e Compare August 6, 2026 21:23
@alizaidis
alizaidis requested a review from syeda-anjum August 6, 2026 22:00
@alizaidis
alizaidis force-pushed the feat/ci-region-shuffling branch from daebf8e to f46d84d Compare August 7, 2026 19:28
"${ACP_REPO_DIR}/platforms/gke/base/use-cases/inference-ref-arch/kubernetes-manifests/online-inference-gpu/vllm-native-cache-offloading/single-tier/configure_vllm.sh"


CRD_DIR="${ACP_REPO_DIR}/test/ci-cd/crds"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I am not clear why we want to add the crds locally here?


# Check if region supports required GPU & TPU v6e machine types (ct6e-standard-4t OR a2-highgpu-1g / g2-standard-4)
if [ -n "${PROJECT_ID_TO_CHECK}" ]; then
mt_check=$(gcloud compute machine-types list --filter="zone ~ ${region} AND name=(ct6e-standard-4t OR a2-highgpu-1g OR g2-standard-4)" --project="${PROJECT_ID_TO_CHECK}" --format="value(name)" 2>/dev/null | head -n 1 || true)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check for all the machine types being created as part of custom compute classes otherwise this code section https://github.com/GoogleCloudPlatform/accelerated-platforms/blob/main/platforms/gke/base/core/custom_compute_class/main.tf#L98. will fail the CI pipeline with these errors:


│ auto provisioned zones, last zone check error: Machine type a2-ultragpu-1g
--
  | │ not available in us-east1-d zone Crd is not healthy.
  | │ gpu-h100-80gb-high-x1: Machine type a3-highgpu-1g is not available in any
  | │ of auto provisioned zones, last zone check error: Machine type
  | │ a3-highgpu-1g not available in us-east1-d zone Crd is not healthy.
  | │ gpu-h100-80gb-high-x2: Machine type a3-highgpu-2g is not available in any
  | │ of auto provisioned zones, last zone check error: Machine type
  | │ a3-highgpu-2g not available in us-east1-d zone Crd is not healthy.
  | │ gpu-h100-80gb-high-x4: Machine type a3-highgpu-4g is not available in any
  | │ of auto provisioned zones, last zone check error: Machine type
  | │ a3-highgpu-4g not available in us-east1-d zone Crd is not healthy.
  | │ gpu-h100-80gb-high-x8: Machine type a3-highgpu-8g is not available in any
  | │ of auto provisioned zones, last zone check error: Machine type
  | │ a3-highgpu-8g not available in us-east1-d zone Crd is not healthy.
  | │ gpu-h100-80gb-mega-x8: Machine type a3-megagpu-8g is not available in any
  | │ of auto provisioned zones, last zone check error: Machine type
  | │ a3-megagpu-8g not available in us-east1-d zone Crd is not healthy.
  | │ gpu-h200-141gb-ultra-x8: Machine type a3-ultragpu-8g is not available in
  | │ any of auto provisioned zones, last zone check error: Machine type
  | │ a3-ultragpu-8g not available in us-east1-d zone Crd is not healthy.
  | │ gpu-h200-141gb-ultra-x8-co: Machine type a3-ultragpu-8g is not available in
  | │ any of auto provisioned zones, last zone check error: Machine type

An example of failed pipeline : https://pantheon.corp.google.com/cloud-build/builds;region=us-central1/92944804-05b4-4192-b2e6-7813c5471e92;step=2?project=accelerated-platforms

Ideally, CANDIDATE_REGIONS in this script should only have those regions that we know supports all the machine types covered in accelerated platforms. But unfortunately, no region other than us-central1 supports all the machine types that we use here.

If my understanding is correct no CI test other than ComfyUI deploys any AI workload that would need machine availability, they just deploy the platform including CCC. ComfyUI deploys the workload but on L4 only. We will need to bypass the CCC check if we want to run the CI in a region other than us-central1 as none of the other regions have full coverage of the machines

EOT

# Run preflight region check to select optimal region for CI run
DYNAMIC_CI_REGION="$("${ACP_REPO_DIR}/test/ci-cd/scripts/cloudbuild/select_best_ci_region.sh" "${PROJECT_ID:-}" | tail -n 1)"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$PROJECT_ID will be accelerated-platforms in the cloudbuild env so the script will check regions and cpu limits and usage in accelerated-platforms and not the project where the platform will be created(platform_default_project_id).

@alizaidis
alizaidis force-pushed the feat/ci-region-shuffling branch 7 times, most recently from 63e6f66 to 9f45a9a Compare August 11, 2026 21:44
@alizaidis
alizaidis force-pushed the feat/ci-region-shuffling branch from 9f45a9a to f25c281 Compare August 11, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants