OLS-3274: inject audit env vars into sandbox pods from AgenticOLSConfig#232
OLS-3274: inject audit env vars into sandbox pods from AgenticOLSConfig#232vimalk78 wants to merge 1 commit into
Conversation
|
@vimalk78: This pull request references OLS-3274 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
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. |
|
Warning Review limit reached
More reviews will be available in 45 minutes and 31 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe controller now reads audit settings from ChangesAudit config propagation
Sequence Diagram(s)sequenceDiagram
participant EnsureAgentTemplate
participant readAuditConfig
participant computeTemplateHash
participant patchAuditEnvVars
participant "client.Client" as clientClient
EnsureAgentTemplate->>readAuditConfig: load cluster audit config
readAuditConfig->>clientClient: Get AgenticOLSConfig "cluster"
clientClient-->>readAuditConfig: *AuditConfig or nil
readAuditConfig-->>EnsureAgentTemplate: audit config
EnsureAgentTemplate->>computeTemplateHash: include audit logging and OTEL endpoint
EnsureAgentTemplate->>patchAuditEnvVars: patch template env vars
patchAuditEnvVars->>readAuditConfig: load cluster audit config
readAuditConfig->>clientClient: Get AgenticOLSConfig "cluster"
clientClient-->>patchAuditEnvVars: *AuditConfig or nil
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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: 1
🧹 Nitpick comments (1)
controller/proposal/sandbox_templates.go (1)
231-233: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAudit config is read twice; the hash and the patched env vars can diverge.
EnsureAgentTemplatereads audit config at Line 176 to compute the template name/hash, thenpatchAuditEnvVars(Line 749) callsreadAuditConfigagain. Besides the redundant APIGet, if the CR changes between the two reads, the template name reflects the first read while its env vars reflect the second — the name no longer describes its contents. Reuse the already-fetched value.Proposed fix: pass audit into the patch helper
- if err := patchAuditEnvVars(ctx, c, derived); err != nil { + if err := patchAuditEnvVars(derived, audit); err != nil { return "", fmt.Errorf("patch audit env vars: %w", err) }-func patchAuditEnvVars(ctx context.Context, c client.Client, tmpl *unstructured.Unstructured) error { - audit := readAuditConfig(ctx, c) +func patchAuditEnvVars(tmpl *unstructured.Unstructured, audit *agenticv1alpha1.AuditConfig) error { if audit.LoggingEnabled() {Also applies to: 748-761
🤖 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 `@controller/proposal/sandbox_templates.go` around lines 231 - 233, Ensure EnsureAgentTemplate and patchAuditEnvVars use the same audit config snapshot instead of calling readAuditConfig twice. Pass the already-fetched audit value from EnsureAgentTemplate into patchAuditEnvVars (and any helper it uses) so the template name/hash and the patched env vars are derived from the same data, avoiding divergence if the CR changes between reads.
🤖 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 `@controller/proposal/helpers.go`:
- Around line 75-81: readAuditConfig currently swallows every c.Get error by
returning nil, which lets computeTemplateHash and appendAuditEnvVars later
dereference a nil AuditConfig and panic. Update readAuditConfig in
controller/proposal/helpers.go to follow the isSuspended pattern: return nil
only when the AgenticOLSConfig object is NotFound, and surface all other
client.Get errors to the caller so upstream code can handle transient failures
safely.
---
Nitpick comments:
In `@controller/proposal/sandbox_templates.go`:
- Around line 231-233: Ensure EnsureAgentTemplate and patchAuditEnvVars use the
same audit config snapshot instead of calling readAuditConfig twice. Pass the
already-fetched audit value from EnsureAgentTemplate into patchAuditEnvVars (and
any helper it uses) so the template name/hash and the patched env vars are
derived from the same data, avoiding divergence if the CR changes between reads.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 6276b424-5c8c-445b-9566-148232766645
📒 Files selected for processing (6)
controller/proposal/bare_pod_manager.gocontroller/proposal/bare_pod_manager_test.gocontroller/proposal/helpers.gocontroller/proposal/podspec_builder.gocontroller/proposal/sandbox_templates.gocontroller/proposal/sandbox_templates_test.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
openshift/lightspeed-agentic-sandbox(manual)
Read the AgenticOLSConfig CR's audit config and set LIGHTSPEED_AUDIT_ENABLED and OTEL_EXPORTER_OTLP_ENDPOINT on sandbox containers in both bare-pod and sandbox-template paths. Include audit config in the template hash so config changes trigger new templates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Vimal Kumar <vimal78@gmail.com>
02a3248 to
1155906
Compare
|
@vimalk78: all tests passed! 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. |
blublinsky
left a comment
There was a problem hiding this comment.
nice-to-have: Redundant AgenticOLSConfig read on every Claim()
Location: controller/proposal/podspec_builder.go:appendAuditEnvVars and controller/proposal/sandbox_templates.go:EnsureAgentTemplate
Observation:
A single reconcile reads AgenticOLSConfig/cluster twice:
isSuspended()at the top ofReconcile()readAuditConfig()insideClaim()(viaappendAuditEnvVarsorEnsureAgentTemplate)
Since controller-runtime's client uses the informer cache for Get, read #2 is a cache lookup, not a real API round-trip — so there's zero performance impact.
Still, if this ever moves to a direct/uncached client (e.g., for freshness), it would be a real extra read. Could be avoided by reading the config once at the top of Reconcile and passing *AuditConfig through the call chain. Low priority — current pattern is consistent with isSuspended.
This comment was also posted by CodeRabbit, and has been resolved. |
Read the AgenticOLSConfig CR's audit config and set LIGHTSPEED_AUDIT_ENABLED and OTEL_EXPORTER_OTLP_ENDPOINT on sandbox containers in both bare-pod and sandbox-template paths. Include audit config in the template hash so config changes trigger new templates.