Skip to content

CNTRLPLANE-2579: feat(konflux): add script to update pipeline task bundles to latest trusted versions - #7553

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
celebdor:CNTRLPLANE-2579
Jan 21, 2026
Merged

CNTRLPLANE-2579: feat(konflux): add script to update pipeline task bundles to latest trusted versions#7553
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
celebdor:CNTRLPLANE-2579

Conversation

@celebdor

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Adds a Python script to automate updating Tekton pipeline task bundle references to the latest trusted versions from the Konflux catalog.

Tekton pipeline task bundles in .tekton/pipelines/ need to be periodically updated to use the latest trusted digests from the data-acceptable-bundles OCI artifact. This ensures:

  • Pipelines use the latest security fixes and improvements
  • Enterprise Contract policy checks pass (trusted_task.trusted)
  • Tasks don't expire and cause pipeline failures

The script hack/tools/scripts/update_trusted_task_bundles.py fetches trusted tasks data from quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles:latest and updates pipeline YAML files.

Features

  • Updates task bundle digests to latest trusted versions
  • Shows available version upgrades (e.g., 0.3 → 0.4)
  • With --upgrade-versions, also applies version upgrades
  • Supports dry-run mode for CI checks
  • JSON output for automation

Usage

# Update digests only
./hack/tools/scripts/update_trusted_task_bundles.py .tekton/pipelines/*.yaml

# Dry-run mode
./hack/tools/scripts/update_trusted_task_bundles.py .tekton/pipelines/*.yaml --dry-run

# Upgrade to newer versions  
./hack/tools/scripts/update_trusted_task_bundles.py .tekton/pipelines/*.yaml --upgrade-versions

Which issue(s) this PR fixes:

Fixes https://issues.redhat.com/browse/CNTRLPLANE-2579

Special notes for your reviewer:

  • Requires Python 3.8+, PyYAML, and skopeo
  • Follow-up ticket CNTRLPLANE-2580 will add a periodic Prow job to automate running this script

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

…rusted versions

This script fetches trusted tasks data from the Konflux
data-acceptable-bundles OCI artifact and updates pipeline YAML files
to use the latest trusted task bundle digests.

Features:
- Updates task bundle digests to latest trusted versions
- Shows available version upgrades (e.g., 0.3 → 0.4)
- With --upgrade-versions, also applies version upgrades
- Supports dry-run mode for CI checks
- JSON output for automation

Jira: CNTRLPLANE-2579

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci-robot

openshift-ci-robot commented Jan 20, 2026

Copy link
Copy Markdown

@celebdor: This pull request references CNTRLPLANE-2579 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 "4.22.0" version, but no target version was set.

Details

In response to this:

What this PR does / why we need it:

Adds a Python script to automate updating Tekton pipeline task bundle references to the latest trusted versions from the Konflux catalog.

Tekton pipeline task bundles in .tekton/pipelines/ need to be periodically updated to use the latest trusted digests from the data-acceptable-bundles OCI artifact. This ensures:

  • Pipelines use the latest security fixes and improvements
  • Enterprise Contract policy checks pass (trusted_task.trusted)
  • Tasks don't expire and cause pipeline failures

The script hack/tools/scripts/update_trusted_task_bundles.py fetches trusted tasks data from quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles:latest and updates pipeline YAML files.

Features

  • Updates task bundle digests to latest trusted versions
  • Shows available version upgrades (e.g., 0.3 → 0.4)
  • With --upgrade-versions, also applies version upgrades
  • Supports dry-run mode for CI checks
  • JSON output for automation

Usage

# Update digests only
./hack/tools/scripts/update_trusted_task_bundles.py .tekton/pipelines/*.yaml

# Dry-run mode
./hack/tools/scripts/update_trusted_task_bundles.py .tekton/pipelines/*.yaml --dry-run

# Upgrade to newer versions  
./hack/tools/scripts/update_trusted_task_bundles.py .tekton/pipelines/*.yaml --upgrade-versions

Which issue(s) this PR fixes:

Fixes https://issues.redhat.com/browse/CNTRLPLANE-2579

Special notes for your reviewer:

  • Requires Python 3.8+, PyYAML, and skopeo
  • Follow-up ticket CNTRLPLANE-2580 will add a periodic Prow job to automate running this script

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

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.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 20, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 20, 2026
@coderabbitai

coderabbitai Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

A new Python tool is implemented to update Tekton Pipeline task bundles to latest trusted versions. The script fetches trusted tasks data from OCI artifacts, parses pipeline YAML files to identify bundle references, analyzes them against trusted data to detect updates or upgrades, and provides diff/apply/JSON output modes with dry-run support.

Changes

Cohort / File(s) Summary
New Tool: Trusted Task Bundle Updater
hack/tools/scripts/update_trusted_task_bundles.py
Adds 633 lines implementing a complete tool with data models (TaskUpdate, TrustedTasksData, AnalysisResult), pipeline parsing and analysis logic, OCI artifact fetching via skopeo, unified diff rendering, and CLI entry point supporting dry-run, diff, JSON, and version-upgrade modes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot added the area/ci-tooling Indicates the PR includes changes for CI or tooling label Jan 20, 2026
@celebdor

Copy link
Copy Markdown
Collaborator Author

/area ci-tooling

@celebdor
celebdor marked this pull request as ready for review January 21, 2026 11:40
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 21, 2026
@openshift-ci
openshift-ci Bot requested review from enxebre and muraee January 21, 2026 11:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@hack/tools/scripts/update_trusted_task_bundles.py`:
- Around line 188-216: The fetch_trusted_tasks_data function currently calls
subprocess.run without a timeout and ignores the cache_dir parameter; update the
subprocess.run call in fetch_trusted_tasks_data to include a reasonable timeout
(e.g., seconds value) and add an except subprocess.TimeoutExpired handler that
raises a clear RuntimeError with stderr/timeout context; also either implement
caching by using the provided cache_dir to persist the skopeo output (use
cache_dir as the destination instead of a tempdir when provided, e.g.,
Path(cache_dir)/"data") or remove the unused cache_dir parameter and related
function signature to avoid dead code—modify only fetch_trusted_tasks_data and
its error handling to reference subprocess.run, subprocess.TimeoutExpired, and
the cache_dir usage (or removal).

Comment on lines +188 to +216
def fetch_trusted_tasks_data(data_source: str, cache_dir: Optional[str] = None) -> TrustedTasksData:
"""Fetch trusted tasks data from OCI artifact using skopeo.

Args:
data_source: OCI image reference (e.g., 'quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles:latest')
cache_dir: Optional directory to cache the fetched data

Returns:
TrustedTasksData object with parsed trusted_tasks
"""
# Create temp directory for skopeo output
with tempfile.TemporaryDirectory() as tmpdir:
dest_dir = Path(tmpdir) / "data"

# Use skopeo to copy the OCI artifact
cmd = [
"skopeo", "copy", "--preserve-digests",
f"docker://{data_source}",
f"dir:{dest_dir}"
]

print(f"Fetching trusted tasks data from {data_source}...", file=sys.stderr)
try:
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
except subprocess.CalledProcessError as e:
print(f"Error fetching data: {e.stderr}", file=sys.stderr)
raise RuntimeError(f"Failed to fetch trusted tasks data: {e}")
except FileNotFoundError:
raise RuntimeError("skopeo not found. Please install skopeo.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add timeout to subprocess call to prevent hangs.

The subprocess.run call on line 211 has no timeout. If skopeo hangs (e.g., network issues, unresponsive registry), this script will block indefinitely, which is problematic for CI pipelines.

Also, the cache_dir parameter is declared but never used—consider removing it or implementing the caching logic.

Proposed fix
-def fetch_trusted_tasks_data(data_source: str, cache_dir: Optional[str] = None) -> TrustedTasksData:
+def fetch_trusted_tasks_data(data_source: str) -> TrustedTasksData:
     """Fetch trusted tasks data from OCI artifact using skopeo.
 
     Args:
         data_source: OCI image reference (e.g., 'quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles:latest')
-        cache_dir: Optional directory to cache the fetched data
 
     Returns:
         TrustedTasksData object with parsed trusted_tasks
     """
         try:
-            result = subprocess.run(cmd, capture_output=True, text=True, check=True)
+            subprocess.run(cmd, capture_output=True, text=True, check=True, timeout=120)
         except subprocess.CalledProcessError as e:
             print(f"Error fetching data: {e.stderr}", file=sys.stderr)
-            raise RuntimeError(f"Failed to fetch trusted tasks data: {e}")
+            raise RuntimeError(f"Failed to fetch trusted tasks data: {e}") from e
         except FileNotFoundError:
-            raise RuntimeError("skopeo not found. Please install skopeo.")
+            raise RuntimeError("skopeo not found. Please install skopeo.") from None
+        except subprocess.TimeoutExpired as e:
+            raise RuntimeError(f"Timeout fetching trusted tasks data after {e.timeout}s") from e
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def fetch_trusted_tasks_data(data_source: str, cache_dir: Optional[str] = None) -> TrustedTasksData:
"""Fetch trusted tasks data from OCI artifact using skopeo.
Args:
data_source: OCI image reference (e.g., 'quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles:latest')
cache_dir: Optional directory to cache the fetched data
Returns:
TrustedTasksData object with parsed trusted_tasks
"""
# Create temp directory for skopeo output
with tempfile.TemporaryDirectory() as tmpdir:
dest_dir = Path(tmpdir) / "data"
# Use skopeo to copy the OCI artifact
cmd = [
"skopeo", "copy", "--preserve-digests",
f"docker://{data_source}",
f"dir:{dest_dir}"
]
print(f"Fetching trusted tasks data from {data_source}...", file=sys.stderr)
try:
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
except subprocess.CalledProcessError as e:
print(f"Error fetching data: {e.stderr}", file=sys.stderr)
raise RuntimeError(f"Failed to fetch trusted tasks data: {e}")
except FileNotFoundError:
raise RuntimeError("skopeo not found. Please install skopeo.")
def fetch_trusted_tasks_data(data_source: str) -> TrustedTasksData:
"""Fetch trusted tasks data from OCI artifact using skopeo.
Args:
data_source: OCI image reference (e.g., 'quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles:latest')
Returns:
TrustedTasksData object with parsed trusted_tasks
"""
# Create temp directory for skopeo output
with tempfile.TemporaryDirectory() as tmpdir:
dest_dir = Path(tmpdir) / "data"
# Use skopeo to copy the OCI artifact
cmd = [
"skopeo", "copy", "--preserve-digests",
f"docker://{data_source}",
f"dir:{dest_dir}"
]
print(f"Fetching trusted tasks data from {data_source}...", file=sys.stderr)
try:
subprocess.run(cmd, capture_output=True, text=True, check=True, timeout=120)
except subprocess.CalledProcessError as e:
print(f"Error fetching data: {e.stderr}", file=sys.stderr)
raise RuntimeError(f"Failed to fetch trusted tasks data: {e}") from e
except FileNotFoundError:
raise RuntimeError("skopeo not found. Please install skopeo.") from None
except subprocess.TimeoutExpired as e:
raise RuntimeError(f"Timeout fetching trusted tasks data after {e.timeout}s") from e
🧰 Tools
🪛 Ruff (0.14.13)

188-188: Unused function argument: cache_dir

(ARG001)


211-211: Local variable result is assigned to but never used

Remove assignment to unused variable result

(F841)


211-211: subprocess call: check for execution of untrusted input

(S603)


214-214: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


214-214: Avoid specifying long messages outside the exception class

(TRY003)


216-216: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


216-216: Avoid specifying long messages outside the exception class

(TRY003)

🤖 Prompt for AI Agents
In `@hack/tools/scripts/update_trusted_task_bundles.py` around lines 188 - 216,
The fetch_trusted_tasks_data function currently calls subprocess.run without a
timeout and ignores the cache_dir parameter; update the subprocess.run call in
fetch_trusted_tasks_data to include a reasonable timeout (e.g., seconds value)
and add an except subprocess.TimeoutExpired handler that raises a clear
RuntimeError with stderr/timeout context; also either implement caching by using
the provided cache_dir to persist the skopeo output (use cache_dir as the
destination instead of a tempdir when provided, e.g., Path(cache_dir)/"data") or
remove the unused cache_dir parameter and related function signature to avoid
dead code—modify only fetch_trusted_tasks_data and its error handling to
reference subprocess.run, subprocess.TimeoutExpired, and the cache_dir usage (or
removal).

@bryan-cox

Copy link
Copy Markdown
Member

/approve

@openshift-ci

openshift-ci Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, celebdor

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

The pull request process is described here

Details 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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 21, 2026
@openshift-ci

openshift-ci Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

@celebdor: all tests passed!

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@bryan-cox

Copy link
Copy Markdown
Member

/lgtm
/verified bypass

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jan 21, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@bryan-cox: The verified label has been added.

Details

In response to this:

/lgtm
/verified bypass

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.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 21, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit 37a7afe into openshift:main Jan 21, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/ci-tooling Indicates the PR includes changes for CI or tooling jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants