Skip to content

fix(ci): read the upstream commit of Konflux images for main E2E coverage - #5729

Merged
openshift-merge-bot[bot] merged 4 commits into
redhat-developer:mainfrom
gustavolira:fix/e2e-coverage-downstream-upstream-sha
Oct 28, 2026
Merged

openshift-merge-bot[bot] merged 4 commits into
redhat-developer:mainfrom
gustavolira:fix/e2e-coverage-downstream-upstream-sha

Conversation

@gustavolira

@gustavolira gustavolira commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Description

Follow-up to #5702. The first main OCP Helm nightly after it merged (run 2114775302033903616) collected E2E coverage but skipped the Codecov upload in all four projects:

⚠ Could not confirm that main contains image revision 30c68de271c560e7735276361d55904fb06e202c
ℹ Run did not test a PR image or a main build (TAG_NAME=next) — skipping Codecov upload

That nightly deploys quay.io/rhdh/rhdh-hub-rhel10:next, a Konflux build. Its org.opencontainers.image.revision label names the GitLab midstream commit, which does not exist on GitHub, so the on-main check fails. The upstream commit is still in the image: the downstream build writes it into the app's build metadata, which is minified into a bundle chunk:

"Upstream":"https://github.com/redhat-developer/rhdh/tree/main @ aa87c991",
"Midstream":"https://gitlab.cee.redhat.com/rhidp/rhdh/-/commits/main @ c4eb3cda"

Changes

  • testing::_coverage_main_commit still tries the revision label first (that is correct for the community image). When the label is not on main, it greps redhat-developer/rhdh/tree/main ?@ ?<sha> from /opt/app-root/src/packages/app/dist in a running RHDH container (oc exec), taking sort -u | head -1 of the matches. It then expands the short sha from the checkout or the GitHub commits API and checks that main contains it.
  • The pod listing is now oc get pods -o json | jq … @tsv, one line per container that runs the image. Containers with an empty imageID (still pulling) are dropped, so they do not count as a second digest. The exec targets a running container in a pod that is not being deleted, never a sidecar.
  • Each way the fallback can come up empty logs its own reason: oc exec failed (exit status, stderr at debug level), the metadata names no main commit, GitHub did not return the short sha, or GitHub answered with non-JSON. oc exec needs pods/exec in the test namespace, a new permission for this job.
  • When the fallback is used, a log line names the label and the upstream commit it replaced.
  • The coverage doc describes the Konflux case.

The fallback does not use the checkout's HEAD: next can lag main, so HEAD may not be the commit that was tested.

Testing

  • yarn test:unit in e2e-tests: 287 passed, 1 skipped. yarn shellcheck, yarn fmt:check and the .ci Prettier config are clean; yarn lint reports only the existing kube-client/index.ts error that main also has.
  • New cases for midstream-labelled images: upload to the upstream commit, short sha expanded through GitHub, upstream commit not on main, metadata naming another repository, branch or a too-short sha, four metadata shapes (no space after the colon, no spaces around @, a suffix, another key), chunks naming two commits, a refused oc exec, a moved bundle, three GitHub failures, terminating and waiting replicas. A replica still pulling the image (empty imageID on the RHDH container) no longer blocks the upload. The fake oc get pods emits real pod JSON, so the jq filter runs; the fake oc exec runs the real grep against a fake bundle.
  • Each guard was mutated and its test seen failing: the empty-imageID filter, the terminating and running checks, the old strict regex, sort -u, the exec-failure branch, and the two GitHub messages.
  • Ran the new grep -rhoE in the real quay.io/rhdh/rhdh-hub-rhel10:next (GNU grep 3.11): it extracts the upstream sha from the bundle and matches the metadata mutations listed above.

Jira: RHIDP-13242

🤖 Generated with Claude Code

…rage

The main OCP Helm nightly deploys quay.io/rhdh/rhdh-hub-rhel10:next, a
Konflux build whose org.opencontainers.image.revision label names the
GitLab midstream commit. GitHub does not know that commit, so the on-main
check failed and every project skipped its Codecov upload:

  Could not confirm that main contains image revision 30c68de...

The downstream build writes the upstream commit into the app's
build-metadata.json ("Upstream": ".../tree/main @ <short sha>"). When the
label is not on main, testing::_coverage_main_commit now greps that entry
from the bundle in the pod running the image (oc exec), expands the short
sha from the checkout or the GitHub API, and checks it is on main. The
community image keeps using its label, which names the upstream commit.

The pod listing now carries pod and container names so the exec targets
the container that runs the image. The tests' fake oc runs the real grep
against a fake bundle, so the pattern itself is covered.

RHIDP-13242

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gustavo Lira e Silva <guga.java@gmail.com>
@openshift-ci
openshift-ci Bot requested review from benwilcock and rostalan October 26, 2026 23:36
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.00%. Comparing base (aa87c99) to head (6fa7cc7).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5729      +/-   ##
==========================================
- Coverage   75.70%   69.00%   -6.70%     
==========================================
  Files          65       58       -7     
  Lines         708      555     -153     
  Branches      100       83      -17     
==========================================
- Hits          536      383     -153     
  Misses        171      171              
  Partials        1        1              
Flag Coverage Δ
rhdh 69.00% <ø> (-6.70%) ⬇️
Components Coverage Δ
Backend plugins ∅ <ø> (∅)
Backend app 78.94% <ø> (ø)
Frontend app 61.03% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa87c99...6fa7cc7. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

gustavolira and others added 2 commits October 26, 2026 20:38
Without it, the upload line names a sha with nothing saying it came from
the bundle rather than the image label, which makes a wrong attribution
hard to trace back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gustavo Lira e Silva <guga.java@gmail.com>
Review fixes for the build-metadata fallback:

- The per-pod jsonpath put every container on one line and awk read it in
  groups of three. A container waiting for its image has an empty imageID,
  awk collapsed the gap, and the groups shifted: the RHDH container was
  dropped or a container name was inspected as a digest. The listing is
  now `oc get pods -o json | jq ... @tsv`, one line per container, and the
  test fake emits real pod JSON so the filter itself is exercised.
- The default test pod lists a sidecar before the RHDH container, so a
  read of the wrong container fails the exec-target assertion.
- The skip warning and the fallback info line say the label is "not
  confirmed on main": a GitHub outage also lands there, not only a commit
  outside main.
- The Upstream grep tolerates a space after the colon.
- _build_metadata_upstream echoes the rev-parse result explicitly, and its
  Args list one argument per line like the rest of lib/.
- Doc: one skip condition instead of two overlapping ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gustavo Lira e Silva <guga.java@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

The container image build workflow finished with status: cancelled.

@github-actions

Copy link
Copy Markdown
Contributor

Image was built and published successfully. It is available at:

@gashcrumb gashcrumb left a comment

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.

Thanks. I checked the premise before the diff: skopeo inspect on quay.io/rhdh/rhdh-hub-rhel10:next shows org.opencontainers.image.revision and vcs-ref both naming the GitLab midstream sha. The image carries no upstream label, so reading the app's build metadata is the right call rather than a shortcut. The jq … @tsv listing and the extra log line both read well.

I'm requesting a change on one point. A pod that carries the image with an empty imageID still suppresses the upload for the whole project (first inline), and the test that claims to cover that case never reaches it (second inline). The other inlines are suggestions: the metadata scrape being tied to a string outside this repo, how the failures will read in a nightly log, and two doc inaccuracies.

Three small things as well. The new docstring omits the # RHIDP-13242: tag that its three neighbours carry. _build_metadata_upstream reads $1 $2 $3 inline where every sibling names its arguments first.

Comment thread .ci/pipelines/lib/testing.sh
Comment thread e2e-tests/unit/e2e-coverage-upload.test.ts Outdated
Comment thread .ci/pipelines/lib/testing.sh Outdated
Comment thread .ci/pipelines/lib/testing.sh Outdated
Comment thread docs/coverage/e2e-rhdh.md Outdated
Address review on the Konflux upstream-commit fallback:

- Drop containers with an empty imageID from the pod listing, so a
  replica still pulling the image no longer counts as a second digest
  and suppresses the upload.
- Exec only into a running container of a pod that is not being
  deleted.
- Match `redhat-developer/rhdh/tree/main ?@ ?<sha>` anywhere in the
  bundle instead of the exact "Upstream" entry, and pick the sha with
  `sort -u | head -1` so the result does not depend on readdir order.
- Log why the fallback found nothing: a failed `oc exec` (exit status,
  stderr at debug level), metadata naming no main commit, GitHub not
  returning the short sha, or GitHub answering with non-JSON.
- Name `_build_metadata_upstream` arguments and tag it RHIDP-13242.
- Docs: the metadata lives in the minified bundle, the image is the one
  the job deploys, and the short sha is expanded through the checkout.

Tests now put the empty imageID on the RHDH container and cover each
log message, metadata shape and pod state; each fails when its guard is
mutated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Image was built and published successfully. It is available at:

@gashcrumb gashcrumb left a comment

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.

Verified against 6fa7cc7. select(.imageID != "") keeps a pulling replica out of the listing, and the replacement test puts the empty imageID on a replica that is still pulling and asserts the upload proceeds. That is the case the old test never reached. The deletionTimestamp and state.running columns also close the hole where oc exec could land on a terminating pod.

The scrape no longer depends on the "Upstream" key or the exact spacing, and tree/release-2.1 is now a negative case, which is what makes the wider pattern safe. Failure logging separates an unreadable bundle, a grep miss, a failed GitHub call, and a non-JSON response, which is what the nightly log needed. Docs read correctly now too.

One thing is still worth doing outside this diff: confirm pods/exec on the test clusters for the job's service account. That path only runs in the nightly, so nothing here exercises the permission.

@openshift-ci openshift-ci Bot added the lgtm label Oct 28, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit 1bc3f63 into redhat-developer:main Oct 28, 2026
31 checks passed
openshift-merge-bot Bot pushed a commit that referenced this pull request Oct 28, 2026
* fix(ci): tell a missing build-metadata entry from a failed read

testing::_build_metadata_upstream treated exit 1 with empty stderr as
"grep matched nothing". That only holds for a local grep: oc exec writes
"command terminated with exit code 1" to stderr whenever the remote command
exits non-zero. On a real cluster, a bundle without the metadata entry, or
one that names another repository or branch, was logged as "Could not read
the build metadata (exit 1)", which points at permissions or the path. The
"names no redhat-developer/rhdh main commit" branch never ran. The upload was
skipped in both cases. Only the reason in the log was wrong.

grep now runs under sh -c in the container, which folds its no-match exit 1
into 0. Any non-zero exit from oc exec is then a failed read. The fake oc in
the unit tests now reports a failed remote command on stderr the way oc does.
With that change, the three "names another repository/branch/a sha too short"
cases fail against the old code.

The "no space after the colon" case replaced '": "' in a fixture that has no
such text, so it repeated the base case. It now adds a space after the
colon, and every metadata-shape case asserts that its variant differs from
the base fixture.

Follow-up to #5729.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(ci): note that the build-metadata read needs a shell in the image

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants