Skip to content

fix(nvca): make ModelCache envtest job completion version-adaptive#239

Open
balajinvda wants to merge 4 commits into
mainfrom
fix/nvca-modelcache-envtest-job-conditions
Open

fix(nvca): make ModelCache envtest job completion version-adaptive#239
balajinvda wants to merge 4 commits into
mainfrom
fix/nvca-modelcache-envtest-job-conditions

Conversation

@balajinvda

@balajinvda balajinvda commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Why

TestReconcile_ModelCache (pkg/storage) drives the writer Job to completion by faking its status against the real envtest apiserver. The apiserver's Job-status validation changed across k8s versions in incompatible directions:

  • k8s 1.30-1.33: reject a SuccessCriteriaMet condition on this NonIndexed Job (it has no SuccessPolicy).
  • k8s 1.34+: require SuccessCriteriaMet before Complete, and reject CompletionTime without Complete.

No single static condition shape satisfies both, and the Job spec is reconciler-owned and immutable on update, so the test cannot reshape it. This is why the nvca row in .github/workflows/bazel.yml is currently build-only.

What changed

The reconciler detects completion via CompletionTime + Succeeded, not the Job conditions. Extract a completeJob helper that applies the modern (>= 1.34) condition shape and falls back to the pre-1.34 shape only if the apiserver rejects it. The test now passes regardless of the envtest version in play.

Customer Release Notes

Not customer visible (test-only change).

Plan Summary

Not applicable.

Usage

Not applicable.

Testing

Ran the full pkg/storage package against both envtest versions:

  • KUBEBUILDER_ASSETS=.../1.30.3 -> ok (previously failed: cannot set SuccessCriteriaMet to NonIndexed Job)
  • KUBEBUILDER_ASSETS=.../1.34.1 -> ok (the version nvca pins via scripts/setup_envtest, K8S_MAJ_MIN_VERSION=1.34)

Notes

Follow-up to actually enable the nvca test row on GHA is tracked in #238 (provision envtest / KUBEBUILDER_ASSETS in the matrix job, then drop tests_skip: true). This PR only removes the underlying test fragility; it does not flip the matrix row.

References

Closes #238

Related Merge Requests/Pull Requests

None

Dependencies

None

Github commit:
fix(nvca): make ModelCache envtest job completion version-adaptive

The writer-Job completion faked in TestReconcile_ModelCache tripped
apiserver Job-status validation that differs by k8s version. Apply the
modern condition shape and fall back to the pre-1.34 shape when the
apiserver rejects it, so the test passes on both. The reconciler keys off
CompletionTime + Succeeded, not the conditions.

Closes #238

Co-authored-by: Balaji Ganesan bganesan@nvidia.com
Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com

Summary by CodeRabbit

  • Tests
    • Improved reliability of the model cache reconciliation test by using a new job-completion helper that adapts to Kubernetes Job status/condition shapes.
    • Added a retry fallback when the API rejects the “modern” completion status, reducing flakiness across Kubernetes versions.
  • CI / Chores
    • Refreshed the build workflow documentation for the nvca detect job to better describe the current test behavior and remaining envtest issues.

TestReconcile_ModelCache drives the writer Job to completion by faking its
status against the real envtest apiserver. The apiserver's Job-status
validation differs by version: k8s 1.30-1.33 reject a SuccessCriteriaMet
condition on this NonIndexed Job (it has no SuccessPolicy), while k8s 1.34+
require SuccessCriteriaMet before Complete and reject CompletionTime without
Complete. No single static condition shape satisfies both, and the Job spec
is reconciler-owned and immutable on update.

The reconciler detects completion via CompletionTime + Succeeded, not the
conditions. Extract a completeJob helper that applies the modern (>= 1.34)
condition shape and falls back to the pre-1.34 shape only if the apiserver
rejects it, so the test passes on both. Verified against envtest 1.30.3 and
1.34.1 (nvca pins 1.34).

Closes #238

Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@balajinvda
balajinvda requested a review from a team as a code owner July 17, 2026 16:23
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d0e44100-ae45-468c-b08d-0e373c97a7a4

📥 Commits

Reviewing files that changed from the base of the PR and between 95545e0 and afd38ec.

📒 Files selected for processing (1)
  • .github/workflows/bazel.yml

📝 Walkthrough

Walkthrough

The model cache reconciliation test now uses a Kubernetes-version-compatible helper to complete the writer Job. The Bazel workflow documents the version-adaptive behavior and updated nvca test status.

Changes

Model cache test compatibility

Layer / File(s) Summary
Adaptive writer Job completion
src/compute-plane-services/nvca/pkg/storage/modelcache_test.go
TestReconcile_ModelCache calls completeJob, which retries Job status updates with a legacy-compatible condition set when modern validation fails.

Workflow documentation

Layer / File(s) Summary
nvca test compatibility documentation
.github/workflows/bazel.yml
The workflow comment describes the Kubernetes-version-adaptive Job completion flow and updates the related test status context.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: kristinapathak

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR fixes TestReconcile_ModelCache, but it does not enable nvca test execution or remove tests_skip in the Bazel matrix [#238]. Enable nvca tests in the Bazel matrix, provide envtest assets or filter envtest-tagged tests, and remove the stale build-only comment [#238].
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making ModelCache envtest job completion handling version-adaptive.
Out of Scope Changes check ✅ Passed The changes stay focused on the ModelCache envtest fix and a related workflow comment update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/nvca-modelcache-envtest-job-conditions

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

@github-actions

Copy link
Copy Markdown

🛡️ CodeQL Analysis

🚨 Found 2 issue(s)

Severity Breakdown:

  • 🔴 Errors: 0
  • 🟡 Warnings: 0
  • 🔵 Notes: 0
📋 Top Issues

🔗 View full details in Security tab

🕐 Last updated: 2026-07-17 16:25:44 UTC | Commit: cc616cf

@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: 1

🤖 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/pkg/storage/modelcache_test.go`:
- Around line 752-765: Update the initial c.Status().Update error handling
around the job status update to retry the legacy shape only when
apierrors.IsInvalid(err) is true. For all other errors, fail immediately instead
of proceeding to the re-fetch and second Status().Update; preserve the existing
fallback mutation for validation errors.
🪄 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: 182f5d5c-d46c-4b62-939d-d229bc18a192

📥 Commits

Reviewing files that changed from the base of the PR and between ed2f0bd and cc616cf.

📒 Files selected for processing (1)
  • src/compute-plane-services/nvca/pkg/storage/modelcache_test.go

Comment thread src/compute-plane-services/nvca/pkg/storage/modelcache_test.go Outdated
…rrors

Flip the nvca Bazel matrix row from tests_skip to tests-run now that
TestReconcile_ModelCache is version-adaptive. The row's comment already said
"tests run" but the field still skipped them; this makes the two agree.

Also address review feedback on completeJob: only fall back to the pre-1.34
Job condition shape when the apiserver returns an Invalid (validation) error.
Any other error (conflict, network, RBAC) now surfaces immediately instead of
being masked by the second Status().Update.

Verified pkg/storage against envtest 1.30.3 and 1.34.1.

Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@balajinvda

Copy link
Copy Markdown
Contributor Author

Folded the #238 enablement into this PR so the Closes #238 is accurate (addresses CodeRabbit's Linked-Issues pre-merge warning):

  • .github/workflows/bazel.yml: flipped the nvca matrix row from tests_skip: true to run tests (nvca|src/compute-plane-services/nvca|false). The row's own comment already said "tests run"; the field now agrees. Updated the comment to describe the version-adaptive completion.
  • Addressed the inline review: gate the pre-1.34 fallback on apierrors.IsInvalid(err).

Verified pkg/storage green against envtest 1.30.3 and 1.34.1 locally. The GHA nvca job now runs bazel test //... against the baked bazel-ci envtest for real validation.

The bazel matrix comments referenced internal issue IDs, which should not
appear in the public mirror. Describe the test-skip reasons without them.

Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@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: 1

🤖 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 @.github/workflows/bazel.yml:
- Around line 86-90: Update the comment describing TestReconcile_ModelCache in
the bazel workflow to state that the fallback occurs only when the apiserver
returns an Invalid validation error, rather than broadly saying it applies
whenever the apiserver rejects the condition shape. Preserve the surrounding
version-adaptive behavior and test-environment details.
🪄 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: c58c2a19-0d3f-421f-a14c-c00e2ecc78b7

📥 Commits

Reviewing files that changed from the base of the PR and between cc616cf and 5722309.

📒 Files selected for processing (2)
  • .github/workflows/bazel.yml
  • src/compute-plane-services/nvca/pkg/storage/modelcache_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/compute-plane-services/nvca/pkg/storage/modelcache_test.go

Comment thread .github/workflows/bazel.yml Outdated
Comment on lines +86 to +90
# nvca: tests run. TestReconcile_ModelCache (NVCF-10347) drives the
# writer Job to completion and is version-adaptive: it applies the
# k8s >= 1.34 Job condition shape and falls back to the pre-1.34
# shape if the apiserver rejects it, so it passes on the bazel-ci
# envtest (verified against 1.30.3 and 1.34.1). The only flaky test,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the fallback’s actual error boundary.

The helper falls back only for an apiserver Invalid validation error; “if the apiserver rejects it” is broader and could imply swallowing conflicts, network failures, or RBAC errors.

Proposed wording
-          #    shape if the apiserver rejects it, so it passes on the bazel-ci
+          #    shape only when the apiserver returns an Invalid validation
+          #    error, so it passes on the bazel-ci
📝 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.

Suggested change
# nvca: tests run. TestReconcile_ModelCache (NVCF-10347) drives the
# writer Job to completion and is version-adaptive: it applies the
# k8s >= 1.34 Job condition shape and falls back to the pre-1.34
# shape if the apiserver rejects it, so it passes on the bazel-ci
# envtest (verified against 1.30.3 and 1.34.1). The only flaky test,
# nvca: tests run. TestReconcile_ModelCache (NVCF-10347) drives the
# writer Job to completion and is version-adaptive: it applies the
# k8s >= 1.34 Job condition shape and falls back to the pre-1.34
# shape only when the apiserver returns an Invalid validation
# error, so it passes on the bazel-ci envtest (verified against 1.30.3 and 1.34.1). The only flaky 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 @.github/workflows/bazel.yml around lines 86 - 90, Update the comment
describing TestReconcile_ModelCache in the bazel workflow to state that the
fallback occurs only when the apiserver returns an Invalid validation error,
rather than broadly saying it applies whenever the apiserver rejects the
condition shape. Preserve the surrounding version-adaptive behavior and
test-environment details.

Enabling `bazel test //...` for nvca surfaced failures beyond the ModelCache
test this PR fixes: TestGetMiniServiceRBACCmData and TestGetNetworkPoliciesData*
in //pkg/operator/reconcile, and the TestCreateMiniService_* (GVK/412) and
Test_applyContainerTaskCreationMessage tests in //pkg/nvca. Those are separate
test-layer issues for the nvca team.

Revert the row to build-only so this PR stays a clean ModelCache fix. The full
enablement backlog is tracked in #238.

Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable nvca test execution in the GitHub Actions Bazel matrix

2 participants