[OTA-1975] pass products-data cincinnati endpoint to plcc#1429
[OTA-1975] pass products-data cincinnati endpoint to plcc#1429ankitathomas wants to merge 1 commit into
Conversation
Signed-off-by: Ankita Thomas <[email protected]>
WalkthroughAgentic-run synchronization now passes a typed Kubernetes client through discovery, resolves an optional Cincinnati Route URL, and includes it in generated requests. Tests cover discovery failures, URL inclusion, omission, and updated helper signatures. ChangesAgentic Run Cincinnati URL Integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Sync
participant getAgenticRun
participant KubernetesClient
participant buildRequest
Sync->>getAgenticRun: pass typed client and context
getAgenticRun->>KubernetesClient: discover Cincinnati Service and Route
KubernetesClient-->>getAgenticRun: return Route host or error
getAgenticRun->>buildRequest: provide Cincinnati URL or empty value
buildRequest-->>getAgenticRun: return generated request text
Suggested reviewers: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (13 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ankitathomas The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
pkg/agenticrun/controller.go (1)
561-564: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNamespace string duplicated.
"openshift-update-service"is repeated for both the Service and Route lists. Extracting it to a package-level constant would avoid drift if it's ever changed.Also applies to: 585-586
🤖 Prompt for 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. In `@pkg/agenticrun/controller.go` around lines 561 - 564, The namespace string is duplicated across the service and route listing logic. Define a package-level constant for "openshift-update-service" and update the Service list and Route list calls in the controller to use that constant instead of repeating the literal.
🤖 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 `@pkg/agenticrun/controller.go`:
- Around line 438-449: Move the single `discoverCincinnatiURL` call from
`getAgenticRun` into `getAgenticRuns`, then pass its resolved URL into each
`getAgenticRun` invocation. Update `getAgenticRun` to accept a `cincinnatiURL
string` parameter, remove its unused `client` parameter and discovery block, and
preserve the existing error fallback and request construction behavior.
- Around line 438-449: Guard the discoverCincinnatiURL call in the agentic run
request flow against a nil client before invoking it, preserving the empty
cincinnatiURL fallback and allowing request construction to continue. Use the
existing client variable and keep normal discovery and error logging behavior
unchanged for non-nil clients.
---
Nitpick comments:
In `@pkg/agenticrun/controller.go`:
- Around line 561-564: The namespace string is duplicated across the service and
route listing logic. Define a package-level constant for
"openshift-update-service" and update the Service list and Route list calls in
the controller to use that constant instead of repeating the literal.
🪄 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 YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: ce315c75-1ea9-4939-b8b4-d7b1616242d5
📒 Files selected for processing (2)
pkg/agenticrun/controller.gopkg/agenticrun/controller_test.go
| // Discover Cincinnati URL | ||
| cincinnatiURL, err := discoverCincinnatiURL(ctx, client) | ||
| if err != nil { | ||
| klog.V(i.Normal).Infof("Could not discover Cincinnati URL: %v (skills will use public API only)", err) | ||
| cincinnatiURL = "" | ||
| } else { | ||
| klog.V(i.Normal).Infof("Discovered Cincinnati URL: %s", cincinnatiURL) | ||
| } | ||
|
|
||
| name := agenticRunName(currentVersion, targetVersion) | ||
| updateType := classifyUpdate(currentVersion, targetVersion) | ||
| request := buildRequest(systemPrompt, currentVersion, targetVersion, channel, updateType, updateKind, availableUpdates, readinessJSON) | ||
| request := buildRequest(systemPrompt, currentVersion, targetVersion, channel, updateType, updateKind, availableUpdates, readinessJSON, cincinnatiURL) |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
Redundant Cincinnati discovery: called once per update instead of once per Sync.
discoverCincinnatiURL is invoked from getAgenticRun, which runs once per availableUpdate/conditionalUpdate (lines 404, 415). Its result doesn't depend on currentVersion/targetVersion, so with N updates this issues 2N redundant List calls (Services + Routes) against the API server for an identical answer. Hoist the discovery to getAgenticRuns (called once) and pass the resolved cincinnatiURL down, dropping the now-unused client param from getAgenticRun.
♻️ Proposed refactor
func getAgenticRuns(
ctx context.Context,
dynamicClient dynamic.Interface,
client ctrlruntimeclient.Client,
availableUpdates []configv1.Release,
conditionalUpdates []configv1.ConditionalUpdate,
namespace string,
currentVersion, channel,
systemPrompt string,
skillsImage string,
) ([]*agenticrunv1alpha1.AgenticRun, error) {
+ cincinnatiURL, err := discoverCincinnatiURL(ctx, client)
+ if err != nil {
+ klog.V(i.Normal).Infof("Could not discover Cincinnati URL: %v (skills will use public API only)", err)
+ cincinnatiURL = ""
+ } else {
+ klog.V(i.Normal).Infof("Discovered Cincinnati URL: %s", cincinnatiURL)
+ }
+
var errs []error
var agenticRuns []*agenticrunv1alpha1.AgenticRun
for _, au := range availableUpdates {
targetVersion := au.Version
readinessJSON := runReadinessJSON(ctx, dynamicClient, currentVersion, targetVersion)
- if agenticRun, err := getAgenticRun(ctx, client, namespace, currentVersion, targetVersion, channel, updateKindRecommended, systemPrompt, readinessJSON, availableUpdates, skillsImage); err != nil {
+ if agenticRun, err := getAgenticRun(ctx, namespace, currentVersion, targetVersion, channel, updateKindRecommended, systemPrompt, readinessJSON, availableUpdates, skillsImage, cincinnatiURL); err != nil {And drop the client/discovery block from getAgenticRun (lines 426, 438-446), adding a cincinnatiURL string param instead.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Discover Cincinnati URL | |
| cincinnatiURL, err := discoverCincinnatiURL(ctx, client) | |
| if err != nil { | |
| klog.V(i.Normal).Infof("Could not discover Cincinnati URL: %v (skills will use public API only)", err) | |
| cincinnatiURL = "" | |
| } else { | |
| klog.V(i.Normal).Infof("Discovered Cincinnati URL: %s", cincinnatiURL) | |
| } | |
| name := agenticRunName(currentVersion, targetVersion) | |
| updateType := classifyUpdate(currentVersion, targetVersion) | |
| request := buildRequest(systemPrompt, currentVersion, targetVersion, channel, updateType, updateKind, availableUpdates, readinessJSON) | |
| request := buildRequest(systemPrompt, currentVersion, targetVersion, channel, updateType, updateKind, availableUpdates, readinessJSON, cincinnatiURL) | |
| name := agenticRunName(currentVersion, targetVersion) | |
| updateType := classifyUpdate(currentVersion, targetVersion) | |
| request := buildRequest(systemPrompt, currentVersion, targetVersion, channel, updateType, updateKind, availableUpdates, readinessJSON, cincinnatiURL) |
🤖 Prompt for 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.
In `@pkg/agenticrun/controller.go` around lines 438 - 449, Move the single
`discoverCincinnatiURL` call from `getAgenticRun` into `getAgenticRuns`, then
pass its resolved URL into each `getAgenticRun` invocation. Update
`getAgenticRun` to accept a `cincinnatiURL string` parameter, remove its unused
`client` parameter and discovery block, and preserve the existing error fallback
and request construction behavior.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm both call sites pass literal nil for the new client param.
rg -n -B2 -A2 'getAgenticRuns\(' pkg/agenticrun/controller_test.goRepository: openshift/cluster-version-operator
Length of output: 436
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the helper and its callers, then inspect the relevant slice of controller.go.
rg -n "func discoverCincinnatiURL|discoverCincinnatiURL\(" pkg/agenticrun/controller.go pkg/agenticrun/controller_test.go
echo
echo "---- controller.go excerpt ----"
sed -n '380,470p' pkg/agenticrun/controller.go
echo
echo "---- controller_test.go excerpt around first call site ----"
sed -n '1068,1090p' pkg/agenticrun/controller_test.go
echo
echo "---- controller_test.go excerpt around second call site ----"
sed -n '1288,1310p' pkg/agenticrun/controller_test.goRepository: openshift/cluster-version-operator
Length of output: 6153
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Probe Go interface semantics for a typed-nil vs truly nil interface call,
# to distinguish panic behavior if the code path reaches client.List on a nil interface.
cat >/tmp/niliface.go <<'PY'
package main
import "fmt"
type C interface{ List() error }
func call(c C) (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("panic: %v", r)
}
}()
return c.List()
}
func main() {
var c C = nil
fmt.Printf("%v\n", call(c))
}
PY
go run /tmp/niliface.goRepository: openshift/cluster-version-operator
Length of output: 244
Guard discoverCincinnatiURL against a nil client
TestGetAgenticRuns_WithReadinessData passes nil for the controller client, and discoverCincinnatiURL calls client.List(...) unconditionally. That panics before the empty-URL fallback can run. Add a nil check here or pass a fake client in the test.
🤖 Prompt for 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.
In `@pkg/agenticrun/controller.go` around lines 438 - 449, Guard the
discoverCincinnatiURL call in the agentic run request flow against a nil client
before invoking it, preserving the empty cincinnatiURL fallback and allowing
request construction to continue. Use the existing client variable and keep
normal discovery and error logging behavior unchanged for non-nil clients.
|
@ankitathomas: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Follow-on work to support openshift/cincinnati#1072 and openshift/cincinnati-operator#270
Summary by CodeRabbit
New Features
Bug Fixes