Skip to content

Commit 4107371

Browse files
authored
feat(infra): Implement parallel base image builds (google#14112)
## What this PR does This PR refactors the base image build process to support parallel builds for multiple Ubuntu versions (`legacy`, `20.04`, `24.04`), aligning with the project's multi-version image strategy. The primary goal is to enable a flexible and controlled migration path from the legacy image to newer Ubuntu versions, while ensuring stability and consistency. ## Why this PR is important Previously, the base image build was a monolithic process tied to a single version. This change introduces the necessary infrastructure to: - Build, test, and publish images for all supported Ubuntu versions simultaneously. - Safely promote a new Ubuntu version (e.g., `ubuntu-20-04`) to become the new default (`:v1` tag) via a single configuration change, without race conditions. - Ensure that all versioned tags (e.g., `:ubuntu-24-04`) are also multi-architecture, providing a consistent experience across all images. ## How the changes were implemented - **Parallel Build Trigger:** The main `base_builder` Cloud Function in `infra/build/functions/base_images.py` was refactored. It now iterates through the `SUPPORTED_VERSIONS` and triggers a separate, parallel Google Cloud Build run for each version. - **Configurable Default Version:** A `DEFAULT_VERSION` constant was introduced. The logic that applies the primary `:v1` tag and builds the multi-arch manifest for it is now tied to this variable, making the promotion of a new default version a simple, one-line change. - **Generalized Manifest Creation:** The logic to create multi-architecture manifests was generalized and is now applied to *all* build versions, ensuring that tags like `:ubuntu-20-04` and `:ubuntu-24-04` are also multi-arch. - **Simplified Tagging:** The redundant `:legacy` tag was removed. The build designated as `DEFAULT_VERSION` now produces the `:v1` tag. To ensure compatibility with chained builds, it also produces the `:latest` tag. All other builds produce only their specific version tag (e.g., `:ubuntu-20-04`). - **Local Testing Capabilities:** The script now supports `--dry-run` and `--no-push` flags, allowing for robust local testing and validation of the build logic without affecting the image registry. - **Bug Fixes:** - `report_generator.py` was enhanced to correctly handle build failures where no projects are run. - `build_lib.py` was modified to return the full build object, enabling build tracking and logging of GCB URLs. - Corrected a path resolution bug for the `base-clang-full` image variant. ## How to test 1. Run the script locally with the dry run flag to inspect the generated build steps: ```bash python3 infra/build/functions/base_images.py --dry-run ``` 2. Trigger a real build without publishing the images to the registry: ```bash python3 infra/build/functions/base_images.py --no-push ``` Monitor the build links logged to the console to confirm success. ## Verification The new logic was tested by triggering a real build on GCB using the `--no-push` flag. All three versioned builds completed successfully, confirming the fix. - **Legacy (v1) Build:** SUCCESS ([View Log](https://console.cloud.google.com/cloud-build/builds;region=us-central1/58a597b4-cd61-4177-9941-9bbd22df1df0?project=1053000335369)) - **Ubuntu 20.04 Build:** SUCCESS ([View Log](https://console.cloud.google.com/cloud-build/builds;region=us-central1/8469368f-a626-4773-8f45-f67a11e03562?project=1053000335369)) - **Ubuntu 24.04 Build:** SUCCESS ([View Log](https://console.cloud.google.com/cloud-build/builds;region=us-central1/b962938a-dbe0-4347-bc35-7a109cad5b70?project=1053000335369)) ## Related Task - **Taskflow:** [b/441792502](b/441792502)
1 parent ab72dd7 commit 4107371

File tree

4 files changed

+268
-92
lines changed

4 files changed

+268
-92
lines changed

0 commit comments

Comments
 (0)