fix(nvca): persist workload config after Helm updates - #654
Conversation
Signed-off-by: rohithb <rohithb@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe update reconciliation flow retains decoded ChangesWorkload configuration persistence
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant RenderedWorkload
participant prepareUpdateWorkload
participant doUpdateWorkload
participant MiniService
RenderedWorkload->>prepareUpdateWorkload: Render workload objects and WorkloadConfig
prepareUpdateWorkload->>doUpdateWorkload: Return decoded WorkloadConfig
doUpdateWorkload->>MiniService: Apply workload objects
doUpdateWorkload->>MiniService: Persist WorkloadConfig
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
77a47b3 to
bdd82dc
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/compute-plane-services/nvca/internal/miniservice/reconcile_update_test.go (1)
619-665: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a table-driven test for the successful transitions.
These tests share the same setup and
doUpdateWorkloadcall. Put the enabled and disabled configurations in table cases witht.Run.As per coding guidelines, tests with multiple scenarios must use table-driven tests.
🤖 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 `@src/compute-plane-services/nvca/internal/miniservice/reconcile_update_test.go` around lines 619 - 665, Refactor the successful workload-config transition tests around TestDoUpdateWorkload_PersistsWorkloadConfig_NoConfigToEnabled and TestDoUpdateWorkload_PersistsWorkloadConfig_EnabledToDisabled into one table-driven test with t.Run cases. Parameterize the prior config, rendered feature-flag value, and expected enabled state while retaining the shared setup, doUpdateWorkload invocation, status assertions, and unrelated-spec checks where applicable.Source: Coding guidelines
🤖 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
`@src/compute-plane-services/nvca/internal/miniservice/reconcile_update_test.go`:
- Line 677: Update the comment describing the empty configYAML case to replace
the non-ASCII arrow with ASCII text, while preserving its meaning and leaving
the test logic unchanged.
In `@src/compute-plane-services/nvca/internal/miniservice/reconcile.go`:
- Around line 1032-1035: Update the saveWorkloadConfig flow around the
NewInstrumentedCRClient.Patch call to wrap the Kubernetes patch operation with
nvcaotel.InvokeWithSpan. Within the span callback, record patch failures using
RecordError and SetStatus, while preserving the existing error propagation from
saveWorkloadConfig.
---
Nitpick comments:
In
`@src/compute-plane-services/nvca/internal/miniservice/reconcile_update_test.go`:
- Around line 619-665: Refactor the successful workload-config transition tests
around TestDoUpdateWorkload_PersistsWorkloadConfig_NoConfigToEnabled and
TestDoUpdateWorkload_PersistsWorkloadConfig_EnabledToDisabled into one
table-driven test with t.Run cases. Parameterize the prior config, rendered
feature-flag value, and expected enabled state while retaining the shared setup,
doUpdateWorkload invocation, status assertions, and unrelated-spec checks where
applicable.
🪄 Autofix
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: c608f8ca-9c86-4d4f-84c1-cbd73b6218a5
📒 Files selected for processing (2)
src/compute-plane-services/nvca/internal/miniservice/reconcile.gosrc/compute-plane-services/nvca/internal/miniservice/reconcile_update_test.go
TL;DR
The Helm-update path in doUpdateWorkload discarded the WorkloadConfig decoded
from the nvcf-workload-config control ConfigMap. A successful revision could
apply new workload objects while MiniService.spec.workloadConfig kept describing
the prior revision. Status reconciliation then used stale config, for example
leaving StatusByWorkerReadiness disabled after a revision that enabled it.
Fix: prepareUpdateWorkload now returns the decoded WorkloadConfig, and
doUpdateWorkload calls saveWorkloadConfig after a successful apply. The existing
targeted SSA contract from #626 is preserved: miniservice-controller owns only
spec.workloadConfig and unrelated MiniService spec fields are untouched.
Additional Details
The root cause is a single discarded return value. decodeObjects has always
returned a
*v1alpha1.WorkloadConfigas its third value. The install path(
doInstall) captured it and calledsaveWorkloadConfig. The update path(
prepareUpdateWorkload) assigned it to_, so the decoded config was neverpropagated.
Key behavior:
nvcf-workload-configin the rendered output clearsspec.workloadConfig,consistent with how
saveWorkloadConfighandles a nil desired value via SSA.saveWorkloadConfigiscalled, so the prior config stays aligned with the workload revision still serving.
saveWorkloadConfigis called unchanged, so the targeted SSA payload introducedin fix(nvca): preserve MiniService spec when saving workload config #626 continues to restrict ownership to
spec.workloadConfigonly.For the Reviewer
reconcile.go: two mechanical changes only.prepareUpdateWorkloadreturnsignature gets a new
*v1alpha1.WorkloadConfigslot; all early returns updated.doUpdateWorkloadunpacks the new return value and callssaveWorkloadConfigafter
applySSAWorkload.reconcile_update_test.go: four new tests and two setup helpers, allself-contained. No existing tests were modified.
For QA
Ran:
All tests pass. The only failure in the package is TestController, which is
pre-existing and unrelated to this change. QA not needed: the fix is contained
to the in-process reconcile path with full unit coverage added.
Issues
Closes #651
Checklist
Summary by CodeRabbit