Pin the policy bundle by modifying the ECP in tekton tasks#3268
Pin the policy bundle by modifying the ECP in tekton tasks#3268simonbaird wants to merge 3 commits intoconforma:mainfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds support for pinning OCI policy bundle digests to Tekton tasks that validate enterprise contracts and Konflux workflows. Introduces a new helper script to resolve policy configurations and replace floating policy bundle tags with digest-pinned references. ChangesPolicy Bundle Digest Pinning
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
It's a long story, but we want to reduce the number of moving parts related to updating Conforma in Red Hat Konflux. Being able to pin the policy bundle when building the Conforma tasks means we can reduce breakages related to old incompatible versions of the cli being used with the latest policy bundle. See also the related PR at conforma/cli#3268 Ref: https://redhat.atlassian.net/browse/EC-1790
It's a long story, but we want to reduce the number of moving parts related to updating Conforma in Red Hat Konflux. Being able to pin the policy bundle when building the Conforma tasks means we can reduce breakages related to old incompatible versions of the cli being used with the latest policy bundle. See also the related PR at conforma/cli#3268 Ref: https://redhat.atlassian.net/browse/EC-1790
It's a long story, but we want to reduce the number of moving parts related to updating Conforma in Red Hat Konflux. Being able to pin the policy bundle when building the Conforma tasks means we can reduce breakages related to old incompatible versions of the cli being used with the latest policy bundle. See also the related PR at conforma/cli#3268 Ref: https://redhat.atlassian.net/browse/EC-1790
It's a long story, but we want to reduce the number of moving parts related to updating Conforma in Red Hat Konflux. Being able to pin the policy bundle when building the Conforma tasks means we can reduce breakages related to old incompatible versions of the cli being used with the latest policy bundle. See also the related PR at conforma/cli#3268 Ref: https://redhat.atlassian.net/browse/EC-1790
It's a long story, but we want to reduce the number of moving parts related to updating Conforma in Red Hat Konflux. Being able to pin the policy bundle when building the Conforma tasks means we can reduce breakages related to old incompatible versions of the cli being used with the latest policy bundle. See also the related PR at conforma/cli#3268 Ref: https://redhat.atlassian.net/browse/EC-1790 Co-authored-by: Claude Code <noreply@anthropic.com>
d1cbab1 to
e75a8c6
Compare
|
/retest |
e75a8c6 to
ecd2dde
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@hack/pin-konflux-policy-bundle.sh`:
- Around line 27-34: The check for an empty digest fails under set -o nounset
because expanding ${POLICY_BUNDLE_DIGEST} errors if the variable is unset;
update the test that reads [[ -z "${POLICY_BUNDLE_DIGEST}" ]] to use parameter
expansion with a default (e.g. ${POLICY_BUNDLE_DIGEST:-}) so the -z check can
run safely even when POLICY_BUNDLE_DIGEST is unset, leaving the rest of the
no-op exit logic unchanged.
- Around line 53-65: The parsing treats any string with "/" as a k8s
namespace/name; change the detection around POLICY_CONFIGURATION (the if [[
"${POLICY_CONFIGURATION}" == *"/"* ]] branch that sets NAMESPACE and NAME and
calls kubectl get enterprisecontractpolicy) so it only treats true k8s ECP refs
as namespace/name—e.g. require exactly one slash and reject inputs that look
like URLs (contain "://" or "//" or domain dots) or otherwise match git-style
paths; if the check fails, skip the kubectl path and continue with the non-k8s
handling that avoids pinning into WORKING_POLICY. Ensure references to
POLICY_CONFIGURATION, NAMESPACE, NAME, and WORKING_POLICY remain but tighten the
conditional logic around the kubectl get calls.
In `@tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml`:
- Around line 345-352: The pin-policy-bundle step currently hard-fails if
pin-konflux-policy-bundle.sh exits non‑zero; update the pin-policy-bundle step
(the container using image quay.io/conforma/cli:latest with envs
POLICY_CONFIGURATION and POLICY_BUNDLE_DIGEST) so the command does not abort the
Task on failure (e.g. run the script under a shell that swallows non‑zero exit
like "sh -c 'pin-konflux-policy-bundle.sh || true'" or modify the script to exit
0 on handled errors) so the later validate/fallback logic can execute and select
the original policy configuration when pinning fails.
In `@tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml`:
- Around line 291-305: The pin step (name: pin-policy-bundle, command:
pin-konflux-policy-bundle.sh) must not stop the Task on failures so the fallback
validate step can run; update that step to be non-blocking by adding Tekton's
continueOnError: true to the step spec (or, if your runtime doesn't support
continueOnError, make the command tolerant to failure e.g. wrap/chain the script
with "|| true") so failures in pin-konflux-policy-bundle.sh do not abort the
Task and the subsequent validate logic still executes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: ed675d0a-c8ea-41db-a0c3-57e0088a8f89
⛔ Files ignored due to path filters (1)
features/__snapshots__/task_validate_image.snapis excluded by!**/*.snap
📒 Files selected for processing (10)
DockerfileDockerfile.distacceptance/kubernetes/kind/acceptance.Dockerfiledocs/modules/ROOT/pages/verify-conforma-konflux-ta.adocdocs/modules/ROOT/pages/verify-enterprise-contract.adocfeatures/task_validate_image.featurehack/pin-konflux-policy-bundle.shhack/update-policy-digest-in-tasks.shtasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yamltasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml
|
I'll do some coderabbit fixes. |
Add optional POLICY_BUNDLE_DIGEST parameter to both conforma Tekton tasks. When provided, the policy configuration is resolved and the oci::quay.io/conforma/release-policy:konflux tag reference is replaced with a digest-pinned reference for reproducible policy evaluation. The reason we want to do this is the same tekton task uses the same policy always, to avoid unexpected cli/policy incompatibilities. As mentioned elsewhere, this is quite Red Hat Konflux-specific, and quite an unpleasant hack, but we're choosing an uncoupled, easy-to-delete hack over alternative options. Ref: https://redhat.atlassian.net/browse/EC-1790 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ecd2dde to
c6c7fb1
Compare
I'm imagining running this manually to begin with, but we might want to automate it have it triggered on a policy bundle push. Ref: https://redhat.atlassian.net/browse/EC-1790 Co-authored-by: Claude Code <noreply@anthropic.com>
c6c7fb1 to
48069b1
Compare
Ref: https://redhat.atlassian.net/browse/EC-1790