Skip to content

fix(ci): honour a preset CHART_VERSION and sort chart tags explicitly - #5343

Open
gustavolira wants to merge 2 commits into
redhat-developer:release-1.9from
gustavolira:fix/ci-pin-chart-to-image-tag-1.9
Open

fix(ci): honour a preset CHART_VERSION and sort chart tags explicitly#5343
gustavolira wants to merge 2 commits into
redhat-developer:release-1.9from
gustavolira:fix/ci-pin-chart-to-image-tag-1.9

Conversation

@gustavolira

Copy link
Copy Markdown
Member

Companion to #5341 (main) and #5342 (release-1.10). This branch carries a different and worse variant of the same problem, so this is not a straight cherry-pick.

Problem

--chart-version is silently discarded on this branch

CHART_VERSION=$(get_chart_version "$CHART_MAJOR_VERSION")
export CHART_VERSION

No -z guard. The Gangway trigger passes an override through MULTISTAGE_PARAM_OVERRIDE_CHART_VERSION, which reaches the script as CHART_VERSION and is overwritten on this line before anything reads it. Every release-1.9 run has resolved the newest chart on the branch regardless of what the operator asked for. main and release-1.10 already guard this; this branch never did.

A pinned image tag does not pin the chart either

--tag 1.9-246 alone leaves CHART_VERSION empty, so the newest chart is resolved. The image and the chart are published together under the same build number, so a pinned TAG_NAME already determines the chart.

Chart tag selection depends on undocumented API ordering

| jq '.tags[0].name' | grep -oE '[0-9]+\.[0-9]+-[0-9]+-CI'

The quay request sets no sort parameter, so taking .tags[0] is an implicit dependency on the response happening to come back newest first.

Fix

Add the -n guard so a preset CHART_VERSION wins. Derive it from TAG_NAME when the tag is pinned to a build number, and log that it was derived. Select the CI chart tags explicitly and take max_by(.start_ts).

Input Before After
--chart-version 1.9-246-CI discarded, newest chart used used as given
--tag 1.9-246, no chart newest chart 1.9-246-CI
--tag 1.9 newest chart unchanged
nothing pinned newest chart unchanged

Verification

Both the old and the new jq expression return 1.9-247-CI against the live API, so today's behaviour is unchanged while the dependency on response order is gone.

1.9-246 -> 1.9-246-CI
1.9     -> resolves from quay (not pinned)

shellcheck --severity=warning and yarn prettier:check pass.

Note on structure

get_chart_version lives in .ci/pipelines/utils.sh on this branch rather than .ci/pipelines/lib/helm.sh, and takes $CHART_MAJOR_VERSION as an argument. The change is equivalent to the other two PRs, adapted to that shape.

🤖 Generated with Claude Code

On this branch CHART_VERSION was assigned unconditionally:

    CHART_VERSION=$(get_chart_version "$CHART_MAJOR_VERSION")

The Gangway trigger passes an override through
MULTISTAGE_PARAM_OVERRIDE_CHART_VERSION, which reaches the script as
CHART_VERSION and is then overwritten on this line before anything reads
it. `--chart-version` has therefore been silently discarded on every
release-1.9 run, and the job resolved the newest chart on the branch
instead. main and release-1.10 already guard this with `-z`; this branch
never did.

Add the guard, and while here close the same gap those branches have: a
pinned image tag did not pin the chart either. `--tag 1.9-246` alone left
CHART_VERSION empty, so the newest chart was resolved regardless. The
image and the chart are published together under the same build number,
so a pinned TAG_NAME already determines the chart. Derive it, and log
that it was derived.

get_chart_version also took `.tags[0].name` from the quay API, which
assumes the response is ordered newest first. The request sets no sort
parameter, so that is an implicit dependency on undocumented behaviour.
Select the tags matching the CI chart shape and take max_by(.start_ts).
Verified against the live API: both the old and the new expression return
1.9-247-CI today.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

The container image build workflow finished with status: failure.

Two problems found reviewing this PR's own diff.

Dropping the `grep` after jq lost the empty case: `max_by` over no
matches yields null, and `jq -r` prints it as the string "null", so
CHART_VERSION became "null". The old grep produced nothing there. Add
`// empty`.

A GA verification pins the image to x.y.z and passes no --chart-version,
which fell through to the lookup and paired it with the newest CI chart -
the same mismatch this PR fixes, for the other half of the flow. The
chart repo publishes exact GA tags (1.9.8 exists), so map x.y.z to
itself.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

The container image build workflow finished with status: failure.

Comment thread .ci/pipelines/utils.sh
@@ -1510,7 +1510,7 @@ get_previous_release_version() {
get_chart_version() {
local chart_major_version=$1
curl -sSX GET "https://quay.io/api/v1/repository/rhdh/chart/tag/?onlyActiveTags=true&filter_tag_name=like:${chart_major_version}-" -H "Content-Type: application/json" \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add comment explaining that chart_major_version is actually in the form x.y (major.minor or stream) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants