Skip to content

OTA-2024: Add plc_lookup.py CLI and update product-lifecycle skill - #35

Merged
openshift-merge-bot[bot] merged 3 commits into
openshift:mainfrom
jhadvig:jhadvig/ota-2024-plc-lookup-cli
Jul 16, 2026
Merged

OTA-2024: Add plc_lookup.py CLI and update product-lifecycle skill#35
openshift-merge-bot[bot] merged 3 commits into
openshift:mainfrom
jhadvig:jhadvig/ota-2024-plc-lookup-cli

Conversation

@jhadvig

@jhadvig jhadvig commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace inline curl/jq commands in the product-lifecycle skill with a standalone Python CLI (plc_lookup.py) wrapping the Product Life Cycle API
  • Address all of Trevor's review feedback from closed PR product-lifecycle: Add plc_lookup.py CLI, migrate to v2 API #13 (36 inline comments)
  • Delete orphaned references/api-details.md
  • 22 unit tests + 7 live integration tests

Trevor's feedback addressed

Issue PR #13 behavior This PR
Status normalization (1a, 3c) STATUS_MAP with "unknown" fallback conflating distinct statuses Pass through raw API types as-is
Phase coverage (1b) Only extracted 3 hardcoded phases Include full phases array (API has 18 distinct types)
Package lookup (1e, 1f) by_package[pkg] = p silently drops duplicates defaultdict(list) preserves all products per package
Fallback search (1g) api_search(pkg) fails for packages like skupper-operator Fallback search + report unavailable if not found
Pagination (1c) --limit/--offset with no ordering guarantee Dropped entirely
former_names (3i) Not in output Included in every result entry
Executable bit (2d) python3 plc_lookup.py Shebang + chmod +x, invoked as ./plc_lookup.py
SKILL.md: allowed-tools (2a) Re-added allowed-tools frontmatter Not added
SKILL.md: API version (2b, 2c) References v2 API endpoints No version references
SKILL.md: internal details (2c) "Maps to GET /v2/products" Removed
api-details.md (2e) Deleted but replaced with CLI inline docs Deleted, SKILL.md covers CLI usage
Test assertions (3f, 3g, 3j) assertGreater, no debug hints assertEqual everywhere, debug messages
Test approach (3b) Subprocess execution Direct import via main(args=[], output=)

What's NOT changed

CI

A companion PR adds a unit presubmit CI job to run these tests on every PR: openshift/release#81732. It reuses the existing skill-scanner image (Python 3.11) and runs python3 -m unittest discover against cluster-update/product-lifecycle/scripts/tests/. Skips on docs-only and evals-only changes.

Test plan

  • Unit tests pass: python3 -m unittest cluster-update/product-lifecycle/scripts/tests/test_plc_lookup.py -v (33 pass)
  • Live integration tests pass: PLC_LIVE_TESTS=1 python3 -m unittest ... -k Live (7 pass)
  • CLI smoke test: ./cluster-update/product-lifecycle/scripts/plc_lookup.py products "logging for Red Hat OpenShift" --ocp 4.21
  • No SKILL.md regressions: no allowed-tools, no v2 references

/cc @wking

Replace inline curl/jq commands with a standalone Python CLI wrapping
the Product Life Cycle API. Addresses all review feedback from PR openshift#13:

- Pass through raw API status types instead of normalizing to custom
  strings (avoids conflating unknown statuses)
- Include all lifecycle phases in output, not just 3 hardcoded ones
  (API has 18 distinct phase types)
- Use defaultdict(list) for package-to-product lookup to preserve
  all products when multiple share a package (e.g. skupper-operator)
- Include former_names in output for search verification
- Drop pagination (--limit/--offset) as it has unclear value with
  no stable ordering guarantee from the API
- Support direct import via main(args=[], output=) for testability
- Set executable bit, rely on shebang

SKILL.md rewritten to reference the CLI tool without exposing API
version or internal tool details. Deleted orphaned api-details.md.

22 unit tests (mocked) + 7 integration tests (live API, opt-in).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 7, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 7, 2026

Copy link
Copy Markdown

@jhadvig: This pull request references OTA-2024 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 either version "5.0." or "openshift-5.0.", but it targets "openshift-5.1" instead.

Details

In response to this:

Summary

  • Replace inline curl/jq commands in the product-lifecycle skill with a standalone Python CLI (plc_lookup.py) wrapping the Product Life Cycle API
  • Address all of Trevor's review feedback from closed PR product-lifecycle: Add plc_lookup.py CLI, migrate to v2 API #13 (36 inline comments)
  • Delete orphaned references/api-details.md
  • 22 unit tests + 7 live integration tests

Trevor's feedback addressed

Issue PR #13 behavior This PR
Status normalization (1a, 3c) STATUS_MAP with "unknown" fallback conflating distinct statuses Pass through raw API types as-is
Phase coverage (1b) Only extracted 3 hardcoded phases Include full phases array (API has 18 distinct types)
Package lookup (1e, 1f) by_package[pkg] = p silently drops duplicates defaultdict(list) preserves all products per package
Fallback search (1g) api_search(pkg) fails for packages like skupper-operator Fallback search + report unavailable if not found
Pagination (1c) --limit/--offset with no ordering guarantee Dropped entirely
former_names (3i) Not in output Included in every result entry
Executable bit (2d) python3 plc_lookup.py Shebang + chmod +x, invoked as ./plc_lookup.py
SKILL.md: allowed-tools (2a) Re-added allowed-tools frontmatter Not added
SKILL.md: API version (2b, 2c) References v2 API endpoints No version references
SKILL.md: internal details (2c) "Maps to GET /v2/products" Removed
api-details.md (2e) Deleted but replaced with CLI inline docs Deleted, SKILL.md covers CLI usage
Test assertions (3f, 3g, 3j) assertGreater, no debug hints assertEqual everywhere, debug messages
Test approach (3b) Subprocess execution Direct import via main(args=[], output=)

