Skip to content

Commit 770314b

Browse files
fix(ci): retag images whose digest is embedded in the values tag
promote-retag.sh carries the same collect_refs blind spot the previous commit fixes in nightly-mirror.sh, and nightly-mirror.sh's own comment asserted the two were "identical to" each other -- which is how the gap stayed invisible once one of them was fixed. Measured against the committed tree, the dry-run selects 19 repositories before this change and 27 after. The eight it was missing are exactly the set that broke the nightly: kamaji, kilo, linstor-csi, piraeus-server, linstor-gui, metallb-controller, metallb-speaker, redis-operator. Nothing is lost from the previous selection. The consequence differs from the nightly case and is milder. This retag is within a single registry, so the digests already exist and every digest-pinned install still resolves -- there is no dangling reference and no 404. What is missing is the :<version> tag (and :latest under MOVE_LATEST=1) for those eight images, so a promoted release does not carry the tags it claims to, and anything resolving a cozystack component by version tag rather than by digest does not find it. Nothing in the promotion detects this: the script reports success having simply never seen those refs. The existing test could not catch it. It asserts "at least one cozystack-owned image is selected" and that nothing third-party leaks in -- both satisfied by the shapes that already worked, which is why eight omissions sat under a green suite. It now names concrete shape-3 packages, since a count or a generic pattern would drift back to proving nothing. Verified the assertion fails against the unfixed script. Same type guard on `.tag` as the previous commit, for the same reason: without it an unquoted numeric tag anywhere in a file silently discards every shape-3 ref in that file, and the swallowed stderr leaves no trace. Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 06278ac commit 770314b

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

‎hack/promote-retag.sh‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,29 @@ yq --version 2>&1 | grep -q mikefarah || { echo "yq (mikefarah) is required" >&2
5050
[ "$DRY_RUN" -eq 1 ] || command -v skopeo >/dev/null || { echo "skopeo is required" >&2; exit 1; }
5151

5252
# Collect "repo@sha256:..." refs from every package values.yaml, across the
53-
# three shapes the build writes:
53+
# four shapes the build writes:
5454
# 1. single string <repo>:<tag>@sha256:<digest> (e.g. .cozystackAPI.image)
5555
# 2. split map {repository, tag, digest} (e.g. .cilium.image)
56-
# 3. OCI artifact {platformSourceUrl: oci://<repo>, platformSourceRef: digest=sha256:<digest>}
56+
# 3. split map {repository, tag: <tag>@sha256:<digest>} (e.g. .linstorCSI.image)
57+
# 4. OCI artifact {platformSourceUrl: oci://<repo>, platformSourceRef: digest=sha256:<digest>}
58+
#
59+
# Shape 3 is the dominant one: most package Makefiles set `.image.tag` to
60+
# "$(IMAGE_TAG)@$(digest)" in a single yq call instead of maintaining a separate
61+
# `digest` key. It matches neither shape 2 (no `digest` key) nor, usefully, shape
62+
# 1 — that rule sees only the bare tag value, which carries no repository, so
63+
# ref_repo() reduces "<tag>@sha256:<digest>" to "<tag>" and the ownership filter
64+
# drops it. Omitting this rule silently skipped eight images across six packages
65+
# (kamaji, kilo, linstor-csi, piraeus-server, linstor-gui, metallb-controller,
66+
# metallb-speaker, redis-operator): the promotion reported success while never
67+
# creating their :<version> tags. Unlike the nightly mirror this retags within one
68+
# registry, so the digests still resolve and digest-pinned installs are unaffected
69+
# — but the release does not carry the tags it claims to, and nothing detects it.
70+
#
71+
# The `tag == "!!str"` guard is load-bearing: yq's test() aborts the expression on
72+
# a non-string tag ("cannot match with !!int"), and since this invocation swallows
73+
# stderr and status, that abort would silently drop every shape-3 ref in the same
74+
# file. `tag: 1.24` unquoted in a neighbouring third-party block is enough. Rule 1
75+
# is immune — its `select(tag == "!!str")` already precedes its test().
5776
collect_refs() {
5877
for f in packages/*/*/values.yaml; do
5978
[ -f "$f" ] || continue
@@ -62,6 +81,8 @@ collect_refs() {
6281
# shape 2
6382
yq -r '.. | select(tag == "!!map") | select(has("repository") and has("digest")) | .repository + "@" + .digest' "$f" 2>/dev/null || true
6483
# shape 3
84+
yq -r '.. | select(tag == "!!map") | select(has("repository") and has("tag")) | select(.tag | tag == "!!str") | select(.tag | test("@sha256:[0-9a-f]{64}")) | .repository + "@" + (.tag | sub(".*@"; ""))' "$f" 2>/dev/null || true
85+
# shape 4
6586
yq -r '.. | select(tag == "!!map") | select(has("platformSourceUrl") and has("platformSourceRef")) | (.platformSourceUrl | sub("^oci://"; "")) + "@" + (.platformSourceRef | sub("^digest="; ""))' "$f" 2>/dev/null || true
6687
done
6788
}

‎hack/promote-retag_test.bats‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@
4848
# At least one cozystack-owned image is selected.
4949
grep -q 'docker://ghcr.io/cozystack/cozystack/' "$tmp/out"
5050

51+
# Images whose digest is embedded in `tag` ({repository, tag: <t>@sha256:<d>})
52+
# must be selected too. The "at least one owned ref" check above cannot catch
53+
# their absence — it is satisfied by the shapes that already worked, which is
54+
# why eight images across six packages were silently skipped while this suite
55+
# stayed green. Naming concrete packages is deliberate: a count or a generic
56+
# pattern would drift back to proving nothing. linstor-csi and piraeus-server
57+
# are the two whose absence from GHCR broke the nightly e2e at image pre-pull.
58+
for owned in linstor-csi piraeus-server kamaji redis-operator; do
59+
grep -q "docker://ghcr.io/cozystack/cozystack/${owned}@sha256:" "$tmp/out"
60+
done
61+
5162
# Every docker:// ref in the copy plan is under the cozystack registry — no
5263
# third-party repos and no malformed arg-string refs leak through.
5364
bad=$(grep -oE 'docker://[^ ]+' "$tmp/out" | sed 's|docker://||' \

0 commit comments

Comments
 (0)