mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-02 21:30:46 +09:00
perf(ci): build release lines from their own cache, in parallel
Release-line image builds read only main's build cache. Once main moved its builder and base images, release-1.7's Dockerfiles stopped matching that cache, and the rc Build step went from 19 to 53 minutes on amd64 and from 10 to 46 on arm64 between v1.7.1-rc.2 and v1.7.2-rc.2. Each line now keeps a cache of its own. build-release.yaml writes buildcache-release-X.Y on every push to the line, and rc builds import it together with main's buildcache. The arm64 rc build, the only arm64 build a line has, keeps buildcache-arm64-release-X.Y itself. CACHE_FROM_TAGS lists every cache a build imports; unset, it is CACHE_TAG, as before. The units of hack/build-matrix.sh now build four at a time (make build- parallel, hack/build-units.sh), since they spend most of their time on registry round trips, one image after another. Every output line carries its unit and is written as it comes, so a job that times out still shows where it stopped. objectstorage-controller waits for the rest because it writes seaweedfs' values.yaml. The rc jobs also leave their buildx builder to the throwaway runner: removing it took up to 11 minutes on arm64. A cache write that fails no longer fails the build (ignore-error=true on every --cache-to): OCIR refuses a blob upload now and then, which already failed the arm64 nightly twice in its last thirty runs, and rc and line builds now write a cache too. Tested with bats: the cache macro, the unit builder against a fake make (the BUILD_JOBS limit, ordering, a failing unit, a failing objectstorage-controller, a unit list that cannot be generated, and output that shows while a unit still builds) and the workflow settings, plus a dry run of hack/build-units.sh over the real units with make -n. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
12 files changed
+251
-35
No files matched your search
@@ -3,7 +3,7 @@ name: Build release line
|
||||
# Publishes the per-line equivalent of what build-main.yaml publishes for main:
|
||||
# every image tagged with the line's branch name, and the whole packages tree as
|
||||
# the `cozystack-packages:<branch>` OCI artifact with each image reference
|
||||
# digest-pinned to the images this run just pushed (`make build` ->
|
||||
# digest-pinned to the images this run just pushed (`make build-parallel` ->
|
||||
# packages/core/installer image-packages does the `flux push artifact`).
|
||||
#
|
||||
# Why it exists: pull-requests.yaml overlays image refs for every package a PR
|
||||
@@ -16,9 +16,9 @@ name: Build release line
|
||||
# artifact published per line, the overlay reads the PR's own base branch and the
|
||||
# generations match.
|
||||
#
|
||||
# Cost: one full `make build` per push to a maintained line, i.e. per merged
|
||||
# backport. That is the price of release-line PRs testing their line's tip rather
|
||||
# than its last release.
|
||||
# Cost: one full `make build-parallel` per push to a maintained line, i.e. per
|
||||
# merged backport. That is the price of release-line PRs testing their line's
|
||||
# tip rather than its last release.
|
||||
|
||||
env:
|
||||
# Same per-CI registry as pull-requests.yaml and build-main.yaml.
|
||||
@@ -140,19 +140,21 @@ jobs:
|
||||
DOCKER_CONFIG: ${{ runner.temp }}/.docker
|
||||
|
||||
- name: Build line images and publish the packages artifact
|
||||
run: make build
|
||||
run: make build-parallel
|
||||
env:
|
||||
DOCKER_CONFIG: ${{ runner.temp }}/.docker
|
||||
BUILDER: ${{ steps.buildx.outputs.name }}
|
||||
# amd64 only, as in build-main.yaml.
|
||||
PLATFORM: linux/amd64
|
||||
# READ the shared mode=max cache, never write it. CACHE_REGISTRY/<img>:
|
||||
# buildcache is a single ref per image and build-main.yaml is
|
||||
# deliberately its only writer, serialized, precisely so concurrent
|
||||
# builds cannot race on the cache manifest (the 409 collision class
|
||||
# #2711 fixed for image tags). A line build can overlap a main build, so
|
||||
# writing here would reintroduce exactly that race.
|
||||
WRITE_CACHE: '0'
|
||||
# The line keeps a mode=max cache of its own, which its rc builds in
|
||||
# tags.yaml import too: main's cache (:buildcache, written only by
|
||||
# build-main.yaml) misses more with every Dockerfile main changes after
|
||||
# the line branched. The concurrency group above runs one build per
|
||||
# line, so this is the only writer of the line's ref, and main's ref is
|
||||
# only read.
|
||||
CACHE_TAG: buildcache-${{ github.ref_name }}
|
||||
CACHE_FROM_TAGS: buildcache-${{ github.ref_name }} buildcache
|
||||
WRITE_CACHE: '1'
|
||||
# Floating per-line handle: images and the packages artifact both land
|
||||
# under the branch name (e.g. :release-1.6). Versioned and :latest tags
|
||||
# belong to releases (tags.yaml / finalize), never to this workflow.
|
||||
|
||||
+20
-15
@@ -101,6 +101,9 @@ jobs:
|
||||
with:
|
||||
driver: docker-container
|
||||
buildkitd-config: hack/buildkitd.toml
|
||||
# The runner is thrown away after the job; removing the builder only
|
||||
# costs time.
|
||||
cleanup: false
|
||||
env:
|
||||
DOCKER_CONFIG: ${{ runner.temp }}/.docker
|
||||
|
||||
@@ -108,14 +111,13 @@ jobs:
|
||||
if: steps.check_release.outputs.release_exists == 'false'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Assigned and checked before the loop: a build-matrix.sh failure
|
||||
# inside `for unit in $(...)` would run no iteration and leave a
|
||||
# green job that built nothing.
|
||||
units="$(MATRIX_ARCH=arm64 hack/build-matrix.sh | jq -r '.[]')"
|
||||
[ -n "$units" ]
|
||||
for unit in $units; do
|
||||
make -C "$unit" image
|
||||
done
|
||||
# The rc builds are the only arm64 builds a release line has, so they
|
||||
# keep the line's arm64 cache themselves. They import main's nightly
|
||||
# cache too, which is all the first rc of a line has.
|
||||
line="release-$(echo "${GITHUB_REF_NAME#v}" | cut --delimiter=. --fields=1-2)"
|
||||
export CACHE_TAG="buildcache-arm64-$line"
|
||||
export CACHE_FROM_TAGS="buildcache-arm64-$line buildcache-arm64"
|
||||
MATRIX_ARCH=arm64 hack/build-units.sh
|
||||
make -C packages/core/installer image-operator
|
||||
env:
|
||||
DOCKER_CONFIG: ${{ runner.temp }}/.docker
|
||||
@@ -123,10 +125,7 @@ jobs:
|
||||
SBOM: '1'
|
||||
PLATFORM: linux/arm64
|
||||
CACHE_REGISTRY: iad.ocir.io/idyksih5sir9/cozystack
|
||||
# Read the arm64 cache build-arm64-nightly.yaml keeps warm; a release
|
||||
# build never writes one.
|
||||
CACHE_TAG: buildcache-arm64
|
||||
WRITE_CACHE: '0'
|
||||
WRITE_CACHE: '1'
|
||||
IMAGE_TAG: ${{ github.ref_name }}-arm64
|
||||
PUBLISH_VERSIONED: '0'
|
||||
PUBLISH_FLOATING: '0'
|
||||
@@ -143,8 +142,8 @@ jobs:
|
||||
if: github.repository == 'cozystack/cozystack'
|
||||
name: Build amd64 images and assets
|
||||
# Ephemeral pool, not the dedicated self-hosted runner (#2937 decommission).
|
||||
# Serial `make build` + `make assets` is CPU-bound, so use the large shape —
|
||||
# same as the main cache warmer (build-main.yaml).
|
||||
# `make build-parallel` runs several image builds at once, so use the large
|
||||
# shape, as the main cache warmer (build-main.yaml) does.
|
||||
runs-on: oracle-vm-24cpu-96gb-x86-64
|
||||
# The budget prepare-release had while it also built; the stitch and the
|
||||
# uploads it no longer runs moved to prepare-release with their own.
|
||||
@@ -305,6 +304,9 @@ jobs:
|
||||
driver: docker-container
|
||||
buildkitd-config: hack/buildkitd.toml
|
||||
use: false
|
||||
# The runner is thrown away after the job; removing the builder only
|
||||
# costs time.
|
||||
cleanup: false
|
||||
env:
|
||||
DOCKER_CONFIG: ${{ runner.temp }}/.docker
|
||||
|
||||
@@ -313,7 +315,7 @@ jobs:
|
||||
if: steps.check_release.outputs.release_exists == 'false'
|
||||
run: |
|
||||
mkdir -p "${PUSHED_TAGS_LOG%/*}"
|
||||
make build
|
||||
make build-parallel
|
||||
# The arm64 assets published below install this image, and building
|
||||
# its arm64 half needs no QEMU, so it is pushed again as both arches.
|
||||
make -C packages/core/talos image-talos PLATFORM=linux/amd64,linux/arm64
|
||||
@@ -329,6 +331,9 @@ jobs:
|
||||
# them from OCIR while pushing images to GHCR. A missing :buildcache
|
||||
# ref 404s harmlessly into a cold build.
|
||||
CACHE_REGISTRY: iad.ocir.io/idyksih5sir9/cozystack
|
||||
# The line's own cache, which build-release.yaml writes on every push
|
||||
# to the line, and main's.
|
||||
CACHE_FROM_TAGS: buildcache-release-${{ steps.tag.outputs.line }} buildcache
|
||||
# amd64 here; build-arm64 builds arm64 natively.
|
||||
PLATFORM: linux/amd64
|
||||
# Push the release tag as :IMAGE_TAG (vX.Y.Z-rc.N) and the component
|
||||
|
||||
Reference in new issue
Block a user