Skip to content

CNTRLPLANE-2560: Add async Python script for Konflux task version lookups - #7537

Closed
celebdor wants to merge 1 commit into
openshift:mainfrom
celebdor:CNTRLPLANE-2560
Closed

CNTRLPLANE-2560: Add async Python script for Konflux task version lookups#7537
celebdor wants to merge 1 commit into
openshift:mainfrom
celebdor:CNTRLPLANE-2560

Conversation

@celebdor

@celebdor celebdor commented Jan 16, 2026

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Adds a new async Python script (hack/tools/scripts/konflux_task_version_lookup.py) for efficiently querying the quay.io registry API to resolve Konflux Tekton task versions. The original /update-konflux-tasks skill used skopeo via bash but had issues with Docker Registry API pagination and incomplete EC log parsing.

Key improvements:

  1. Pagination handling: Properly follows Link headers in the Docker Registry API to get all semver tags (fixes cases like 0.7 → 0.2 "downgrade" when 0.7 was actually the latest)

  2. Structured log parsing: Parses EC logs using the STEP-REPORT-JSON delimiter instead of regex

  3. Handles three types of EC messages:

    • trusted_task.current warnings - outdated but still trusted tasks
    • tasks.unsupported violations - task version no longer supported
    • trusted_task.trusted violations - task digest not in trusted list (NEW)
  4. EC recommendation priority: Prioritizes EC-recommended versions from violations over digest matching

  5. Correct digest lookup: When using EC-recommended or highest-available versions, looks up the actual digest for that version from the registry

  6. Async performance: Uses aiohttp for parallel HTTP requests to the registry

Files changed:

  • hack/tools/scripts/konflux_task_version_lookup.py - New async Python script
  • .claude/commands/update-konflux-tasks.md - Updated skill to use the new script

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2560

Special notes for your reviewer:

Requires Python 3.8+ with aiohttp (pip install aiohttp).

Example output showing untrusted task detection:

### 🚨 Untrusted Tasks (BLOCKING - must fix)
- **rpms-signature-scan**: needs digest sha256:00417785... (version 0.2)

### Version Bumps (require migration notes check)
- ⬆️  **build-image-index**: 0.1 → 0.2 (via ec_recommended)

Checklist:

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

🤖 Generated with Claude Code via /update-konflux-tasks

@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 16, 2026
@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 16, 2026
@openshift-ci-robot

openshift-ci-robot commented Jan 16, 2026

Copy link
Copy Markdown

@celebdor: This pull request references CNTRLPLANE-2560 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 task 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 new async Python script (hack/tools/scripts/konflux_task_version_lookup.py) for efficiently querying the quay.io registry API to resolve Konflux Tekton task versions. The original /update-konflux-tasks skill used skopeo via bash but had issues with Docker Registry API pagination, causing incorrect version lookups.

Key improvements:

  1. Pagination handling: Properly follows Link headers in the Docker Registry API to get all semver tags (fixes cases like 0.7 → 0.2 "downgrade" when 0.7 was actually the latest)

  2. Structured log parsing: Parses EC logs using the STEP-REPORT-JSON delimiter instead of regex

  3. EC recommendation priority: Prioritizes EC-recommended versions from tasks.unsupported violations over digest matching

  4. Correct digest lookup: When using EC-recommended or highest-available versions, looks up the actual digest for that version from the registry

  5. Async performance: Uses aiohttp for parallel HTTP requests to the registry

Files changed:

  • hack/tools/scripts/konflux_task_version_lookup.py - New async Python script
  • .claude/commands/update-konflux-tasks.md - Updated skill to use the new script

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2560

Special notes for your reviewer:

Requires Python 3.8+ with aiohttp (pip install aiohttp).

Tested with enterprise contract verification logs - correctly identifies version bumps and digest updates.

Checklist:

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

🤖 Generated with Claude Code via /update-konflux-tasks

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 commented Jan 16, 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 16, 2026

Copy link
Copy Markdown

@celebdor: This pull request references CNTRLPLANE-2560 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 task 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 new async Python script (hack/tools/scripts/konflux_task_version_lookup.py) for efficiently querying the quay.io registry API to resolve Konflux Tekton task versions. The original /update-konflux-tasks skill used skopeo via bash but had issues with Docker Registry API pagination, causing incorrect version lookups.

Key improvements:

  1. Pagination handling: Properly follows Link headers in the Docker Registry API to get all semver tags (fixes cases like 0.7 → 0.2 "downgrade" when 0.7 was actually the latest)

  2. Structured log parsing: Parses EC logs using the STEP-REPORT-JSON delimiter instead of regex

  3. EC recommendation priority: Prioritizes EC-recommended versions from tasks.unsupported violations over digest matching

  4. Correct digest lookup: When using EC-recommended or highest-available versions, looks up the actual digest for that version from the registry

  5. Async performance: Uses aiohttp for parallel HTTP requests to the registry

Files changed:

  • hack/tools/scripts/konflux_task_version_lookup.py - New async Python script
  • .claude/commands/update-konflux-tasks.md - Updated skill to use the new script

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2560

Special notes for your reviewer:

Requires Python 3.8+ with aiohttp (pip install aiohttp).

Tested with enterprise contract verification logs - correctly identifies version bumps and digest updates.

Checklist:

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

🤖 Generated with Claude Code via /update-konflux-tasks

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.

@coderabbitai

coderabbitai Bot commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Replaces skopeo-based digest-to-version mapping with a Python aiohttp-based registry lookup; adds a new script to parse Enterprise Contract logs and resolve Tekton task versions via quay.io; updates the update-konflux-tasks command doc to target a single common pipeline file and reflect Python tooling and outputs.

Changes

Cohort / File(s) Summary
Claude Command Documentation
\.claude/commands/update-konflux-tasks.md
Replaces skopeo/JQ/YQ workflow with Python-based digest→version resolution; changes Parse EC Log step to use the Python script and emit JSON; consolidates updates to .tekton/pipelines/common-operator-build.yaml; updates prompts, expected output format, safety, requirements, and installation guidance to reference Python/aiohttp.
Python Registry Lookup Tooling
hack/tools/scripts/konflux_task_version_lookup.py
New comprehensive script: parses EC logs (STEP-REPORT-JSON), extracts tasks, resolves registry auth (env, containers config, docker config, anonymous), performs async quay.io API calls to list semver tags and fetch manifests, applies resolution priority (ec_recommended → digest_match → highest_available), marks version_source/is_version_bump, outputs JSON and human-readable summaries, and includes logging and concurrency controls.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

✨ Finishing touches
  • 📝 Generate docstrings

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

@openshift-ci openshift-ci Bot added do-not-merge/needs-area area/ai Indicates the PR includes changes related to AI - Claude agents, Cursor rules, etc. area/ci-tooling Indicates the PR includes changes for CI or tooling and removed do-not-merge/needs-area labels Jan 16, 2026

@jparrill jparrill 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.

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 16, 2026
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 16, 2026
@openshift-ci-robot

openshift-ci-robot commented Jan 16, 2026

Copy link
Copy Markdown

@celebdor: This pull request references CNTRLPLANE-2560 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 task 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 new async Python script (hack/tools/scripts/konflux_task_version_lookup.py) for efficiently querying the quay.io registry API to resolve Konflux Tekton task versions. The original /update-konflux-tasks skill used skopeo via bash but had issues with Docker Registry API pagination and incomplete EC log parsing.

Key improvements:

  1. Pagination handling: Properly follows Link headers in the Docker Registry API to get all semver tags (fixes cases like 0.7 → 0.2 "downgrade" when 0.7 was actually the latest)

  2. Structured log parsing: Parses EC logs using the STEP-REPORT-JSON delimiter instead of regex

  3. Handles three types of EC messages:

  • trusted_task.current warnings - outdated but still trusted tasks
  • tasks.unsupported violations - task version no longer supported
  • trusted_task.trusted violations - task digest not in trusted list (NEW)
  1. EC recommendation priority: Prioritizes EC-recommended versions from violations over digest matching

  2. Correct digest lookup: When using EC-recommended or highest-available versions, looks up the actual digest for that version from the registry

  3. Async performance: Uses aiohttp for parallel HTTP requests to the registry

Files changed:

  • hack/tools/scripts/konflux_task_version_lookup.py - New async Python script
  • .claude/commands/update-konflux-tasks.md - Updated skill to use the new script

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2560

Special notes for your reviewer:

Requires Python 3.8+ with aiohttp (pip install aiohttp).

Example output showing untrusted task detection:

### 🚨 Untrusted Tasks (BLOCKING - must fix)
- **rpms-signature-scan**: needs digest sha256:00417785... (version 0.2)

### Version Bumps (require migration notes check)
- ⬆️  **build-image-index**: 0.1 → 0.2 (via ec_recommended)

Checklist:

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

🤖 Generated with Claude Code via /update-konflux-tasks

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.

1 similar comment
@openshift-ci-robot

openshift-ci-robot commented Jan 16, 2026

Copy link
Copy Markdown

@celebdor: This pull request references CNTRLPLANE-2560 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 task 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 new async Python script (hack/tools/scripts/konflux_task_version_lookup.py) for efficiently querying the quay.io registry API to resolve Konflux Tekton task versions. The original /update-konflux-tasks skill used skopeo via bash but had issues with Docker Registry API pagination and incomplete EC log parsing.