What's NOT changed

Test plan

  • Unit tests pass: python3 -m unittest cluster-update/product-lifecycle/scripts/tests/test_plc_lookup.py -v (22 pass)
  • CLI smoke test: ./cluster-update/product-lifecycle/scripts/plc_lookup.py products "logging for Red Hat OpenShift" --ocp 4.21
  • No SKILL.md regressions: no allowed-tools, no v2 references
  • Live integration tests: PLC_LIVE_TESTS=1 python3 -m unittest ... -k Live

/cc @wking

🤖 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.

@openshift-ci
openshift-ci Bot requested a review from wking July 7, 2026 10:53
jhadvig and others added 2 commits July 7, 2026 14:48
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Skip API calls for empty/missing package names in olm-check,
  report them as lifecycle_unavailable immediately
- Add tests for api_search error handling: URLError (API down),
  invalid JSON response, and missing "data" key in response
- Add test verifying empty packages don't trigger API calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jhadvig

jhadvig commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Test results

=== Unit tests (mocked API) ===

test_invalid_json_produces_error ... ok
test_missing_data_key_produces_error ... ok
test_url_error_produces_json ... ok
Multiple products sharing a package should all appear in results. ... ok
Empty package name should not trigger an API call. ... ok
When OpenShift batch misses a package, fallback to direct search. ... ok
test_found_operator ... ok
test_mixed_found_and_unavailable ... ok
test_unavailable_operator ... ok
test_found ... ok
test_no_ocp_target ... ok
test_not_found ... ok
test_with_ocp_target ... ok
test_all_phases_included ... ok
test_basic_format ... ok
test_no_ocp_fields_without_target ... ok
test_ocp_compatible_false ... ok
test_ocp_compatible_none_when_no_compat_data ... ok
test_ocp_compatible_true ... ok
Raw API types are passed through without normalization. ... ok
test_main_help ... ok
test_olm_check_help ... ok
test_products_help ... ok
test_comma_separated ... ok
test_empty_string ... ok
test_none ... ok
Ran 33 tests in 0.019s
OK (skipped=7)

=== Live API integration tests ===

test_former_names_preserved ... ok
test_logging_ocp_311_not_compatible ... ok
test_logging_ocp_421_compatible ... ok
test_logging_product_found ... ok
test_ocp_product_found ... ok
test_olm_check_cluster_logging ... ok
test_olm_check_nonexistent ... ok
Ran 7 tests in 3.326s
OK

=== CLI smoke tests ===

$ ./plc_lookup.py products "logging for Red Hat OpenShift" --ocp 4.21
  total: 16, ocp_target: 4.21
  logging for Red Hat OpenShift 6.5 - Full Support (OCP 4.21: True)
  logging for Red Hat OpenShift 6.4 - Full Support (OCP 4.21: True)
  logging for Red Hat OpenShift 6.3 - Maintenance Support (OCP 4.21: False)

$ ./plc_lookup.py olm-check --ocp 4.21 --operators '[{"package":"cluster-logging"},{"package":"web-terminal"},{"package":"nonexistent-op"}]'
  operators_checked: 3
  lifecycle_unavailable: ["nonexistent-op"]
  Products found: ['logging for Red Hat OpenShift', 'web terminal operator']

26 unit tests + 7 live API tests pass. CLI produces correct structured JSON output.

@jhadvig

jhadvig commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

@wking PTAL 🙏

@matzew matzew left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm
/approve

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

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhadvig, matzew

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 Jul 14, 2026
@matzew

matzew commented Jul 16, 2026

Copy link
Copy Markdown
Member

/override eval

(The eval failure is pre-existing)

@matzew

matzew commented Jul 16, 2026

Copy link
Copy Markdown
Member

/override "ci/prow/eval"

@matzew

matzew commented Jul 16, 2026

Copy link
Copy Markdown
Member

/override ci/prow/eval

@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown

@matzew: /override requires failed status contexts, check run or a prowjob name to operate on.
The following unknown contexts/checkruns were given:

  • eval

Only the following failed contexts/checkruns were expected:

  • ci/prow/eval
  • ci/prow/images
  • pull-ci-openshift-agentic-skills-main-eval
  • pull-ci-openshift-agentic-skills-main-images
  • tide

If you are trying to override a checkrun that has a space in it, you must put a double quote on the context.

Details

In response to this:

/override eval

(The eval failure is pre-existing)

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.

@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown

@matzew: Overrode contexts on behalf of matzew: ci/prow/eval

Details

In response to this:

/override "ci/prow/eval"

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.

@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown

@matzew: Overrode contexts on behalf of matzew: ci/prow/eval

Details

In response to this:

/override ci/prow/eval

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.

@jhadvig

jhadvig commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

/verified by @jhadvig

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

Copy link
Copy Markdown

@jhadvig: This PR has been marked as verified by @jhadvig.

Details

In response to this:

/verified by @jhadvig

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 Jul 16, 2026

Copy link
Copy Markdown

@jhadvig: 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.

@openshift-merge-bot
openshift-merge-bot Bot merged commit 3689989 into openshift:main Jul 16, 2026
3 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. 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