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.

Signed-off-by: Ankita Thomas <ankithom@redhat.com>
Signed-off-by: Ankita Thomas <ankithom@redhat.com>
@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

@openshift-ci

openshift-ci Bot commented Aug 17, 2026

Copy link
Copy Markdown

@ankitathomas: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/eval cb21827 link true /test eval

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

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

Comment on lines +42 to +43
if "name" in i and n in i["name"].lower():
names.append(i)

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.

let's do some deduplication here, otherwise we can end up with the same product twice (or maybe there is some structure to this data that prevents this, but it is not clear from this PR/comment that there is).

For example, something like name="mcp,openshift" with a product name `"MCP Server for Red Hat OpenShift" would end up matching twice

url = API_BASE
if name:
url = f"{url}?{urllib.parse.urlencode({'name': name})}"
url = f"{url}?{urllib.parse.urlencode({'name': name})}&match_mode=contains"

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.

shouldn't we urlencode the match_mode=contains as well?

self.assertEqual(result[0]["name"], "logging for Red Hat OpenShift")
finally:
os.unlink(temp_path)
def test_former_names_fallback_logic(self):

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.

doesn't this test case make more sense in TestSearchLocal ?



def api_search(name=None):
def search_local(name=None, path=PRODUCTS_PATH):

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.

nit: we should add one more blank line above this function, PEP 8 requires two blank lines between top-level function definitions

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