Key improvements:

  1. Pagination handling: Properly follows Link headers in the Docker Registry API to get all semver tags (fixes cases like 0.7 → 0.2 "downgrade" when 0.7 was actually the latest)

  2. Structured log parsing: Parses EC logs using the STEP-REPORT-JSON delimiter instead of regex

  3. Handles three types of EC messages:

  • trusted_task.current warnings - outdated but still trusted tasks
  • tasks.unsupported violations - task version no longer supported
  • trusted_task.trusted violations - task digest not in trusted list (NEW)
  1. EC recommendation priority: Prioritizes EC-recommended versions from violations over digest matching

  2. Correct digest lookup: When using EC-recommended or highest-available versions, looks up the actual digest for that version from the registry

  3. Async performance: Uses aiohttp for parallel HTTP requests to the registry

Files changed:

  • hack/tools/scripts/konflux_task_version_lookup.py - New async Python script
  • .claude/commands/update-konflux-tasks.md - Updated skill to use the new script

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2560

Special notes for your reviewer:

Requires Python 3.8+ with aiohttp (pip install aiohttp).

Example output showing untrusted task detection:

### 🚨 Untrusted Tasks (BLOCKING - must fix)
- **rpms-signature-scan**: needs digest sha256:00417785... (version 0.2)

### Version Bumps (require migration notes check)
- ⬆️  **build-image-index**: 0.1 → 0.2 (via ec_recommended)

Checklist:

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

🤖 Generated with Claude Code via /update-konflux-tasks

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.

@celebdor
celebdor marked this pull request as ready for review January 16, 2026 22:13
@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 16, 2026
@openshift-ci
openshift-ci Bot requested review from bryan-cox and csrwng January 16, 2026 22:13
The original /update-konflux-tasks skill used skopeo to look up task
versions but had issues with Docker Registry API pagination, causing
incorrect version lookups (e.g., 0.7 → 0.2 "downgrade").

This adds a new Python script that:
- Uses async HTTP requests (aiohttp) for parallel registry queries
- Properly handles pagination via Link headers to get all semver tags
- Parses EC logs using STEP-REPORT-JSON delimiter instead of regex
- Prioritizes EC-recommended versions from tasks.unsupported violations
- Handles trusted_task.trusted violations for untrusted tasks
- Looks up correct digests when using EC-recommended or highest-available

The skill documentation is updated to reference the new script and
point to the common pipeline file only.

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

@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: 2

🤖 Fix all issues with AI agents
In `@hack/tools/scripts/konflux_task_version_lookup.py`:
- Around line 145-149: The env token path currently returns the raw token from
get_auth_token_from_env() which can be interpreted as Basic auth; change the
handling so that when token is truthy you normalize it to a Bearer token (if it
doesn't already start with "Bearer ") before returning it (the return at the
token assignment around get_auth_token_from_env()); apply the same normalization
logic to the other auth branch referenced in the review (the code around lines
184-194) so both paths consistently return a value prefixed with "Bearer ".
- Around line 49-50: The script creates an aiohttp.ClientSession for registry
calls without a timeout, so add a session-level timeout by constructing an
aiohttp.ClientTimeout (e.g., with connect and total/sock_read limits) and pass
it to aiohttp.ClientSession(timeout=...) where the session is instantiated
(refer to the existing aiohttp.ClientSession usage); also ensure any per-request
timeouts aren't overwritten and keep MAX_CONCURRENT_REQUESTS logic intact so the
concurrency limit remains unchanged.
🧹 Nitpick comments (1)
hack/tools/scripts/konflux_task_version_lookup.py (1)

475-544: Avoid order-dependence when applying EC-recommended versions.

If a tasks.unsupported violation appears after the trusted_task.current warning (e.g., in a later component), recommended_version never gets applied to already-collected tasks. Consider backfilling after all components are parsed.

🔁 Proposed fix
-                        if task_data['recommended_version']:
-                            logger.info(f"Task {friendly_name}: EC recommends version {task_data['recommended_version']}")
+                        if task_data['recommended_version']:
+                            logger.info(f"Task {friendly_name}: EC recommends version {task_data['recommended_version']}")
+
+    # Backfill recommendations discovered after warnings were parsed
+    for task_data in tasks_by_bundle.values():
+        if not task_data.get('recommended_version'):
+            rec = unsupported_recommendations.get(task_data['task_name'])
+            if rec:
+                task_data['recommended_version'] = rec
+                logger.info(f"Task {task_data['friendly_name']}: EC recommends version {rec}")

Comment on lines +49 to +50
MAX_CONCURRENT_REQUESTS = 20

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

🧩 Analysis chain

🏁 Script executed:

cd hack/tools/scripts && wc -l konflux_task_version_lookup.py

Repository: openshift/hypershift

Length of output: 98


🏁 Script executed:

cd hack/tools/scripts && cat -n konflux_task_version_lookup.py | head -70

Repository: openshift/hypershift

Length of output: 2405


