Skip to content

feat(controller): add OCP version auto-detection for RAG configuration#72

Closed
omkarjoshi0304 wants to merge 0 commit into
openstack-lightspeed:mainfrom
omkarjoshi0304:OSPRH-23918
Closed

feat(controller): add OCP version auto-detection for RAG configuration#72
omkarjoshi0304 wants to merge 0 commit into
openstack-lightspeed:mainfrom
omkarjoshi0304:OSPRH-23918

Conversation

@omkarjoshi0304

Copy link
Copy Markdown
Contributor

Description

This PR implements the automatic detection of the OpenShift (OCP) cluster version to dynamically select the correct RAG database directory and index name.

Key Changes

  1. Auto-Detection: The operator now queries the config.openshift.io/v1/ClusterVersion API.
  2. Smart Resolution:
    • Matches detected version to supported DB paths (e.g., 4.16 -> /ocp/4.16).
    • Fallback Logic: If the detected version is newer or unsupported (e.g., 4.20), it defaults to latest and sets a Warning condition in the Status.
  • Status Fields Added:
    • detectedOCPVersion: The actual version found on the cluster.
    • activeOCPVersion: The version string used for paths (e.g., latest or 4.18).
    • ocpVersionFallback: Boolean flag indicating if fallback logic was used.

Testing / Verification

I have verified this functionality on a local CRC environment running OCP 4.20 (which triggers the fallback logic as expected).

1. Verification of Logic (Unit Tests)

Ran go test ./internal/controller/... covering detection, path generation, and fallback logic.

=== RUN   TestResolveOCPVersion/Unsupported_version_-_fallback
--- PASS: TestResolveOCPVersion/Unsupported_version_-_fallback (0.00s)
PASS

### 2. Verification from live cluster (operator log)

2026-01-22T14:13:55Z	INFO	Controllers.OpenStackLightspeed	OpenStackLightspeed Reconciling	{"controller": "openstacklightspeed", "controllerGroup": "lightspeed.openstack.org", "controllerKind": "OpenStackLightspeed", "OpenStackLightspeed": {"name":"test-lightspeed-2","namespace":"openshift-lightspeed"}, "namespace": "openshift-lightspeed", "name": "test-lightspeed-2", "reconcileID": "c693ac3f-c64b-4537-b02d-ebdc66bcd9fc"}
2026-01-22T14:13:55Z	INFO	Controllers.OpenStackLightspeed	Detected OCP cluster version	{"controller": "openstacklightspeed", "controllerGroup": "lightspeed.openstack.org", "controllerKind": "OpenStackLightspeed", "OpenStackLightspeed": {"name":"test-lightspeed-2","namespace":"openshift-lightspeed"}, "namespace": "openshift-lightspeed", "name": "test-lightspeed-2", "reconcileID": "c693ac3f-c64b-4537-b02d-ebdc66bcd9fc", "version": "4.20"}
2026-01-22T14:13:55Z	INFO	Controllers.OpenStackLightspeed	Using 'latest' OCP documentation as fallback	{"controller": "openstacklightspeed", "controllerGroup": "lightspeed.openstack.org", "controllerKind": "OpenStackLightspeed", "OpenStackLightspeed": {"name":"test-lightspeed-2","namespace":"openshift-lightspeed"}, "namespace": "openshift-lightspeed", "name": "test-lightspeed-2", "reconcileID": "c693ac3f-c64b-4537-b02d-ebdc66bcd9fc", "detectedVersion": "4.20", "supportedVersions": ["4.16", "4.18", "latest"]}

### 2. Verification from live cluster (CR Status Output)

status:
activeOCPVersion: latest
conditions:

  • lastTransitionTime: "2026-01-22T10:46:39Z"
    message: Waiting for the OpenShift Lightspeed operator to deploy.
    reason: Requested
    severity: Info
    status: "False"
    type: Ready
  • lastTransitionTime: "2026-01-22T13:45:28Z"
    message: 'Cluster version 4.20 is not explicitly supported. Using ''latest'' OCP
    documentation. Supported versions: [4.16 4.18 latest]'
    reason: Ready
    status: "True"
    type: OCPVersionResolved
  • lastTransitionTime: "2026-01-22T10:46:39Z"
    message: Waiting for the OpenShift Lightspeed operator to deploy.
    reason: Requested
    severity: Info
    status: "False"
    type: OpenShiftLightspeedOperatorReady
  • lastTransitionTime: "2026-01-22T10:46:39Z"
    message: OpenStack Lightspeed not started
    reason: Init
    status: Unknown
    type: OpenStackLightspeedReady
    detectedOCPVersion: "4.20"
    observedGeneration: 1
    ocpVersionFallback: true

@openshift-ci openshift-ci Bot requested review from lpiwowar and umago January 22, 2026 14:18
@softwarefactory-project-zuul

Copy link
Copy Markdown

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/openstack-lightspeed/operator for 72,f0104feb8c94da260d7fd68df067eff52f5c9242

@openshift-merge-robot

Copy link
Copy Markdown
Collaborator

PR needs rebase.

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.

@softwarefactory-project-zuul

Copy link
Copy Markdown

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/openstack-lightspeed/operator for 72,26797aa65251f41f81e9da28530e4cc4bb9acbfd

@openshift-ci

openshift-ci Bot commented Jan 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: omkarjoshi0304

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants