Repository navigation
fix(build): honour PUSH and LOAD from the environment and in image-talos - #4654
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Repository: cozystack/cozystack/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: cozystack/cozystack/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughBuild settings now use nonempty environment or command-line values, with ChangesBuild controls
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The changes align image publishing with the requested build mode without an established regression. Mergeable subject to normal checks, including the make dry-run tests. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The changes reduce unintended image publication and do not demonstrate expanded credentials or privileges. Residual risk lies in existing independent cache writes and partially completed registry publication; their behavior outside the inspected release path remains unverified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
e82a3fb to
236640f
Compare
No caller passes the second argument any more, and an explicit tag would bypass CACHE_TAG, so the amd64 and arm64 legs of such an image would write the same mode=max cache ref and evict each other's layers. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
A plain := assignment beats an environment variable, so `LOAD=1 PUSH=0 make image` pushed a multi-arch build instead of loading one. An empty value from the environment falls back to the default rather than reaching buildx as `--push=`. PUSH now also defaults to 0 under LOAD=1, so a local load never publishes unless PUSH=1 is asked for. The OCI_EXPORT_DIR block still overrides an environment PUSH or LOAD. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
image-talos publishes with skopeo instead of buildx, so it never saw --push=$(PUSH) and a local PUSH=0 build still overwrote talos tags in REGISTRY. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
PUSHED_TAGS_LOG fed every tag to hack/stitch-multiarch.sh whether or not the build pushed it, so a PUSH=0 build, and now a plain LOAD=1 build, handed the stitch tags that were never published. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
236640f to
c603327
Compare
IvanHunters
left a comment
There was a problem hiding this comment.
LGTM
Verified hermetically with make -n and the bats suite, no cluster.
This makes the build honour PUSH/LOAD from the environment and the command line, which it did not before. On the merge base both were pinned unconditionally (PUSH := 1, LOAD := 0), so an environment PUSH=0 was silently overridden by the makefile and the build pushed anyway. The default survives the change: with nothing set the build still resolves --push=1 --load=0, an empty env value falls back to that default, LOAD=1 derives PUSH=0 while an explicit PUSH=1 still wins, and OCI_EXPORT_DIR keeps forcing both off.
image-talos now gates each skopeo copy docker:// on [ "$PUSH" = "1" ], so it lines up with the buildx images: pushes under the default PUSH=1, publishes nothing with PUSH=0. Gating PUSHED_TAGS_LOG on PUSH=1 is right for the same reason, the stitch should only move tags a build actually pushed.
I also checked the blast radius. No workflow sets PUSH or LOAD in the environment, and CI invokes make build / make -C … image relying on the unchanged default, so the CI push path is untouched. Dropping the per-call cache tag from cache-args is safe dead-code removal: no Makefile in the tree passes a second argument, at head or at the merge base.
All 14 cases in hack/common-envs_test.bats pass, and still pass after merging current main into the head. The rewritten CACHE_TAG test holds the new contract (CACHE_TAG wins, no per-call bypass) and would redden if the second argument came back.
[NIT] LOAD=1 make -C packages/core/talos image-talos without OCI_EXPORT_DIR now builds the installer index and then discards it without pushing or loading, because the skopeo path has no docker-store load. That fits the "don't touch the registry" intent, and a multi-arch index can't be loaded locally anyway. CI never calls image-talos with LOAD=1. Flagging it only in case a local build flow expected a talos image to land there.
…#4663) ## What this PR does A local build with `PUSH=0` no longer publishes the packages artifact. Before this change, `make image-packages` in `packages/core/installer` ran `flux push artifact` no matter what `PUSH` was set to, and then wrote the pushed digest into `values.yaml`. The `chart` target in the same Makefile already respects `PUSH`. With `PUSH` set to anything other than 1, the target now skips both the push and the digest stamp. It prints one line saying so and leaves the committed `platformSourceUrl` and `platformSourceRef` as they are. It still writes `packages/core/platform/.build-revision`, which is gitignored. I chose to skip the stamp instead of computing a local digest, because every reader of that value needs a digest that exists in the registry. The chart passes `platformSourceRef` to the operator as `--platform-source-ref`, and Flux then pulls `cozystack-packages@<digest>` from the registry. The release scripts `verify-promoted-packages.sh`, `promote-packages-artifact.sh`, `stitch-multiarch.sh` and `nightly-mirror.sh` also treat it as a registry digest. A digest of an artifact that was never pushed points at nothing. On main an unpushed run would not even get that far, since the recipe dies at `test -n "$DIGEST"`. The gate is a make-level `ifeq ($(PUSH),1)`, so it reads whatever `PUSH` ends up as after `hack/common-envs.mk`. On main that means `PUSH=0` on the command line. I also applied the `common-envs.mk` change from #4654 locally, which takes `PUSH` from the environment and makes `LOAD=1` default it to 0. With that applied, a dry run shows no push and no stamp for `PUSH=0` in the environment, for `LOAD=1`, and for `PUSH=0` on the command line, while `LOAD=1 PUSH=1` and an empty `PUSH` still push. CI is not affected, because no workflow sets `PUSH` or `LOAD` and `PUSH` stays at 1. I dry-ran the three CI invocations of this Makefile before and after the change, on main and again with #4654 applied: - `tags.yaml`, release stitch step: `make -C packages/core/installer image-packages chart` with `REGISTRY`, a release tag as `IMAGE_TAG`, and `PUSHED_TAGS_LOG` - `pull-requests.yaml`, installer step of a same-repo PR: `make -C packages/core/installer image` with a `pr-N-sha` tag, `PLATFORM=linux/amd64`, `BUILDER`, and an empty `OCI_EXPORT_DIR` - `build-main.yaml` and `build-release.yaml`: `make build`, which runs the installer `image` target with defaults ```text $ diff --recursive before/ after/ # tags.txt pr.txt build.txt $ echo $? 0 ``` There is one side effect. `OCI_EXPORT_DIR` forces `PUSH := 0`, so running `image-packages` with it set no longer pushes, where before it would have tried an anonymous push. No CI path does that. The fork PR build already runs only `pre-checks image-operator` for the installer, and the `make -n ... image OCI_EXPORT_DIR=/oci` scan in `e2e-fork.yaml` greps only the `.oci.tar` names, which this change does not touch. The new test dry-runs the target in both modes. With `PUSH=0` there must be no `flux push artifact` and no `platformSourceRef` stamp; with `PUSH` at its default, both must be present. The first test fails on main. I mutated the guard three ways, and each time only the matching test went red: - condition forced true: the `PUSH=0` test fails - compared against 2: the default-path test fails - `endif` moved up so only the push is gated: the `PUSH=0` test fails on the stamp check One limitation is left as a follow-up. The test's `env -u PUSH -u LOAD` only isolates it once #4654 lands, because on main a file assignment wins over the environment anyway. It does not cover `PUSH=0` coming in through `MAKEFLAGS`, so `make bats-unit-tests PUSH=0` would fail the default-path test here and the ordering check in `hack/stitch-multiarch_test.bats`. Nothing runs the suite that way today. If that changes, passing an explicit `PUSH=1` on the default-path `make` lines, or unsetting `MAKEFLAGS` the way `hack/bats-unit-keep-going.bats` does, would fix it. ### Screenshots Not a UI change. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: The website's `development.md` tells developers to run `make image-packages` with `REGISTRY` set to their own registry. That is the default `PUSH=1` path, and it works as before. Neither the website nor ccp mentions `PUSH=0` for this target. Closes #4656 ### Release note ```release-note fix(installer): `make image-packages` no longer pushes the cozystack-packages artifact or stamps its digest into values.yaml when PUSH=0. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * You can run `image-packages` with `PUSH=0` to skip publishing the artifact and keep the committed platform source reference unchanged. * When pushing is enabled, the command publishes the artifact and updates the platform source URL and digest-based reference. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
What this PR does
A local build that asks to load images into docker no longer pushes them.
hack/common-envs.mksetPUSHandLOADwith plain:=, and a makefile assignment beats the environment, soLOAD=1 PUSH=0 make imagequietly pushed a multi-arch build. Both now take the environment value, and an empty one falls back to the default. I also madePUSHdefault to 0 whenLOAD=1, soLOAD=1alone only loads. Before this,make image LOAD=1pushed and loaded at once. An explicitPUSHfrom the environment or the command line still wins, andOCI_EXPORT_DIRstill forces both off. Every buildx target gets the values throughBUILDX_ARGS, so the fix lives in that one file.The Talos installer was the one image that ignored
PUSH. It is published with skopeo, not buildx, so it never saw--push=$(PUSH). Its registry copies now run only whenPUSH=1.A build that pushes nothing no longer writes
PUSHED_TAGS_LOG. That log tells the multi-arch stitch which tags to move, so it must hold only tags that were really pushed.The cache helper lost an argument nobody used. No caller passes the second argument of
cache-args, and an explicit tag there would bypassCACHE_TAG, so the amd64 and arm64 builds of that image would share one cache ref.CI sets neither
PUSHnorLOAD, so CI builds do the same thing as before. Each fix has amake --dry-runtest inhack/common-envs_test.bats.Closes #4499
Closes #4504
Closes #4551
Screenshots
Not a UI change.
Downstream repositories
The ccp skills pass
PUSH=1explicitly, which still works. The website docs do not mentionPUSH,LOADorcache-args.Release note