Skip to content

Commit e707475

Browse files
committed
fix(clickhouse): fetch tags via skopeo and fail closed on a missing pin
Address review of the version generator (hack/update-versions.sh): - Fetch tags with `skopeo list-tags` (registry v2 /tags/list) instead of the Docker Hub v2 API, whose anonymous pagination caps at 1000 entries and then returns an error page with no `.results`, silently truncating the list so the frozen 24.9.2.42 fell outside the window and the run failed. skopeo is already in build-deps and is how the sibling generators (postgres, redis, mongodb, opensearch, kubernetes) fetch. - Make a frozen default tag missing from the registry a hard error instead of silently falling back to a newer patch, which would move the default image for existing installs. - Restore 0644 on the regenerated files (mktemp's 0600 survived the mv). - Exclude /hack from the chart tarball via .helmignore. - Refresh files/versions.yaml: v25.8 -> 25.8.32.4, the true latest 25.8 patch now visible with the complete tag list. - bats: add a missing-frozen-tag hard-error case and make the atomicity test reach the resolution phase after a valid default rather than failing at the default-in-set check. Signed-off-by: Alexey Artamonov <[email protected]>
1 parent 3c78c0b commit e707475

4 files changed

Lines changed: 40 additions & 14 deletions

File tree

‎hack/clickhouse-update-versions_test.bats‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,33 @@ init_case() {
133133
if CH_SUPPORTED_MAJORS="26.99 24.9" bash "$GEN" >/dev/null 2>&1; then echo "expected non-zero exit" >&2; exit 1; fi
134134
}
135135

136-
@test "on error the committed files are left untouched (atomic)" {
136+
@test "a frozen default tag missing from the registry is a hard error" {
137137
init_case
138138
seed_values "$VALUES_FILE" v24.9
139-
printf '%s\n' 24.9.2.42 > "$SERVER"
139+
printf '%s\n' '"v24.9": "24.9.2.42"' > "$VERSIONS_FILE"
140+
printf '%s\n' 24.9.3.128 > "$SERVER" # the pinned 24.9.2.42 is absent
141+
cp "$SERVER" "$KEEPER"
142+
cp "$VERSIONS_FILE" "$WORK/versions.before"
143+
cp "$VALUES_FILE" "$WORK/values.before"
144+
# Must NOT silently fall back to 24.9.3.128 and move the default image.
145+
if CH_SUPPORTED_MAJORS="24.9" bash "$GEN" >/dev/null 2>&1; then echo "expected hard error on missing frozen tag" >&2; exit 1; fi
146+
cmp -s "$VERSIONS_FILE" "$WORK/versions.before" || { echo "versions.yaml changed on failure" >&2; exit 1; }
147+
cmp -s "$VALUES_FILE" "$WORK/values.before" || { echo "values.yaml changed on failure" >&2; exit 1; }
148+
}
149+
150+
@test "no files are written when a configured major fails to resolve" {
151+
init_case
152+
seed_values "$VALUES_FILE" v24.9
153+
# The default (v24.9) is valid and 25.8 resolves, so the run passes the
154+
# default check and gets deep into the resolution loop before 26.99 fails —
155+
# exercising that nothing is written after a partial resolution, not just on
156+
# an early exit.
157+
printf '%s\n' 24.9.2.42 25.8.28.1 > "$SERVER"
140158
cp "$SERVER" "$KEEPER"
141159
printf '%s\n' '"v24.9": "24.9.2.42"' > "$VERSIONS_FILE"
142160
cp "$VERSIONS_FILE" "$WORK/versions.before"
143161
cp "$VALUES_FILE" "$WORK/values.before"
144-
if CH_SUPPORTED_MAJORS="26.99" bash "$GEN" >/dev/null 2>&1; then echo "expected non-zero exit" >&2; exit 1; fi
162+
if CH_SUPPORTED_MAJORS="25.8 24.9 26.99" bash "$GEN" >/dev/null 2>&1; then echo "expected non-zero exit" >&2; exit 1; fi
145163
cmp -s "$VERSIONS_FILE" "$WORK/versions.before" || { echo "versions.yaml changed on failure" >&2; exit 1; }
146164
cmp -s "$VALUES_FILE" "$WORK/values.before" || { echo "values.yaml changed on failure" >&2; exit 1; }
147165
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.helmignore
22
/logos
33
/Makefile
4+
/hack
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
"v25.8": "25.8.28.1"
1+
"v25.8": "25.8.32.4"
22
"v25.3": "25.3.14.14"
33
"v24.9": "24.9.2.42"

‎packages/apps/clickhouse/hack/update-versions.sh‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ fetch_tags() {
3535
grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' "$file" | LC_ALL=C sort -u
3636
return
3737
fi
38+
# skopeo reads the registry v2 /tags/list, which returns the full tag set.
39+
# (Docker Hub's own v2 API caps anonymous pagination at 1000 entries and then
40+
# returns an error page with no `.results`, silently truncating the list.)
41+
# skopeo is already required by the repo's build-deps and is how the sibling
42+
# generators (postgres, redis, mongodb, opensearch, kubernetes) fetch tags.
43+
command -v skopeo >/dev/null 2>&1 || { echo "Error: skopeo is required to fetch tags" >&2; exit 1; }
3844
command -v jq >/dev/null 2>&1 || { echo "Error: jq is required to fetch tags" >&2; exit 1; }
39-
local url="https://hub.docker.com/v2/repositories/${repo}/tags/?page_size=100"
40-
while [ -n "$url" ] && [ "$url" != "null" ]; do
41-
local page
42-
page="$(curl -sSL "$url")"
43-
printf '%s\n' "$page" | jq -r '.results[].name'
44-
url="$(printf '%s\n' "$page" | jq -r '.next')"
45-
done | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' | LC_ALL=C sort -u
45+
skopeo list-tags "docker://docker.io/${repo}" \
46+
| jq -r '.Tags[]' \
47+
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' | LC_ALL=C sort -u
4648
}
4749

4850
echo "Resolving ClickHouse versions..." >&2
@@ -92,9 +94,11 @@ for mm in $CH_SUPPORTED_MAJORS; do
9294
if printf '%s\n' "$COMMON_TAGS" | grep -qx "$FROZEN_DEFAULT_TAG"; then
9395
tag="$FROZEN_DEFAULT_TAG"
9496
else
95-
echo "Warning: frozen default tag ${FROZEN_DEFAULT_TAG} for ${key} is no longer available in both images; falling back to the latest ${mm} patch" >&2
96-
[ -n "$latest" ] || { echo "Error: no tag found for default ${mm} in both images" >&2; exit 1; }
97-
tag="$latest"
97+
# Never silently move the default image. If the frozen tag has genuinely
98+
# left the registry, fail and let a maintainer re-pin files/versions.yaml
99+
# deliberately.
100+
echo "Error: frozen default tag ${FROZEN_DEFAULT_TAG} for ${key} is not available in both images; refusing to move the default. Re-pin files/versions.yaml deliberately if the default must change." >&2
101+
exit 1
98102
fi
99103
elif [ -n "$latest" ]; then
100104
tag="$latest"
@@ -163,4 +167,7 @@ done < "$VALUES_FILE"
163167

164168
mv "$TMP_VERSIONS" "$VERSIONS_FILE"
165169
mv "$TMP_VALUES" "$VALUES_FILE"
170+
# mktemp creates 0600 files and mv preserves that mode; restore the normal
171+
# world-readable mode so the committed files are not left at 0600.
172+
chmod 0644 "$VERSIONS_FILE" "$VALUES_FILE"
166173
echo "Updated $VERSIONS_FILE and $VALUES_FILE (default ${DEFAULT_VERSION})" >&2

0 commit comments

Comments
 (0)