🏁 Script executed:

cd hack/tools/scripts && cat -n konflux_task_version_lookup.py | sed -n '400,430p'

Repository: openshift/hypershift

Length of output: 1601


🏁 Script executed:

cd hack/tools/scripts && grep -n "ClientSession" konflux_task_version_lookup.py

Repository: openshift/hypershift

Length of output: 187


🏁 Script executed:

cd hack/tools/scripts && grep -n -i "timeout\|ClientTimeout" konflux_task_version_lookup.py

Repository: openshift/hypershift

Length of output: 46


🏁 Script executed:

cd hack/tools/scripts && grep -n "self.session" konflux_task_version_lookup.py

Repository: openshift/hypershift

Length of output: 404


🏁 Script executed:

cd hack/tools/scripts && sed -n '200,250p' konflux_task_version_lookup.py

Repository: openshift/hypershift

Length of output: 2309


🏁 Script executed:

cd hack/tools/scripts && sed -n '240,300p' konflux_task_version_lookup.py

Repository: openshift/hypershift

Length of output: 3084


Add explicit HTTP timeouts for registry calls.

The aiohttp.ClientSession created at line 416 lacks a timeout, allowing async registry requests to hang indefinitely. Add a session-level timeout to keep the script responsive during network stalls.

Proposed fix
 # Concurrency limit
 MAX_CONCURRENT_REQUESTS = 20
+HTTP_TIMEOUT_SECONDS = 30
 
 # Configure logging
 logger = logging.getLogger(__name__)
     async def process_all_tasks(self, tasks: List[dict]) -> List[dict]:
         """Process all tasks in parallel."""
+        timeout = aiohttp.ClientTimeout(total=HTTP_TIMEOUT_SECONDS)
-        async with aiohttp.ClientSession() as session:
+        async with aiohttp.ClientSession(timeout=timeout) as session:
             self.session = session
             results = await asyncio.gather(*[self.process_task(task) for task in tasks])
🤖 Prompt for AI Agents
In `@hack/tools/scripts/konflux_task_version_lookup.py` around lines 49 - 50, The
script creates an aiohttp.ClientSession for registry calls without a timeout, so
add a session-level timeout by constructing an aiohttp.ClientTimeout (e.g., with
connect and total/sock_read limits) and pass it to
aiohttp.ClientSession(timeout=...) where the session is instantiated (refer to
the existing aiohttp.ClientSession usage); also ensure any per-request timeouts
aren't overwritten and keep MAX_CONCURRENT_REQUESTS logic intact so the
concurrency limit remains unchanged.

Comment on lines +145 to +149
# 1. Environment variable (already a bearer token)
token = get_auth_token_from_env()
if token:
return token, "QUAY_REGISTRY_TOKEN environment variable"

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

Treat QUAY_REGISTRY_TOKEN as a bearer token, not Basic auth.

Right now a raw token from Line 145 is interpreted as Basic auth unless it already includes Bearer , which breaks the “env token” path for private registries. Consider normalizing the env token to a Bearer token at the source.

🔧 Proposed fix
-    token = get_auth_token_from_env()
-    if token:
-        return token, "QUAY_REGISTRY_TOKEN environment variable"
+    token = get_auth_token_from_env()
+    if token:
+        bearer = token if token.startswith("Bearer ") else f"Bearer {token}"
+        return bearer, "QUAY_REGISTRY_TOKEN environment variable"

Also applies to: 184-194

🤖 Prompt for AI Agents
In `@hack/tools/scripts/konflux_task_version_lookup.py` around lines 145 - 149,
The env token path currently returns the raw token from
get_auth_token_from_env() which can be interpreted as Basic auth; change the
handling so that when token is truthy you normalize it to a Bearer token (if it
doesn't already start with "Bearer ") before returning it (the return at the
token assignment around get_auth_token_from_env()); apply the same normalization
logic to the other auth branch referenced in the review (the code around lines
184-194) so both paths consistently return a value prefixed with "Bearer ".

@bryan-cox

Copy link
Copy Markdown
Member

/retest-required

@jparrill

Copy link
Copy Markdown
Contributor

Live test on #7551 and looks it's working perfectly fine. It not uses Skopeo, jq and so on, just the Python script.

@jparrill

Copy link
Copy Markdown
Contributor

/retest-required

@jparrill

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2026
@openshift-ci

openshift-ci Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: celebdor, jparrill

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 20, 2026
@jparrill

Copy link
Copy Markdown
Contributor

/hold

Tasks it's failing on the sample PR

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 20, 2026
@openshift-ci

openshift-ci Bot commented Jan 20, 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.

@celebdor celebdor closed this Jan 20, 2026
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/ai Indicates the PR includes changes related to AI - Claude agents, Cursor rules, etc. area/ci-tooling Indicates the PR includes changes for CI or tooling do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants