Skip to content

Add adapter to create Lightspeed Proposal after must-gather completion#365

Draft
sakshiep1 wants to merge 2 commits into
openshift:masterfrom
sakshiep1:adapter
Draft

Add adapter to create Lightspeed Proposal after must-gather completion#365
sakshiep1 wants to merge 2 commits into
openshift:masterfrom
sakshiep1:adapter

Conversation

@sakshiep1

@sakshiep1 sakshiep1 commented Jun 18, 2026

Copy link
Copy Markdown

Summary

Adds an adapter in the must-gather operator that automatically creates a Lightspeed
Proposal CR for agentic root-cause analysis when a MustGather job completes
successfully with spec.agenticDebuggingEnabled: true.

This enables the end-to-end flow:

MustGather (with storage) → must-gather collection → Job success → Proposal created
→ Lightspeed agentic operator runs IntelliAide analysis on the must-gather PVC.

Changes

  • Add optional spec.agenticDebuggingEnabled field to the MustGather CRD
  • Add controllers/mustgather/proposal.go with adapter logic:
    • Guard checks: opt-in flag, spec.storage set, Lightspeed installed (Proposal CRD discovery), idempotency
    • Creates Proposal in openshift-lightspeed using unstructured objects (no hard dependency on lightspeed-agentic-operator Go types)
    • Proposal spec includes IntelliAide skills image, paths: [/skills/intelliaide], PVC dataSource, and IntelliAide-specific request text
  • Hook adapter into handleJobCompletion() on successful Job completion (best-effort; failures do not block MustGather completion)
  • Add ClusterRole RBAC for proposals.agentic.openshift.io (get, create)

Design notes

  • Optional dependency: If OpenShift Lightspeed Agentic is not installed, the adapter is a no-op.
  • Namespace requirement: The must-gather PVC and MustGather CR should be created in openshift-lightspeed so the analysis pod can mount the same PVC (PVCs are namespace-scoped).

Test plan

  • Deployed updated operator image to a test cluster with Lightspeed Agentic installed
  • Created SA, PVC, and MustGather CR in openshift-lightspeed with agenticDebuggingEnabled: true and storage configured
  • Verified must-gather Job completes and writes data to PVC
  • Verified adapter creates Proposal (intelliaide-<mustgather-name>) in openshift-lightspeed
  • Verified analysis pod starts and mounts skills image + PVC at /data/input
  • Upstream CI: make go-test, make lint

Summary by CodeRabbit

  • New Features
    • Added optional agentic debugging for must-gather operations. When enabled, automatically creates a Lightspeed Proposal for analysis after successful completion.
    • Requires must-gather storage configuration to be set for persistence.
  • Bug Fixes
    • Proposal creation is now best-effort: failures no longer block normal must-gather completion and cleanup.
  • Documentation
    • Updated MustGather CRD schema and validation behavior to reflect the new option.

@openshift-ci

openshift-ci Bot commented Jun 18, 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 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 Jun 18, 2026
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0ae746b2-2a1f-4a82-8c34-b5d18cf1824d

📥 Commits

Reviewing files that changed from the base of the PR and between 3ff3d65 and f0e61ba.

⛔ Files ignored due to path filters (1)
  • api/v1alpha1/zz_generated.deepcopy.go is excluded by !**/zz_generated*
📒 Files selected for processing (3)
  • api/v1alpha1/mustgather_types.go
  • controllers/mustgather/proposal.go
  • deploy/crds/operator.openshift.io_mustgathers.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/v1alpha1/mustgather_types.go

Walkthrough

Adds an optional agenticDebuggingEnabled field to MustGatherSpec. When enabled and a PVC storage is configured, the controller calls a new createIntelliAideProposal function after a successful must-gather job, which checks for Lightspeed installation via discovery and idempotently creates an unstructured Proposal CR. RBAC permissions for agentic.openshift.io proposals are added to both the controller annotations and the ClusterRole manifest.

Changes

Agentic Debugging Integration

Layer / File(s) Summary
API contract and CRD validation
api/v1alpha1/mustgather_types.go, deploy/crds/operator.openshift.io_mustgathers.yaml
Adds optional agenticDebuggingEnabled pointer bool to MustGatherSpec (defaulting to false) with kubebuilder validation enforcing spec.storage presence. CRD schema is updated with the field, default, and validation rule; controller-gen version annotation is bumped.
Proposal creation logic
controllers/mustgather/proposal.go
New file defining Proposal API constants, GroupVersionResource, and isLightspeedInstalled() via discovery client. createIntelliAideProposal() implements guard conditions (feature flag, PVC, namespace, Lightspeed availability), idempotent Get-before-Create for existing Proposals, and construction of an unstructured Proposal CR with request content, target namespaces, skill configuration, and data source reference.
Controller integration and RBAC permissions
controllers/mustgather/mustgather_controller.go, deploy/02_must-gather-operator.ClusterRole.yaml
Adds RBAC annotation granting get and create on agentic.openshift.io proposals to the controller. handleJobCompletion() wires a best-effort createIntelliAideProposal() call when job status is "Completed". ClusterRole manifest adds the corresponding rule for proposal access.

Sequence Diagram(s)

sequenceDiagram
  participant Job as Kubernetes Job
  participant Controller as MustGatherReconciler
  participant ProposalLogic as proposal.go
  participant Discovery as DiscoveryClient
  participant K8s as Kubernetes API

  Job-->>Controller: Job status = Completed
  Controller->>ProposalLogic: createIntelliAideProposal(ctx, mustGather)
  ProposalLogic->>ProposalLogic: agenticDebuggingEnabled && spec.storage set?
  ProposalLogic->>K8s: Get Proposal by name/namespace
  alt Already exists
    K8s-->>ProposalLogic: Proposal found
    ProposalLogic-->>Controller: nil
  else Not found
    ProposalLogic->>Discovery: ServerResourcesForGroupVersion(agentic.openshift.io)
    Discovery-->>ProposalLogic: resources or error
    ProposalLogic->>K8s: Create unstructured Proposal CR (PVC, image, namespaces)
    K8s-->>ProposalLogic: OK or CRD missing
    ProposalLogic-->>Controller: nil
  end
  Controller->>Controller: continue completion/cleanup flow
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning No tests were added for the new 194-line proposal.go file with complex logic (two public functions: isLightspeedInstalled and createIntelliAideProposal with multiple guard conditions, idempotency l... Add proposal_test.go or update mustgather_controller_test.go with test cases covering: guard conditions (flag, storage, namespace, Lightspeed install), idempotency, successful creation, NoMatch errors, and existing Proposal detection.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the primary change—adding an adapter to create Lightspeed Proposal after must-gather completion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed No Ginkgo test files were added or modified in this PR. The PR only adds implementation code (proposal.go) and updates to CRD types and deployment configurations, with no test code changes.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added in this PR. The changes consist only of CRD type definitions, controller logic, proposal adapter code, and manifests—no test files were added or modified.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests (It(), Describe(), Context(), When()) were added in this PR. Changes are limited to controller implementation, types, RBAC, and CRD definitions.
Topology-Aware Scheduling Compatibility ✅ Passed PR adds CRD field, controller logic, and RBAC for Lightspeed Proposal creation with no scheduling constraints (no affinity, topology spread, nodeSelector, or replica logic).
Ote Binary Stdout Contract ✅ Passed PR modifies the must-gather operator binary (not OTE test code) and uses proper stderr-directed logging throughout (logf.Log + zap). No stdout writes in process-level code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo e2e tests are added in this PR. All changes are implementation files (CRD types, controller logic, proposal adapter) and manifest updates. The check is not applicable.
No-Weak-Crypto ✅ Passed No weak cryptographic algorithms, custom crypto implementations, or non-constant-time secret comparisons found in the PR changes.
Container-Privileges ✅ Passed No container privilege escalation found. All modified files (types, controller, proposal adapter, RBAC, CRD) are clean of privileged settings.
No-Sensitive-Data-In-Logs ✅ Passed All logging statements only expose non-sensitive data: resource identifiers (mustgather.Name, pvcName, namespaces) and standard error objects. No passwords, tokens, API keys, PII, or sensitive cred...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci

openshift-ci Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sakshiep1
Once this PR has been reviewed and has the lgtm label, please assign shivprakashmuley 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@controllers/mustgather/proposal.go`:
- Around line 99-101: The Proposal is always created in the openshift-lightspeed
namespace, but the pvcName is retrieved from the MustGather spec which may be in
a different namespace. Since PVCs are namespace-scoped, this causes invalid
Proposal data when the MustGather instance is outside openshift-lightspeed. Add
a guard condition before creating the Proposal (before the pvcName and
proposalName variable assignments) that checks if the instance namespace equals
openshift-lightspeed, and skip or reject Proposal creation if the namespaces do
not match.

In `@deploy/crds/operator.openshift.io_mustgathers.yaml`:
- Around line 103-110: The agenticDebuggingEnabled field currently accepts true
values even when spec.storage is not configured, resulting in non-functional
accepted configurations. Add a validation rule to the agenticDebuggingEnabled
field definition in the mustgathers CRD schema that enforces the prerequisite:
reject configurations where agenticDebuggingEnabled is set to true unless
spec.storage is also specified. This can be accomplished by adding a CEL
validation rule that checks if agenticDebuggingEnabled is true, then requires
spec.storage to be non-empty, preventing invalid configurations from being
accepted by the API server.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ef390d95-a11a-4f2f-a4a6-a44867458290

📥 Commits

Reviewing files that changed from the base of the PR and between e65f61a and 3ff3d65.

⛔ Files ignored due to path filters (1)
  • api/v1alpha1/zz_generated.deepcopy.go is excluded by !**/zz_generated*
📒 Files selected for processing (5)
  • api/v1alpha1/mustgather_types.go
  • controllers/mustgather/mustgather_controller.go
  • controllers/mustgather/proposal.go
  • deploy/02_must-gather-operator.ClusterRole.yaml
  • deploy/crds/operator.openshift.io_mustgathers.yaml

Comment thread controllers/mustgather/proposal.go
Comment thread deploy/crds/operator.openshift.io_mustgathers.yaml
…osal spec.

Use an IntelliAide-specific request prompt, add targetNamespaces, and increase
analysis timeout so the agent follows the skills pipeline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants