ROX-37477: Add hack/resolve-konflux-images.sh for Konflux CI image resolution #1479
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>
:robot: To deploy this PR, run the following command:
make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-9e6b922b5259a881360f3a839fa8ce54e575ac25
/ok-to-test
:robot: To deploy this PR, run the following command:
make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-746307d3bcf6a05481cf0208fb8f0c847735fe0b
/retest-required
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.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./lgtm
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.
I have a feeling we'll need to account for longer ARM builds. But otherwise I think this is on the right track.
[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:
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"]} -->
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.
Good call — Vincent's follow-up commit (2d6fb1c) addresses this:
.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 imageThe script also changed from being sourced to being a standalone executable that accepts component names as arguments.
---
AI-generated. Review for accuracy.
/retest-required
:robot: To deploy this PR, run the following command:
make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-2d6fb1c9857166798cf1a5451c82e8d9d6fde246
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.
:robot: To deploy this PR, run the following command:
make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-39592030b1937058e773f21f6dd47c565e8c6baa
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?
:robot: To deploy this PR, run the following command:
make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-b1a946373073ad67f96fb646dc859eed6cc3a306
:robot: To deploy this PR, run the following command:
make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-47bad340f489890a6791662bcff7daefd8e256d8
@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.tektonpull-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.shhas 35 cases. It runs the script against a fake Quay in scratch repositories, and on this repository's own pipelines and history.make test-unitruns 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>
:robot: To deploy this PR, run the following command:
make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-f817e5dc7221ebe8207c7e4a2f2bfb0c6821408e
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.
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.
:robot: To deploy this PR, run the following command:
make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-9071b693e5246b26ef239d35dd8395e544ff40fa
/test e2e-aws-scan-config
:robot: To deploy this PR, run the following command:
make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1479-4f67ad994a3e2f0062dc2bf04541f7343142981d
If we have jq available in the CI image, we can make this more readable by doing something like jq -e ".tags | length > 0
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.
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.
Vincent056
redhat-chai-bot
Summary
hack/resolve-konflux-images.shprints 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:The same commands work on release branches.
How it picks the image
The same rule applies to every component:
.tektonpull-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>.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 toKONFLUX_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:
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-deviscompliance-operator-release-1-10, with that branch's pipelines and the repository they push to,compliance-operator-release. Rehearsals and local runs, which have noPULL_BASE_REFfor this repository, use the branch that the base's push pipelines build, andKONFLUX_BRANCHoverrides 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
/ok-to-testbefore building them. Until someone comments it, their e2e jobs fail with a message saying so, instead of testing another operator image.Testing
hack/test-resolve-konflux-images.shhas 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-unitruns it, so the unit job does too. shellcheck is clean.- falling back to
:master, ignoringPULL_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 showintogrep -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-parentimplies it.- 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