← Back to Pull requests

ROX-37477: Add hack/resolve-konflux-images.sh for Konflux CI image resolution #1479

Open
redhat-chai-bot opened this pull request with 739 lines diff across 3 files
View on GitHub
redhat-chai-bot redhat-chai-bot commented on Oct 09, 2026 19:43 UTC
Author

Summary

hack/resolve-konflux-images.sh prints the Konflux build of each component that a CI job should test with, so the e2e jobs can use Konflux's builds instead of building the images in Prow (ROX-37477, about 10 minutes per job). openshift/release#86580 will call it from each e2e job:

IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
OPENSCAP_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-openscap-dev)
MUST_GATHER_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-must-gather-dev)

The same commands work on release branches.

How it picks the image

The same rule applies to every component:

  • If the PR changes a file that the component's .tekton pull-request pipeline watches (its "<pattern>".pathChanged() list, which is what Konflux checks before it builds), the job uses the PR's own build, on-pr-<head>.

  • Otherwise the job uses the push build of the newest base commit that changed such a file. That build is the image the base has.
  • The image repository is the one in the pipeline's output-image. The script reads the pipelines from git at the PR head and at the base, the same commits Pipelines as Code reads them from. It waits up to KONFLUX_WAIT_SECONDS (default 300) for the build, then fails if Quay doesn't have it. It never falls back to another image, such as :master, so a job can't pass on an image that doesn't match the code it tests.

    It also fails, rather than guessing, on:

  • triggers or patterns it can't match the way Konflux does, and triggers for another branch;

  • batch jobs;

  • commits that a shallow clone lacks;

  • a Quay outage, so that it can't look like a missing build.
  • Release branches

    Jobs name components as master does. On a release branch (PULL_BASE_REF), the script uses that branch's component instead: on release-1.10, compliance-operator-dev is compliance-operator-release-1-10, with that branch's pipelines and the repository they push to, compliance-operator-release. Rehearsals and local runs, which have no PULL_BASE_REF for this repository, use the branch that the base's push pipelines build, and KONFLUX_BRANCH overrides both. So a release branch's ci-operator config can run the same commands once the script is backported there. Prow runs no jobs on this repository's release branches today.

    Notes for reviewers

  • PRs from outside the organization: Konflux waits for /ok-to-test before building them. Until someone comments it, their e2e jobs fail with a message saying so, instead of testing another operator image.

  • Build time: arm64 is the slowest platform. In the last 68 operator PR builds it took 15 minutes at the median (x86-64: 5), and a whole build 17, up to 32. Once #86580 drops the Prow image builds, the test step starts 46 to 72 minutes into the job. So the wait only matters when Konflux queues builds, as it does for the weekly references PR in its Saturday batch: there the 5-minute wait covered 2 of the 4 sampled runs.

  • Failed push builds: the script never falls back, so a base whose newest push build failed fails its jobs until someone reruns that build. On release-1.9, two openscap push builds never finished, so 8 of its 45 commits can't be tested.
  • Testing

  • Test suite: hack/test-resolve-konflux-images.sh has 47 cases. It runs the script against a fake Quay in scratch repositories, one of them with a release branch. It also runs it on this repository's own pipelines and history, and on its newest release branch when the clone has one. make test-unit runs it, so the unit job does too. shellcheck is clean.

  • Deliberate breaks: of 31 breaks to the script, the suite catches 30. They include:

  • - falling back to :master, ignoring PULL_BASE_REF, and assuming the repository is the component's name;
    - skipping the trigger's branch check;
    - dropping --first-parent, and diffing against the base instead of the merge base;
    - an off-by-one wait, and accepting expired tags;
    - piping git show into grep -m1, where git can die of SIGPIPE and pipefail reports that as a failure.

    The one it misses, dropping --diff-merges=first-parent, changes nothing in current git, because --first-parent implies it.

  • Real data (read-only, from the Quay tag API and git history):

  • - master, newest 40 commits:
    - push decisions match Konflux's builds in 120 of 120 cases;
    - the builds the script picks exist for 39 of the 40 commits. Konflux's push build of #1492 never finished (no ppc64le image), so on that commit the script fails rather than use an older image.
    - master, 50 most recent PRs that Konflux built: PR decisions match the pipelines Konflux ran in 200 of 200 cases.
    - release-1.10, all 18 commits and 36 PRs since the branch was cut:
    - 51 of 54 push decisions match. The other 3 are builds that started minutes after the push without a watched change, most likely by hand;
    - every commit resolves to images on Quay;
    - PR decisions match in 144 of 144 cases.
    - release-1.9, 45 commits and 63 PRs:
    - 134 of 135 push decisions and 248 of 252 PR decisions match;
    - the other 4 PR cases are one stale bot PR whose head predates the branch's pipelines. Konflux built nothing for it, and the script fails.

    Generated with Claude Code

    [ROX-37477]: https://redhat.atlassian.net/browse/ROX-37477?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 739 lines (+738 / -1) across 3 files Reviewer: Vincent056 Review duration: 78013m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.52) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 739 lines diff across 3 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.92 · 5 substantive comment(s)
    0.92
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    89%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.395
    Real PR Conversation Timeline
    30 items
    openshift-ci[bot] openshift-ci[bot] commented on Oct 09, 2026 19:43 UTC
    Bot

    Hi @redhat-chai-bot. Thanks for your PR.

    I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

    >[!TIP]
    >We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

    Once the patch is verified, the new status will be reflected by the ok-to-test label.

    I understand the commands that are listed here.

    <details>

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
    </details>

    github-actions[bot] github-actions[bot] commented on Oct 09, 2026 19:51 UTC
    Bot

    :robot: To deploy this PR, run the following command:

    make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-9e6b922b5259a881360f3a839fa8ce54e575ac25
    

    Vincent056 Vincent056 commented on Oct 14, 2026 20:52 UTC
    Contributor

    /ok-to-test

    github-actions[bot] github-actions[bot] commented on Oct 14, 2026 20:56 UTC
    Bot

    :robot: To deploy this PR, run the following command:

    make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-746307d3bcf6a05481cf0208fb8f0c847735fe0b
    

    redhat-chai-bot redhat-chai-bot commented on Oct 14, 2026 23:46 UTC
    Author

    /retest-required

    Vincent056 Vincent056 commented on Oct 15, 2026 04:23 UTC
    Contributor

    The failing checks here aren't caused by this PR's change. It only adds hack/resolve-konflux-images.sh, which no job runs yet.

  • ci/prow/e2e-aws-serial failed twice (first run, rerun) in TestStrictNodeScanConfiguration, which expected NON-COMPLIANT and got INCONSISTENT. Both times, the test before it, TestRuntimeSSHConfigWithRemediation, waited the full 25 minutes for its SSH remediation's MachineConfig to leave the e2e pool, and only logged the timeout. The same failure followed the same timeout on #1116, #721 and #1399, all on the same master commit (e5e873f20), and none of the passing serial runs had the timeout. The fix belongs in the serial suite on master.

  • The two Trivy scans fail on every PR, from master's dependencies: golang.org/x/crypto, x/mod and x/net in go.mod, and the Go 1.25.14 standard library in the image.

  • check-title fails because the title doesn't start with a Jira key. That's fixed by retitling, not by a code change.
  • Vincent056 Vincent056 commented on Oct 15, 2026 04:23 UTC
    Contributor

    /lgtm

    rhmdnd rhmdnd commented on code on Oct 16, 2026 13:59 UTC
    Code Review
    hack/resolve-konflux-images.sh:1
    @@ -0,0 +1,81 @@
    +#!/bin/bash
    +# resolve-konflux-images.sh — Print the Konflux builds of images to test with.
    +#
    +#   hack/resolve-konflux-images.sh <component>...
    +#
    +# For each Konflux component, such as compliance-operator-dev, this prints the
    +# pull spec of its build for the PR's head commit, waiting up to 5 minutes
    +# while Konflux finishes it. Konflux builds an image only for PRs that change
    +# its sources, so when it hasn't started a build for the PR, this prints the
    +# master build, which has the same sources. It fails rather than print another
    +# image when the PR's build has expired or doesn't finish in time, or when
    +# Quay can't be reached.
    +#
    +# CI jobs test with these images instead of having Prow build them before the
    +# cluster install starts:
    +#
    +#   IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
    +#   OPENSCAP_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-openscap-dev)
    +#
    +# Jobs for other repositories can run it from GitHub:
    +#
    +#   curl -fsSL https://raw.githubusercontent.com/ComplianceAsCode/compliance-operator/master/hack/resolve-konflux-images.sh |
    +#     bash -s -- compliance-operator-dev
    +#
    +# Environment:
    +#   KONFLUX_REPO  the Quay repository of the components (default:
    +#                 DEFAULT_KONFLUX_REPO in the Makefile)
    +#   KONFLUX_SHA   the commit to find the builds of (default: PULL_PULL_SHA,
    +#                 which Prow sets to the PR's head commit). Without one, the
    +#                 master builds are printed.
    +
    +set -euo pipefail
    +
    +repo=${KONFLUX_REPO:-quay.io/redhat-user-workloads/ocp-isc-tenant}
    +sha=${KONFLUX_SHA:-${PULL_PULL_SHA:-}}
    +
    +if [[ $# -eq 0 ]]; then
    +  echo "usage: $0 <component>..." >&2
    +  exit 2
    +fi
    +if [[ $repo != quay.io/* ]]; then
    +  echo "KONFLUX_REPO must be on quay.io: $repo" >&2
    +  exit 2
    +fi
    +
    +# has <component> <tag> [active]: whether Quay has the tag, or ever had it.
    +# It exits when Quay can't be reached, so that an outage doesn't look like a
    +# missing build.
    +has() {
    +  local out
    +  out=$(curl -fsS --max-time 30 --retry 5 --retry-all-errors \
    +    "https://quay.io/api/v1/repository/${repo#quay.io/}/$1/tag/?specificTag=$2${3:+&onlyActiveTags=true}") || {
    +    echo "Could not get the tags of $repo/$1 from Quay" >&2
    +    exit 1
    +  }
    +  [[ $out == *'"name"'* ]]
    +}
    +
    +# resolve <component>: print the build of the component to test with.
    +resolve() {
    +  local tag=on-pr-$sha delay
    +  # A Konflux build stores its source at <tag>.git when it starts.
    +  if [[ -n $sha ]] && has "$1" "$tag.git"; then
    +    # Retry with backoff for up to 5 minutes while the build finishes.
    +    for delay in 10 20 40 80 150 0; do

    I wonder if this is going to be long enough. It's possible the build takes longer than 5 minutes, then two minutes after the run fails the Konflux images are ready.

    ARM64 builds take the longest, it's not uncommon for them to take more than 15 minutes (I've seen this in other projects building on Konflux, too).

    Can we budget ~30 min for the operator component? Also worth noting the same "has not built after 5 minutes" message is emitted when a build fails, so a red PipelineRun is indistinguishable from a slow one.

    rhmdnd rhmdnd requested changes on Oct 16, 2026 17:37 UTC
    Changes Requested Reviewer

    I have a feeling we'll need to account for longer ARM builds. But otherwise I think this is on the right track.

    openshift-ci[bot] openshift-ci[bot] commented on Oct 16, 2026 17:42 UTC
    Bot

    [APPROVALNOTIFIER] This PR is NOT APPROVED

    This pull-request has been approved by: <a href="https://github.com/ComplianceAsCode/compliance-operator/pull/1479#" title="Author self-approved">redhat-chai-bot</a>
    Once this PR has been reviewed and has the lgtm label, please ask for approval from rhmdnd. For more information see the Code Review Process.

    The full list of commands accepted by this bot can be found here.

    <details open>
    Needs approval from an approver in each of these files:

  • OWNERS
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":["rhmdnd"]} -->

    redhat-chai-bot redhat-chai-bot commented on code on Oct 16, 2026 17:43 UTC
    Code Review
    hack/resolve-konflux-images.sh:1
    @@ -0,0 +1,81 @@
    +#!/bin/bash
    +# resolve-konflux-images.sh — Print the Konflux builds of images to test with.
    +#
    +#   hack/resolve-konflux-images.sh <component>...
    +#
    +# For each Konflux component, such as compliance-operator-dev, this prints the
    +# pull spec of its build for the PR's head commit, waiting up to 5 minutes
    +# while Konflux finishes it. Konflux builds an image only for PRs that change
    +# its sources, so when it hasn't started a build for the PR, this prints the
    +# master build, which has the same sources. It fails rather than print another
    +# image when the PR's build has expired or doesn't finish in time, or when
    +# Quay can't be reached.
    +#
    +# CI jobs test with these images instead of having Prow build them before the
    +# cluster install starts:
    +#
    +#   IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
    +#   OPENSCAP_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-openscap-dev)
    +#
    +# Jobs for other repositories can run it from GitHub:
    +#
    +#   curl -fsSL https://raw.githubusercontent.com/ComplianceAsCode/compliance-operator/master/hack/resolve-konflux-images.sh |
    +#     bash -s -- compliance-operator-dev
    +#
    +# Environment:
    +#   KONFLUX_REPO  the Quay repository of the components (default:
    +#                 DEFAULT_KONFLUX_REPO in the Makefile)
    +#   KONFLUX_SHA   the commit to find the builds of (default: PULL_PULL_SHA,
    +#                 which Prow sets to the PR's head commit). Without one, the
    +#                 master builds are printed.
    +
    +set -euo pipefail
    +
    +repo=${KONFLUX_REPO:-quay.io/redhat-user-workloads/ocp-isc-tenant}
    +sha=${KONFLUX_SHA:-${PULL_PULL_SHA:-}}
    +
    +if [[ $# -eq 0 ]]; then
    +  echo "usage: $0 <component>..." >&2
    +  exit 2
    +fi
    +if [[ $repo != quay.io/* ]]; then
    +  echo "KONFLUX_REPO must be on quay.io: $repo" >&2
    +  exit 2
    +fi
    +
    +# has <component> <tag> [active]: whether Quay has the tag, or ever had it.
    +# It exits when Quay can't be reached, so that an outage doesn't look like a
    +# missing build.
    +has() {
    +  local out
    +  out=$(curl -fsS --max-time 30 --retry 5 --retry-all-errors \
    +    "https://quay.io/api/v1/repository/${repo#quay.io/}/$1/tag/?specificTag=$2${3:+&onlyActiveTags=true}") || {
    +    echo "Could not get the tags of $repo/$1 from Quay" >&2
    +    exit 1
    +  }
    +  [[ $out == *'"name"'* ]]
    +}
    +
    +# resolve <component>: print the build of the component to test with.
    +resolve() {
    +  local tag=on-pr-$sha delay
    +  # A Konflux build stores its source at <tag>.git when it starts.
    +  if [[ -n $sha ]] && has "$1" "$tag.git"; then
    +    # Retry with backoff for up to 5 minutes while the build finishes.
    +    for delay in 10 20 40 80 150 0; do

    Addressed both points:

    1. Extended the timeout to ~30 minutes. The retry loop now starts with short backoff intervals (10, 20, 40 seconds) for quick builds, then settles into 60-second polling until 1800 seconds (~30 min) have elapsed. That should comfortably cover the 15+ minute ARM64 builds.

    2. Distinct error messages for slow vs failed builds. After the timeout, the script checks whether the .git tag is still active:
    - Still active → "Konflux is still building … after 30 minutes; the PipelineRun may be unusually slow — check its status"
    - No longer active → "Konflux build of … appears to have failed (PipelineRun finished without producing an image)"

    This way a genuinely slow PipelineRun and a red one produce different diagnostics.

    ---
    AI-generated. Review for accuracy.

    redhat-chai-bot redhat-chai-bot commented on code on Oct 16, 2026 17:43 UTC
    Code Review
    hack/resolve-konflux-images.sh:1
    @@ -0,0 +1,81 @@
    +#!/bin/bash
    +# resolve-konflux-images.sh — Print the Konflux builds of images to test with.
    +#
    +#   hack/resolve-konflux-images.sh <component>...
    +#
    +# For each Konflux component, such as compliance-operator-dev, this prints the
    +# pull spec of its build for the PR's head commit, waiting up to 5 minutes
    +# while Konflux finishes it. Konflux builds an image only for PRs that change
    +# its sources, so when it hasn't started a build for the PR, this prints the
    +# master build, which has the same sources. It fails rather than print another
    +# image when the PR's build has expired or doesn't finish in time, or when
    +# Quay can't be reached.
    +#
    +# CI jobs test with these images instead of having Prow build them before the
    +# cluster install starts:
    +#
    +#   IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
    +#   OPENSCAP_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-openscap-dev)
    +#
    +# Jobs for other repositories can run it from GitHub:
    +#
    +#   curl -fsSL https://raw.githubusercontent.com/ComplianceAsCode/compliance-operator/master/hack/resolve-konflux-images.sh |
    +#     bash -s -- compliance-operator-dev
    +#
    +# Environment:
    +#   KONFLUX_REPO  the Quay repository of the components (default:
    +#                 DEFAULT_KONFLUX_REPO in the Makefile)
    +#   KONFLUX_SHA   the commit to find the builds of (default: PULL_PULL_SHA,
    +#                 which Prow sets to the PR's head commit). Without one, the
    +#                 master builds are printed.
    +
    +set -euo pipefail
    +
    +repo=${KONFLUX_REPO:-quay.io/redhat-user-workloads/ocp-isc-tenant}
    +sha=${KONFLUX_SHA:-${PULL_PULL_SHA:-}}
    +
    +if [[ $# -eq 0 ]]; then
    +  echo "usage: $0 <component>..." >&2
    +  exit 2
    +fi
    +if [[ $repo != quay.io/* ]]; then
    +  echo "KONFLUX_REPO must be on quay.io: $repo" >&2
    +  exit 2
    +fi
    +
    +# has <component> <tag> [active]: whether Quay has the tag, or ever had it.
    +# It exits when Quay can't be reached, so that an outage doesn't look like a
    +# missing build.
    +has() {
    +  local out
    +  out=$(curl -fsS --max-time 30 --retry 5 --retry-all-errors \
    +    "https://quay.io/api/v1/repository/${repo#quay.io/}/$1/tag/?specificTag=$2${3:+&onlyActiveTags=true}") || {
    +    echo "Could not get the tags of $repo/$1 from Quay" >&2
    +    exit 1
    +  }
    +  [[ $out == *'"name"'* ]]
    +}
    +
    +# resolve <component>: print the build of the component to test with.
    +resolve() {
    +  local tag=on-pr-$sha delay
    +  # A Konflux build stores its source at <tag>.git when it starts.
    +  if [[ -n $sha ]] && has "$1" "$tag.git"; then
    +    # Retry with backoff for up to 5 minutes while the build finishes.
    +    for delay in 10 20 40 80 150 0; do

    Good call — Vincent's follow-up commit (2d6fb1c) addresses this:

  • Timeout is now 30 minutes (fast backoff of 10/20/40s, then 60s polling up to 1800s total)

  • Slow builds are now distinguishable from failed ones: if the .git tag is still active after 30 min, the message says the PipelineRun may be unusually slow; if it's gone, it says the build appears to have failed without producing an image
  • The script also changed from being sourced to being a standalone executable that accepts component names as arguments.

    ---
    AI-generated. Review for accuracy.

    redhat-chai-bot redhat-chai-bot commented on Oct 16, 2026 17:43 UTC
    Author

    /retest-required

    github-actions[bot] github-actions[bot] commented on Oct 16, 2026 17:49 UTC
    Bot

    :robot: To deploy this PR, run the following command:

    make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-2d6fb1c9857166798cf1a5451c82e8d9d6fde246
    

    redhat-chai-bot redhat-chai-bot commented on code on Oct 16, 2026 18:17 UTC
    Code Review
    hack/resolve-konflux-images.sh:1
    @@ -0,0 +1,81 @@
    +#!/bin/bash
    +# resolve-konflux-images.sh — Print the Konflux builds of images to test with.
    +#
    +#   hack/resolve-konflux-images.sh <component>...
    +#
    +# For each Konflux component, such as compliance-operator-dev, this prints the
    +# pull spec of its build for the PR's head commit, waiting up to 5 minutes
    +# while Konflux finishes it. Konflux builds an image only for PRs that change
    +# its sources, so when it hasn't started a build for the PR, this prints the
    +# master build, which has the same sources. It fails rather than print another
    +# image when the PR's build has expired or doesn't finish in time, or when
    +# Quay can't be reached.
    +#
    +# CI jobs test with these images instead of having Prow build them before the
    +# cluster install starts:
    +#
    +#   IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
    +#   OPENSCAP_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-openscap-dev)
    +#
    +# Jobs for other repositories can run it from GitHub:
    +#
    +#   curl -fsSL https://raw.githubusercontent.com/ComplianceAsCode/compliance-operator/master/hack/resolve-konflux-images.sh |
    +#     bash -s -- compliance-operator-dev
    +#
    +# Environment:
    +#   KONFLUX_REPO  the Quay repository of the components (default:
    +#                 DEFAULT_KONFLUX_REPO in the Makefile)
    +#   KONFLUX_SHA   the commit to find the builds of (default: PULL_PULL_SHA,
    +#                 which Prow sets to the PR's head commit). Without one, the
    +#                 master builds are printed.
    +
    +set -euo pipefail
    +
    +repo=${KONFLUX_REPO:-quay.io/redhat-user-workloads/ocp-isc-tenant}
    +sha=${KONFLUX_SHA:-${PULL_PULL_SHA:-}}
    +
    +if [[ $# -eq 0 ]]; then
    +  echo "usage: $0 <component>..." >&2
    +  exit 2
    +fi
    +if [[ $repo != quay.io/* ]]; then
    +  echo "KONFLUX_REPO must be on quay.io: $repo" >&2
    +  exit 2
    +fi
    +
    +# has <component> <tag> [active]: whether Quay has the tag, or ever had it.
    +# It exits when Quay can't be reached, so that an outage doesn't look like a
    +# missing build.
    +has() {
    +  local out
    +  out=$(curl -fsS --max-time 30 --retry 5 --retry-all-errors \
    +    "https://quay.io/api/v1/repository/${repo#quay.io/}/$1/tag/?specificTag=$2${3:+&onlyActiveTags=true}") || {
    +    echo "Could not get the tags of $repo/$1 from Quay" >&2
    +    exit 1
    +  }
    +  [[ $out == *'"name"'* ]]
    +}
    +
    +# resolve <component>: print the build of the component to test with.
    +resolve() {
    +  local tag=on-pr-$sha delay
    +  # A Konflux build stores its source at <tag>.git when it starts.
    +  if [[ -n $sha ]] && has "$1" "$tag.git"; then
    +    # Retry with backoff for up to 5 minutes while the build finishes.
    +    for delay in 10 20 40 80 150 0; do

    Reverting this timeout recommendation per discussion with @Vincent056:

    The resolve-konflux-images.sh script runs after the test cluster is up and running — it's invoked right before the make e2e target, not during the image-build / cluster-provisioning phase. Since cluster provisioning takes 40–50 minutes, the Konflux images (including ARM64) will already be built and available on Quay by the time the script executes. The 5-minute backoff in the original version is more than sufficient as a safety net.

    The 30-minute timeout and the slow-vs-failed build distinction I pushed earlier can be reverted back to the original shorter timeout.

    ---
    AI-generated. Review for accuracy.

    ---
    AI-generated. Review for accuracy.

    github-actions[bot] github-actions[bot] commented on Oct 16, 2026 18:32 UTC
    Bot

    :robot: To deploy this PR, run the following command:

    make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-39592030b1937058e773f21f6dd47c565e8c6baa
    

    rhmdnd rhmdnd commented on code on Oct 16, 2026 18:37 UTC
    Code Review
    hack/resolve-konflux-images.sh:1
    @@ -0,0 +1,97 @@
    +#!/bin/bash
    +# resolve-konflux-images.sh — Print the Konflux builds of images to test with.
    +#
    +#   hack/resolve-konflux-images.sh <component>...
    +#
    +# For each Konflux component, such as compliance-operator-dev, this prints the
    +# pull spec of its build for the PR's head commit, waiting up to 5 minutes
    +# while Konflux finishes it. Konflux builds an image only for PRs that change
    +# its sources, so when it hasn't started a build for the PR, this prints the
    +# master build, which has the same sources. It fails rather than print another
    +# image when the PR's build has expired or doesn't finish in time, or when
    +# Quay can't be reached.
    +#
    +# CI jobs test with these images instead of having Prow build them before the
    +# cluster install starts:
    +#
    +#   IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
    +#   OPENSCAP_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-openscap-dev)
    +#
    +# Jobs for other repositories can run it from GitHub:
    +#
    +#   curl -fsSL https://raw.githubusercontent.com/ComplianceAsCode/compliance-operator/master/hack/resolve-konflux-images.sh |
    +#     bash -s -- compliance-operator-dev
    +#
    +# Environment:
    +#   KONFLUX_REPO  the Quay repository of the components (default:
    +#                 DEFAULT_KONFLUX_REPO in the Makefile)
    +#   KONFLUX_SHA   the commit to find the builds of (default: PULL_PULL_SHA,
    +#                 which Prow sets to the PR's head commit). Without one, the
    +#                 master builds are printed.
    +
    +set -euo pipefail
    +
    +repo=${KONFLUX_REPO:-quay.io/redhat-user-workloads/ocp-isc-tenant}
    +sha=${KONFLUX_SHA:-${PULL_PULL_SHA:-}}
    +
    +if [[ $# -eq 0 ]]; then
    +  echo "usage: $0 <component>..." >&2
    +  exit 2
    +fi
    +if [[ $repo != quay.io/* ]]; then
    +  echo "KONFLUX_REPO must be on quay.io: $repo" >&2
    +  exit 2
    +fi
    +
    +# has <component> <tag> [active]: whether Quay has the tag, or ever had it.
    +# It exits when Quay can't be reached, so that an outage doesn't look like a
    +# missing build.
    +has() {
    +  local out
    +  out=$(curl -fsS --max-time 30 --retry 5 --retry-all-errors \
    +    "https://quay.io/api/v1/repository/${repo#quay.io/}/$1/tag/?specificTag=$2${3:+&onlyActiveTags=true}") || {
    +    echo "Could not get the tags of $repo/$1 from Quay" >&2
    +    exit 1
    +  }
    +  [[ $out == *'"name"'* ]]
    +}
    +
    +# resolve <component>: print the build of the component to test with.
    +resolve() {
    +  local tag=on-pr-$sha
    +  # A Konflux build stores its source at <tag>.git when it starts.
    +  if [[ -n $sha ]] && has "$1" "$tag.git"; then
    +    # Retry with backoff for up to 5 minutes while the build finishes.
    +    local elapsed=0 delay
    +    for delay in 10 20 40; do
    +      has "$1" "$tag" active && { echo "$repo/$1:$tag"; return; }
    +      has "$1" "$tag.git" active || {
    +        echo "$repo/$1:$tag has expired: /test $1-on-pull-request rebuilds it" >&2
    +        exit 1
    +      }
    +      sleep "$delay"
    +      elapsed=$((elapsed + delay))
    +    done
    +    while [[ $elapsed -lt 300 ]]; do
    +      has "$1" "$tag" active && { echo "$repo/$1:$tag"; return; }
    +      has "$1" "$tag.git" active || {
    +        echo "$repo/$1:$tag has expired: /test $1-on-pull-request rebuilds it" >&2
    +        exit 1
    +      }
    +      sleep 60
    +      elapsed=$((elapsed + 60))
    +    done
    +    # Distinguish a slow build (PipelineRun still active) from a failed one.
    +    if has "$1" "$tag.git" active; then
    +      echo "Konflux is still building $repo/$1:$tag after 5 minutes; the PipelineRun may be unusually slow — check its status" >&2
    +    else
    +      echo "Konflux build of $repo/$1:$tag appears to have failed (PipelineRun finished without producing an image)" >&2
    +    fi
    +    exit 1
    +  fi
    +  echo "$repo/$1:master"

    This won't make sense on release branches (e.g., release-1.11). In those cases, the images would resolve to master instead of the latest images on the release branch.

    Also worth noting the release branches publish to different repos (compliance-operator-release, compliance-operator-openscap-release, compliance-operator-must-gather-release), and those have no master tag. Their floating tag is {{ target_branch }} (e.g. :release-1.10). So depending on which component name the job passes, this is either silently-wrong images or an ImagePullBackOff. Can we use PULL_BASE_REF here?

    github-actions[bot] github-actions[bot] commented on Oct 16, 2026 22:52 UTC
    Bot

    :robot: To deploy this PR, run the following command:

    make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-b1a946373073ad67f96fb646dc859eed6cc3a306
    

    github-actions[bot] github-actions[bot] commented on Oct 18, 2026 04:54 UTC
    Bot

    :robot: To deploy this PR, run the following command:

    make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-47bad340f489890a6791662bcff7daefd8e256d8
    

    openshift-ci-robot openshift-ci-robot commented on Oct 21, 2026 00:04 UTC
    Contributor

    @redhat-chai-bot: This pull request references ROX-37477 which is a valid jira issue.

    Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.1.0" version, but no target version was set.

    <details>

    In response to this:

    >## Summary

    >hack/resolve-konflux-images.sh prints the Konflux build of each component that a CI job should test with, so the e2e jobs can use Konflux's builds instead of building the images in Prow (ROX-37477, about 10 minutes per job). openshift/release#86580 will call it from each e2e job:

    >
    >IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
    >OPENSCAP_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-openscap-dev)
    >MUST_GATHER_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-must-gather-dev)
    >

    >## How it picks the image

    >The same rule applies to every component:

    >- If the PR changes a file that the component's .tekton pull-request pipeline watches (its "<pattern>".pathChanged() list, which is what Konflux checks before it builds), the job uses the PR's own build, on-pr-<head>.

    >- Otherwise the job uses the push build of the newest base commit that changed such a file. That build is the image the base has.
    >The script reads the triggers from git at the PR head and at the base, the same commits Pipelines as Code reads them from. It waits up to KONFLUX_WAIT_SECONDS (default 300) for the build, then fails if Quay doesn't have it. It never falls back to another image, so a job can't pass on an image that doesn't match the code it tests.

    >It also fails, rather than guessing, on:

    >- triggers or patterns it can't match the way Konflux does;
    >- batch jobs;
    >- commits that a shallow clone lacks;
    >- a Quay outage, so that it can't look like a missing build.
    >## Notes for reviewers

    >- PRs from outside the organization: Konflux waits for /ok-to-test before building them. Until someone comments it, their e2e jobs fail with a message saying so, instead of testing another operator image.

    >- Build time: in recent runs, operator PR builds took 16 to 33 minutes (median 17). The e2e test step starts about 77 minutes after the push, so the 5-minute wait rarely comes into play.
    >- Release branches: Prow runs this repository's presubmits only on master. On a branch whose .tekton files have other names, the script fails rather than guessing.
    >## Testing

    >- Test suite: hack/test-resolve-konflux-images.sh has 35 cases. It runs the script against a fake Quay in scratch repositories, and on this repository's own pipelines and history. make test-unit runs it, so the unit job does too. shellcheck is clean.

    >- Deliberate breaks: of 20 breaks to the script, the suite catches 19. The breaks include falling back to :master, dropping --first-parent, diffing against the base instead of the merge base, an off-by-one wait, and accepting expired tags. The one it misses, dropping --diff-merges=first-parent, changes nothing in current git, because --first-parent implies it.
    >- Real data (read-only):
    - For master's newest 40 commits, every build the script picks exists on Quay, and its push decisions match Konflux's builds in all 120 cases.

    - For the 50 most recent master PRs that Konflux built, its PR decisions match the pipelines Konflux ran in all 200 cases.

    >Generated with Claude Code

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

    </details>

    [ROX-37477]: https://redhat.atlassian.net/browse/ROX-37477?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    github-actions[bot] github-actions[bot] commented on Oct 21, 2026 00:06 UTC
    Bot

    :robot: To deploy this PR, run the following command:

    make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-f817e5dc7221ebe8207c7e4a2f2bfb0c6821408e
    

    Vincent056 Vincent056 commented on code on Oct 23, 2026 12:38 UTC
    Code Review
    hack/resolve-konflux-images.sh:1
    @@ -0,0 +1,97 @@
    +#!/bin/bash
    +# resolve-konflux-images.sh — Print the Konflux builds of images to test with.
    +#
    +#   hack/resolve-konflux-images.sh <component>...
    +#
    +# For each Konflux component, such as compliance-operator-dev, this prints the
    +# pull spec of its build for the PR's head commit, waiting up to 5 minutes
    +# while Konflux finishes it. Konflux builds an image only for PRs that change
    +# its sources, so when it hasn't started a build for the PR, this prints the
    +# master build, which has the same sources. It fails rather than print another
    +# image when the PR's build has expired or doesn't finish in time, or when
    +# Quay can't be reached.
    +#
    +# CI jobs test with these images instead of having Prow build them before the
    +# cluster install starts:
    +#
    +#   IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
    +#   OPENSCAP_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-openscap-dev)
    +#
    +# Jobs for other repositories can run it from GitHub:
    +#
    +#   curl -fsSL https://raw.githubusercontent.com/ComplianceAsCode/compliance-operator/master/hack/resolve-konflux-images.sh |
    +#     bash -s -- compliance-operator-dev
    +#
    +# Environment:
    +#   KONFLUX_REPO  the Quay repository of the components (default:
    +#                 DEFAULT_KONFLUX_REPO in the Makefile)
    +#   KONFLUX_SHA   the commit to find the builds of (default: PULL_PULL_SHA,
    +#                 which Prow sets to the PR's head commit). Without one, the
    +#                 master builds are printed.
    +
    +set -euo pipefail
    +
    +repo=${KONFLUX_REPO:-quay.io/redhat-user-workloads/ocp-isc-tenant}
    +sha=${KONFLUX_SHA:-${PULL_PULL_SHA:-}}
    +
    +if [[ $# -eq 0 ]]; then
    +  echo "usage: $0 <component>..." >&2
    +  exit 2
    +fi
    +if [[ $repo != quay.io/* ]]; then
    +  echo "KONFLUX_REPO must be on quay.io: $repo" >&2
    +  exit 2
    +fi
    +
    +# has <component> <tag> [active]: whether Quay has the tag, or ever had it.
    +# It exits when Quay can't be reached, so that an outage doesn't look like a
    +# missing build.
    +has() {
    +  local out
    +  out=$(curl -fsS --max-time 30 --retry 5 --retry-all-errors \
    +    "https://quay.io/api/v1/repository/${repo#quay.io/}/$1/tag/?specificTag=$2${3:+&onlyActiveTags=true}") || {
    +    echo "Could not get the tags of $repo/$1 from Quay" >&2
    +    exit 1
    +  }
    +  [[ $out == *'"name"'* ]]
    +}
    +
    +# resolve <component>: print the build of the component to test with.
    +resolve() {
    +  local tag=on-pr-$sha
    +  # A Konflux build stores its source at <tag>.git when it starts.
    +  if [[ -n $sha ]] && has "$1" "$tag.git"; then
    +    # Retry with backoff for up to 5 minutes while the build finishes.
    +    local elapsed=0 delay
    +    for delay in 10 20 40; do
    +      has "$1" "$tag" active && { echo "$repo/$1:$tag"; return; }
    +      has "$1" "$tag.git" active || {
    +        echo "$repo/$1:$tag has expired: /test $1-on-pull-request rebuilds it" >&2
    +        exit 1
    +      }
    +      sleep "$delay"
    +      elapsed=$((elapsed + delay))
    +    done
    +    while [[ $elapsed -lt 300 ]]; do
    +      has "$1" "$tag" active && { echo "$repo/$1:$tag"; return; }
    +      has "$1" "$tag.git" active || {
    +        echo "$repo/$1:$tag has expired: /test $1-on-pull-request rebuilds it" >&2
    +        exit 1
    +      }
    +      sleep 60
    +      elapsed=$((elapsed + 60))
    +    done
    +    # Distinguish a slow build (PipelineRun still active) from a failed one.
    +    if has "$1" "$tag.git" active; then
    +      echo "Konflux is still building $repo/$1:$tag after 5 minutes; the PipelineRun may be unusually slow — check its status" >&2
    +    else
    +      echo "Konflux build of $repo/$1:$tag appears to have failed (PipelineRun finished without producing an image)" >&2
    +    fi
    +    exit 1
    +  fi
    +  echo "$repo/$1:master"

    Agreed. Since this comment the script stopped using floating tags at all: it uses the PR's on-pr-<head> build or the push build of the newest base commit that changed the component's files, never :master or :release-1.10. But it still only worked on master. On release-1.10 the pipelines are compliance-operator-release-1-10-* and push to compliance-operator-release, so it failed there.

    9071b693e uses PULL_BASE_REF, as you suggested. Jobs keep passing master's names, so a release branch's config can copy master's commands. On release-1.10, compliance-operator-dev becomes compliance-operator-release-1-10: the script reads that branch's pipelines and takes the repository from each pipeline's output-image (compliance-operator-release, -openscap-release, -must-gather-release). It fails if a pipeline's trigger is for another branch. Without PULL_BASE_REF, as in rehearsals, it uses the branch that the base's push pipelines build.

    Checked against what Konflux built: all 18 release-1.10 commits since the branch was cut resolve to images that are on Quay. For all 36 release-1.10 PRs, the choice matches the pipelines Konflux ran (144 of 144). On release-1.9 it's 248 of 252. The other 4 are one bot PR from April whose head is older than the branch's pipelines, so Konflux built nothing and the script fails.

    Running e2e on a release branch still needs the script backported there and a branch config in openshift/release; neither exists today.

    Vincent056 Vincent056 commented on code on Oct 23, 2026 12:41 UTC
    Code Review
    hack/resolve-konflux-images.sh:1
    @@ -0,0 +1,81 @@
    +#!/bin/bash
    +# resolve-konflux-images.sh — Print the Konflux builds of images to test with.
    +#
    +#   hack/resolve-konflux-images.sh <component>...
    +#
    +# For each Konflux component, such as compliance-operator-dev, this prints the
    +# pull spec of its build for the PR's head commit, waiting up to 5 minutes
    +# while Konflux finishes it. Konflux builds an image only for PRs that change
    +# its sources, so when it hasn't started a build for the PR, this prints the
    +# master build, which has the same sources. It fails rather than print another
    +# image when the PR's build has expired or doesn't finish in time, or when
    +# Quay can't be reached.
    +#
    +# CI jobs test with these images instead of having Prow build them before the
    +# cluster install starts:
    +#
    +#   IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
    +#   OPENSCAP_IMAGE=$(hack/resolve-konflux-images.sh compliance-operator-openscap-dev)
    +#
    +# Jobs for other repositories can run it from GitHub:
    +#
    +#   curl -fsSL https://raw.githubusercontent.com/ComplianceAsCode/compliance-operator/master/hack/resolve-konflux-images.sh |
    +#     bash -s -- compliance-operator-dev
    +#
    +# Environment:
    +#   KONFLUX_REPO  the Quay repository of the components (default:
    +#                 DEFAULT_KONFLUX_REPO in the Makefile)
    +#   KONFLUX_SHA   the commit to find the builds of (default: PULL_PULL_SHA,
    +#                 which Prow sets to the PR's head commit). Without one, the
    +#                 master builds are printed.
    +
    +set -euo pipefail
    +
    +repo=${KONFLUX_REPO:-quay.io/redhat-user-workloads/ocp-isc-tenant}
    +sha=${KONFLUX_SHA:-${PULL_PULL_SHA:-}}
    +
    +if [[ $# -eq 0 ]]; then
    +  echo "usage: $0 <component>..." >&2
    +  exit 2
    +fi
    +if [[ $repo != quay.io/* ]]; then
    +  echo "KONFLUX_REPO must be on quay.io: $repo" >&2
    +  exit 2
    +fi
    +
    +# has <component> <tag> [active]: whether Quay has the tag, or ever had it.
    +# It exits when Quay can't be reached, so that an outage doesn't look like a
    +# missing build.
    +has() {
    +  local out
    +  out=$(curl -fsS --max-time 30 --retry 5 --retry-all-errors \
    +    "https://quay.io/api/v1/repository/${repo#quay.io/}/$1/tag/?specificTag=$2${3:+&onlyActiveTags=true}") || {
    +    echo "Could not get the tags of $repo/$1 from Quay" >&2
    +    exit 1
    +  }
    +  [[ $out == *'"name"'* ]]
    +}
    +
    +# resolve <component>: print the build of the component to test with.
    +resolve() {
    +  local tag=on-pr-$sha delay
    +  # A Konflux build stores its source at <tag>.git when it starts.
    +  if [[ -n $sha ]] && has "$1" "$tag.git"; then
    +    # Retry with backoff for up to 5 minutes while the build finishes.
    +    for delay in 10 20 40 80 150 0; do

    You're right that arm64 is the slow part. Quay's tag times for the last 68 operator PR builds (Aug 24 to Oct 23): arm64 takes 15 minutes at the median and up to 28, x86-64 takes 5, and the whole build 17, up to 32. arm64 finished last in 67 of the 68.

    The wait only starts once the cluster is installed, though. Without the Prow image builds (#86580), the test step would start 46 to 72 minutes into the job (median 54, from 54 recent e2e runs), and Konflux starts its build within seconds of Prow. In 20 of the 24 runs that had an operator PR build, the image was ready 30 to 54 minutes before the test step.

    The other 4 were all the weekly "Update Konflux references" PR (#1395). Its builds run in Konflux's Saturday batch, where PipelineRuns waited 15 to 52 minutes before they started cloning, and the images came 5 to 9 minutes after the test step would start. Release-branch PRs, nearly all bot PRs built in those batches, took 45 minutes from push to image at the median and up to 77.

    We'll keep the 5-minute default: for developer PRs the cluster install hides the build, and the batch-built bot PRs take a /retest. A failed build, or a PR still waiting for /ok-to-test, then fails 5 minutes into the test step instead of 30.

    On failed vs. slow: Quay can't tell them apart, because a failed build leaves the same .git tag as one that's still running. The GitHub check can, but then every job would call the GitHub API, so the message points to it instead: the PR's Konflux check, and /test <component>-on-pull-request to rebuild.

    github-actions[bot] github-actions[bot] commented on Oct 23, 2026 12:48 UTC
    Bot

    :robot: To deploy this PR, run the following command:

    make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-9071b693e5246b26ef239d35dd8395e544ff40fa
    

    Vincent056 Vincent056 commented on Nov 02, 2026 20:16 UTC
    Contributor

    /test e2e-aws-scan-config

    github-actions[bot] github-actions[bot] commented on Nov 24, 2026 05:36 UTC
    Bot

    :robot: To deploy this PR, run the following command:

    make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-4f67ad994a3e2f0062dc2bf04541f7343142981d
    

    rhmdnd rhmdnd commented on code on Dec 02, 2026 20:24 UTC
    Code Review
    hack/resolve-konflux-images.sh:1
    @@ -0,0 +1,211 @@
    +#!/bin/bash
    +# Print the Konflux build of each component that a CI job should test with:
    +#
    +#   IMAGE_FROM_CI=$(hack/resolve-konflux-images.sh compliance-operator-dev)
    +#
    +# A PR is tested with its own build of a component (on-pr-<head>) when it
    +# changes a file that the component's .tekton pull-request pipeline watches,
    +# which is the check Konflux makes before it builds. Otherwise the job uses the
    +# push build of the newest base commit that changed such a file, which is the
    +# image the base has. The image is the one the pipeline's output-image names.
    +# The script waits up to KONFLUX_WAIT_SECONDS for that build and fails if Quay
    +# doesn't have it. It never falls back to another image, so a job can't pass on
    +# an image that doesn't match the code it tests.
    +#
    +# Jobs name components as master does, so every branch runs the same command.
    +# Master's components end in -dev; on another branch the script uses that
    +# branch's component instead, with its own pipelines and image repository: on
    +# release-1.10, compliance-operator-dev is compliance-operator-release-1-10,
    +# which Konflux pushes to compliance-operator-release. Names that don't end in
    +# -dev are used as given.
    +#
    +# Konflux matches each "<pattern>".pathChanged() with gobwas/glob, where * also
    +# matches /. For patterns made of literal characters, * and ?, bash's
    +# [[ $file == $pattern ]] matches the same files; the script refuses other
    +# patterns, and triggers that aren't a plain list of watched paths for the
    +# job's branch.
    +#
    +# Environment:
    +#   PULL_PULL_SHA, PULL_BASE_SHA, PULL_BASE_REF
    +#                         set by Prow; used only in this repository's jobs
    +#   KONFLUX_SHA           the PR head, overriding PULL_PULL_SHA; without one the
    +#                         job tests the base
    +#   KONFLUX_BASE_SHA      the base, overriding PULL_BASE_SHA; default the
    +#                         checkout's HEAD
    +#   KONFLUX_BRANCH        the base's branch, overriding PULL_BASE_REF; default
    +#                         the branch that the base's push pipelines build
    +#   KONFLUX_WAIT_SECONDS  default 300
    +
    +set -euo pipefail
    +
    +fail() {
    +	echo "$*" >&2
    +	exit 1
    +}
    +
    +# CI checkouts can belong to another user, which git refuses by default.
    +git() {
    +	command git -c safe.directory='*' "$@"
    +}
    +
    +wait_seconds=${KONFLUX_WAIT_SECONDS:-300}
    +[[ $# -gt 0 ]] || fail "usage: $0 <component>..."
    +[[ $wait_seconds =~ ^[0-9]+$ ]] || fail "KONFLUX_WAIT_SECONDS must be whole seconds: $wait_seconds"
    +[[ ${JOB_TYPE:-} != batch ]] || fail "A batch job tests several PRs together, so no single Konflux build matches it"
    +cd "$(dirname "$0")/.."
    +
    +# openshift/release rehearsals set PULL_* for their own PR, not this repository's.
    +if [[ ${REPO_OWNER:-}/${REPO_NAME:-} == ComplianceAsCode/compliance-operator ]]; then
    +	head=${KONFLUX_SHA:-${PULL_PULL_SHA:-}}
    +	base=${KONFLUX_BASE_SHA:-${PULL_BASE_SHA:-}}
    +	branch=${KONFLUX_BRANCH:-${PULL_BASE_REF:-}}
    +else
    +	head=${KONFLUX_SHA:-}
    +	base=${KONFLUX_BASE_SHA:-}
    +	branch=${KONFLUX_BRANCH:-}
    +fi
    +base=${base:-$(git rev-parse HEAD)}
    +shallow=
    +[[ $(git rev-parse --is-shallow-repository) == false ]] || shallow=" (the clone is shallow)"
    +for commit in $head $base; do
    +	git cat-file -e "$commit^{commit}" 2>/dev/null || fail "The checkout lacks commit $commit$shallow"
    +done
    +# Without a branch, such as in a rehearsal, the job tests the branch that the
    +# base's push pipelines build.
    +if [[ -z $branch ]]; then
    +	branch=$(git grep -h -o -E 'target_branch *== *"[^"]*"' "$base" -- '.tekton/*-push.yaml' |
    +		sed -E 's/.*"(.*)"/\1/' | sort -u) || true
    +	[[ -n $branch && $branch != *$'\n'* ]] ||
    +		fail "Set KONFLUX_BRANCH: the push pipelines in .tekton at $base don't build a single branch"
    +fi
    +
    +# component <name>: the component's name on the job's branch.
    +component() {
    +	if [[ $branch != master && $1 == *-dev ]]; then
    +		echo "${1%-dev}-${branch//./-}"
    +	else
    +		echo "$1"
    +	fi
    +}
    +
    +# watched <commit> <pipeline>: the path patterns that the trigger of
    +# .tekton/<pipeline> watches at the commit, one per line. Konflux reads a PR's
    +# pipelines from its head, and a push's from the pushed commit.
    +watched() {
    +	local spec=$1:.tekton/$2 yaml cel shape patterns pattern
    +	local re='^event=="(pull_request|push)"&&target_branch=="([^"]+)"&&\(\)$'
    +	# Read the file whole first: piped into grep -m1, git show can die of
    +	# SIGPIPE, and pipefail reports that as a failure.
    +	yaml=$(git show "$spec" 2>/dev/null) || fail "$spec doesn't exist"
    +	cel=$(grep -m1 'pipelinesascode.tekton.dev/on-cel-expression:' <<<"$yaml") ||
    +		fail "$spec has no on-cel-expression"
    +	cel=${cel#*on-cel-expression:}
    +	shape=$(sed -E 's/"[^"]*"\.pathChanged\(\)//g; s/\|\|//g; s/[[:space:]]//g' <<<"$cel")
    +	patterns=$(grep -o '"[^"]*"\.pathChanged()' <<<"$cel" | sed -E 's/^"//; s/"\.pathChanged\(\)$//') || true
    +	[[ -n $patterns && $shape =~ $re ]] ||
    +		fail "$spec: the trigger isn't a list of watched paths:$cel"
    +	[[ ${BASH_REMATCH[2]} == "$branch" ]] ||
    +		fail "$spec: the trigger is for ${BASH_REMATCH[2]}, not $branch"
    +	while IFS= read -r pattern; do
    +		case $pattern in
    +		*'['* | *'{'* | *\\*) fail "$spec: unsupported pattern $pattern" ;;
    +		esac
    +	done <<<"$patterns"
    +	echo "$patterns"
    +}
    +
    +# output_image <commit> <pipeline>: the image that .tekton/<pipeline> at the
    +# commit pushes when it builds the commit, from its output-image parameter.
    +output_image() {
    +	local spec=$1:.tekton/$2 yaml value re='^quay\.io/[^:]+:(on-pr-)?\{\{revision\}\}$'
    +	yaml=$(git show "$spec" 2>/dev/null) || fail "$spec doesn't exist"
    +	value=$(sed -n '/^ *- name: output-image$/{n;s/^ *value: *//p;q;}' <<<"$yaml")
    +	[[ $value =~ $re ]] || fail "$spec has no output-image quay.io/<repository>:[on-pr-]{{revision}}: $value"
    +	echo "${value%%:*}:${BASH_REMATCH[1]}$1"
    +}
    +
    +# matches <patterns> <files>: print the first file a pattern matches, with the
    +# pattern, or return 1 if none does.
    +matches() {
    +	local file pattern
    +	while IFS= read -r file; do
    +		while IFS= read -r pattern; do
    +			# shellcheck disable=SC2053 # $pattern is a glob on purpose.
    +			if [[ -n $file && $file == $pattern ]]; then
    +				echo "$file ($pattern)"
    +				return 0
    +			fi
    +		done <<<"$1"
    +	done <<<"$2"
    +	return 1
    +}
    +
    +# newest_build <patterns>: the newest commit in the base's first-parent history
    +# whose own change touches a watched file. Konflux built it on push, and its
    +# build is the image the base has. A shallow clone's oldest commit seems to add
    +# every file, so the search stops there.
    +newest_build() {
    +	local line commit='' parents='' files='' why
    +	while IFS= read -r line; do
    +		if [[ $line == commit\ * ]]; then
    +			if [[ -n $commit ]]; then
    +				[[ -n $parents || -z $shallow ]] || return 1
    +				if why=$(matches "$1" "$files"); then
    +					echo "$commit $why"
    +					return 0
    +				fi
    +			fi
    +			read -r commit parents <<<"${line#commit }"
    +			files=
    +		elif [[ -n $line ]]; then
    +			files+=$line$'\n'
    +		fi
    +	done < <(git log --first-parent --diff-merges=first-parent --no-renames --max-count=1000 \
    +		--format='commit %H %P' --name-only "$base"; echo 'commit ')
    +	return 1
    +}
    +
    +# on_quay <image>: whether Quay has the image's tag. Fails when Quay can't be
    +# reached, so an outage can't look like a missing build.
    +on_quay() {
    +	local repository=${1%:*} tags
    +	tags=$(curl -fsS --max-time 30 --retry 5 --retry-all-errors \
    +		"https://quay.io/api/v1/repository/${repository#quay.io/}/tag/?specificTag=${1##*:}&onlyActiveTags=true") ||
    +		fail "Could not get the tags of $repository from Quay"
    +	[[ $tags == *'"name"'* ]]

    If we have jq available in the CI image, we can make this more readable by doing something like jq -e ".tags | length > 0

    rhmdnd rhmdnd commented on code on Dec 02, 2026 21:12 UTC
    Code Review
    hack/test-resolve-konflux-images.sh:1
    @@ -0,0 +1,522 @@
    +#!/bin/bash
    +# Tests for hack/resolve-konflux-images.sh.
    +#
    +# Most cases run the script in scratch git repositories with their own .tekton
    +# pipelines, one of them with a release branch, against a fake Quay (curl and
    +# sleep on PATH), and check the image it prints, its exit code and its message.
    +# The last cases run it on this repository's own .tekton pipelines and history,
    +# and on its newest release branch when the clone has one.

    500 lines of test code in bash makes me wonder if we should be using a different approach.

    By the time this script has to run, could it check the GH checks API instead of comparing the git tree against the trigger CEL expressions parsed out of the YAML?

    If we commit to this approach, we could also try incorporating it directly into openshift/release as a task that other teams can use from their CI configs. That could be useful for a lot of folks.

    rhmdnd rhmdnd commented on Dec 02, 2026 22:21 UTC
    Reviewer

    I didn't think about incorporating this into openshift/release when we first started experimenting with it, but after some digging I'm seeing other product teams ask for this functionality, too.

    I'd like to follow up with the test platform team to see if this is something they'd accept in openshift/release so we're sharing the maintenance cost and providing it as a CI savings tool for everyone else, too.

    Reviewers
    Assignees
    redhat-chai-bot redhat-chai-bot
    Labels
    risk: low confidence: 89.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.4% (MEDIUM) · Higher = larger blast radius
    52.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.9% · Lower = rushed or shallow review
    89.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5.3% · Safe to merge
    5.3%