Skip to content

Do not update status on unpopulated CR when Get fails - #3279

Open
AyushSrivastava1818 wants to merge 1 commit into
NVIDIA:mainfrom
AyushSrivastava1818:fix/avoid-status-update-on-unpopulated-cr
Open

AyushSrivastava1818 wants to merge 1 commit into
NVIDIA:mainfrom
AyushSrivastava1818:fix/avoid-status-update-on-unpopulated-cr

Conversation

@AyushSrivastava1818

@AyushSrivastava1818 AyushSrivastava1818 commented Nov 21, 2026 •

Copy link
Copy Markdown

Issue

Fixes #3190

Description

When
.Get fails with a non-404 error (such as transient API server connection issues, context timeouts, or client rate limiting), ClusterPolicyReconciler and NVIDIADriverReconciler previously called
.conditionUpdater.SetConditionsError on an unpopulated custom resource object whose .metadata.name is empty ("").

Because SetConditionsError attempts to fetch the CR by name ( ypes.NamespacedName{Name: cr.Name}), this triggered a secondary error:
failed to get <CR> instance for status update: resource name may not be empty
which obscured the original Get failure and polluted controller logs.

This PR aligns both reconcilers with the pattern already established in GPUClusterReconciler: when
.Get fails on an unpopulated instance, log the error and surface it directly for requeue without attempting to set conditions on an empty CR.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Lint checks passing (make lint)
  • Generated assets in-sync (make validate-generated-assets)
  • Go mod artifacts in-sync (make validate-modules)
  • Test cases are added for new code paths

Testing

  • Added unit tests in controllers/clusterpolicy_controller_test.go (TestClusterPolicyReconcileGetFailureDoesNotUpdateCondition) and controllers/nvidiadriver_controller_test.go (TestNVIDIADriverReconcileGetFailureDoesNotUpdateCondition) asserting that non-404
    .Get errors are returned directly without invoking SetConditionsError.
  • Executed all controller unit tests (go test ./controllers/...) in WSL and confirmed they pass.
  • Verified linting via golangci-lint run ./controllers/....

Devin Review

When r.Get fails with a non-404 error, ClusterPolicyReconciler and
NVIDIADriverReconciler attempt to set conditions on an unpopulated
instance where .metadata.name is empty. This causes a secondary error
("resource name may not be empty") and masks the underlying failure.

Align with GPUClusterReconciler by logging the error and returning it
directly for requeue without updating status on the unpopulated CR.

Signed-off-by: AyushSrivastava1818 <ayush.sri0705@gmail.com>
@AyushSrivastava1818
AyushSrivastava1818 requested a review from a team as a code owner November 21, 2026 08:09
@copy-pr-bot

copy-pr-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When Get fails with an error other than NotFound, the ClusterPolicy and NVIDIADriver reconcilers no longer attempt to update status on the unpopulated instance. They return the fetch error. New tests verify error propagation and confirm that the condition updater’s error reason remains empty.

Severity of issue fixed: Low

Merge Risk: Minimal · up to 64313

This change stops the reconcilers from attempting a status update on an empty resource after a failed fetch. The original fetch error is now returned cleanly for requeue instead of being obscured by a secondary error. It is low risk and ready to merge.

Security architecture risk: Minimal · up to 64313

The change avoids invalid status-update attempts after a resource fetch fails. It preserves the original failure signal and does not introduce a material change to security boundaries, persisted-state ownership, or recovery behavior.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d338c6b and 64313d3.

Files selected for processing: 4

  • controllers/clusterpolicy_controller.go
  • controllers/clusterpolicy_controller_test.go
  • controllers/nvidiadriver_controller.go
  • controllers/nvidiadriver_controller_test.go

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

This branch has not been deployed

No deployments
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.

[Bug]: ClusterPolicy and NVIDIADriver reconcilers pass unpopulated CR to SetConditionsError on r.Get failure

1 participant