Skip to content

[OTA-2089] fall back to local source for plc_lookup - #45

Open
ankitathomas wants to merge 2 commits into
openshift:mainfrom
ankitathomas:plcc-products-json
Open

[OTA-2089] fall back to local source for plc_lookup#45
ankitathomas wants to merge 2 commits into
openshift:mainfrom
ankitathomas:plcc-products-json

Conversation

@ankitathomas

Copy link
Copy Markdown

Include product lifecycle data as a file in agentic-skills image and have plc_lookup.py use the local file if the products lifecycle API is unreachable, such as in a disconnected environment.

Comment thread Containerfile Outdated
@ankitathomas
ankitathomas force-pushed the plcc-products-json branch 2 times, most recently from caf8fcf to c6b66eb Compare July 29, 2026 15:35
@ankitathomas
ankitathomas requested a review from wking July 29, 2026 15:41

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

Just a few nits. Also perhaps data/product.json should be back to the repo (and later addressed/updated via PR with github action or something similar)

Comment thread cluster-update/product-lifecycle/scripts/plc_lookup.py Outdated
Comment thread cluster-update/product-lifecycle/scripts/plc_lookup.py Outdated
Comment thread cluster-update/product-lifecycle/scripts/plc_lookup.py Outdated
@ankitathomas
ankitathomas force-pushed the plcc-products-json branch 4 times, most recently from 1471a6f to 384507c Compare August 12, 2026 14:45

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

Hi Ankita! Thanks for the fallback code. I've tested with many combinations using both live and fallback data and it looks it mirrors the search logic properly. Nice job! Just a note about connectivity check, it looks redundant and can be simplified.

API_BASE = "https://access.redhat.com/product-life-cycles/api/v2/products"
PRODUCTS_PATH = os.path.join(os.path.dirname(__file__), "data", "products.json")

def check_connectivity(url, timeout=5):

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.

I think this could be simplified. The same checks are already performed on the api_search so maybe you can just call the fallback function in the exception handling of the api_search. Having this check also makes the live api to be called twice in a happy path where API is available. So perhaps, consider removing it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch, moved the fallback logic to when the api is unreachable

Comment thread cluster-update/product-lifecycle/scripts/plc_snapshot.sh
Comment thread cluster-update/product-lifecycle/scripts/plc_snapshot.sh Outdated
@jrangelramos

Copy link
Copy Markdown
Member

Hello @ankitathomas the test test_url_error_produces_json is failing. With the new fallback logic you may need to mock search_local as well (to simulate missing the local products file). Other than that it looks good to me

@jrangelramos

Copy link
Copy Markdown
Member

/lgtm

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

@jrangelramos jrangelramos 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

@jrangelramos

Copy link
Copy Markdown
Member

/verified by @jrangelramos

Ran locally a bunch of lookup test and compared results with live api.

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 17, 2026
@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Aug 17, 2026
@openshift-ci-robot

Copy link
Copy Markdown

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

Details

In response to this:

/verified by @jrangelramos

Ran locally a bunch of lookup test and compared results with live api.

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 removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 17, 2026
@openshift-ci

openshift-ci Bot commented Aug 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ankitathomas
Once this PR has been reviewed and has the lgtm label, please assign hongkailiu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@jrangelramos

Copy link
Copy Markdown
Member

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 18, 2026
import urllib.request

API_BASE = "https://access.redhat.com/product-life-cycles/api/v2/products"
PRODUCTS_PATH = os.path.join(os.path.dirname(__file__), "data", "products.json")

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.

This file isn't committed so wouldn't be in the final image built from this repo. Is there any plan for this to be committed and/or mounted into wherever this will be run?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, the file will be updated by a periodic job calling ‎cluster-update/product-lifecycle/scripts/plc_snapshot.sh‎ on changes to the contents served by the product lifecycle api. The file is not present yet due to some concerns about the 5.0 lifecycle information's availability via the api.

Comment thread cluster-update/product-lifecycle/scripts/plc_lookup.py
Comment thread cluster-update/product-lifecycle/scripts/plc_lookup.py Outdated
Comment thread cluster-update/product-lifecycle/scripts/tests/test_plc_lookup.py Outdated
Comment thread cluster-update/product-lifecycle/scripts/plc_lookup.py
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 31, 2026
@ankitathomas
ankitathomas requested a review from Cali0707 August 31, 2026 14:10
@jrangelramos

Copy link
Copy Markdown
Member

Hello @ankitathomas Apparently there is still some logic mismatch when search criteria contains comma.
Here some tests when using live api vs when using fallback products.json file.

with live api

$ python3 plc_lookup.py products "mcp,openshift"         
{
  "error": "no products found",
  "query": "mcp,openshift"
}
$ python3 plc_lookup.py products "compliance,operator"         
{
  "error": "no products found",
  "query": "compliance,operator"
}

with fake url -> fallback to products.json

$ python3 plc_lookup.py products "mcp,openshift" | wc -l 
15061
$ python3 plc_lookup.py products "compliance,operator"
Traceback (most recent call last):
  File "/home/jeramos/pixaa/test/test-ocp5/agentic-skills/cluster-update/product-lifecycle/scripts/plc_lookup.py", line 266, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/jeramos/pixaa/test/test-ocp5/agentic-skills/cluster-update/product-lifecycle/scripts/plc_lookup.py", line 262, in main
    return handlers[parsed.command](parsed, output=output)
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeramos/pixaa/test/test-ocp5/agentic-skills/cluster-update/product-lifecycle/scripts/plc_lookup.py", line 138, in cmd_products
    results.append(format_product_version(p, v, target_ocp=target_ocp))
                   ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeramos/pixaa/test/test-ocp5/agentic-skills/cluster-update/product-lifecycle/scripts/plc_lookup.py", line 107, in format_product_version
    "version": version["name"],
               ~~~~~~~^^^^^^^^
KeyError: 'name'

Signed-off-by: Ankita Thomas <ankithom@redhat.com>
Signed-off-by: Ankita Thomas <ankithom@redhat.com>
@ankitathomas

Copy link
Copy Markdown
Author

$ python3 plc_lookup.py products "compliance,operator"
Traceback (most recent call last):
File "/home/jeramos/pixaa/test/test-ocp5/agentic-skills/cluster-update/product-lifecycle/scripts/plc_lookup.py", line 266, in
sys.exit(main())
~~~~^^
File "/home/jeramos/pixaa/test/test-ocp5/agentic-skills/cluster-update/product-lifecycle/scripts/plc_lookup.py", line 262, in main
return handlers[parsed.command](parsed, output=output)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jeramos/pixaa/test/test-ocp5/agentic-skills/cluster-update/product-lifecycle/scripts/plc_lookup.py", line 138, in cmd_products
results.append(format_product_version(p, v, target_ocp=target_ocp))
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jeramos/pixaa/test/test-ocp5/agentic-skills/cluster-update/product-lifecycle/scripts/plc_lookup.py", line 107, in format_product_version
"version": version["name"],
~~~~~~~^^^^^^^^
KeyError: 'name'

Good catch! Turns out two entries in the product lifecycle api are being shipped without a version. That seems like a mistake, but I've added some checks so the script does not panic.

@openshift-ci

openshift-ci Bot commented Sep 1, 2026

Copy link
Copy Markdown

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

@jrangelramos

Copy link
Copy Markdown
Member

/lgtm

@jrangelramos

Copy link
Copy Markdown
Member

/verified by @jrangelramos

@openshift-ci-robot

Copy link
Copy Markdown

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

Details

In response to this:

/verified by @jrangelramos

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 Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

5 participants