← Back to Pull requests

fix(plugin): return health update send errors #214

Merged
blackdragoon26 merged 3 files (202 lines) on Nov 01, 2026 18:18 UTC
View on GitHub
blackdragoon26 blackdragoon26 commented on Oct 31, 2026 19:58 UTC
Author

What type of PR is this?
/kind bug
<!--
Add one of the following kinds:
/kind bug
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
-->

What this PR does / why we need it:
ListAndWatch returns an error when its initial Send fails, but previously returned nil when sending a later health update failed. Return that error too. Replace the inherited recovery FIXME with a description of the existing behavior.

Add deterministic unit coverage and a real Unix-socket gRPC regression for unhealthy updates, clean shutdown and a Send after client cancellation.

Which issue(s) this PR fixes:
Fixes #207

Special notes for your reviewer:

  • Linux ARM64 in Docker on an Apple Silicon Mac and native Linux AMD64 on Ubuntu 24.04.5, Go 1.27.3 with CGO enabled: go mod verify, go build ./..., go vet ./... and the uncached full unit suite passed. Each architecture passed 264 tests/subtests. The shuffled plugin race suite passed 25 tests/subtests on each; golangci-lint v2.15.0 reports 0 issues on both. Formatting and git diff --check passed.

  • The real-gRPC cancellation regression fails on baseline production code because the handler returns nil; it passes with the fix. The healthy-update/clean-EOF control also passes.

  • Ran race-enabled manual probes against a real kubelet in disposable kind Kubernetes v1.37.0 on native AMD64. A synthetic resource manager exercised production Serve, Register and ListAndWatch: registration published capacity/allocatable 1/1; an unhealthy update changed it to 1/0; re-registration restored 1/1; CPU-only control Pods became Running and Ready; normal stop returned nil.

  • The probe delegates every Send to real gRPC. Stopping its actual transport produced Unavailable: transport is closing. Baseline swallowed this and returned nil; fixed code returned the actual Send error. Registration and re-registration worked on both versions; this is an error-propagation fix, with no claim of changed kubelet recovery behavior.

  • The existing opt-in TestLiveMonitorInformerCutsPodList skipped in the broad suites without cluster configuration, then passed separately with the race detector on that cluster: 24 Pod LIST requests over 24 baseline ticks, versus 0 over 25 informer ticks.

  • The inventory was synthetic. Real NVIDIA GPU allocation, isolation and NVML health detection were not tested. Temporary clusters, images, networks, volumes, test binaries and caches were removed after saving evidence.
  • Does this PR introduce a user-facing change?:
    A failed health-update Send returns its error from ListAndWatch instead of a successful handler return. No configuration changes.

    AI Disclosure:
    AI assistance was used for the fix, regression tests, integration harness, validation and this description.

    <!-- Briefly disclose any AI assistance used. Do not add AI co-author or assistance trailers to commits. -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

  • Bug Fixes

  • - Errors encountered while sending updated device lists are now returned instead of being treated as successful. Failures during device health updates are logged with the affected resource and device, and the stream reports the error to callers.
  • Tests

  • - Added coverage for initial and updated device-list send failures, health updates, normal shutdown, and client cancellation. Tests also verify device health responses and stream termination behavior.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 202 lines (+200 / -2) across 3 files Reviewer: moezdil Review duration: 1339m
    All Vouch review confidence checks passed
    Residual risk 0.07 = Change Risk (0.38) × (1 − Review Confidence (0.82)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.38 · 202 lines diff across 3 files
    0.38
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.73 · 5 substantive comment(s)
    0.73
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    82%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.318
    Real PR Conversation Timeline
    7 items
    hami-robot[bot] hami-robot[bot] commented on Oct 31, 2026 19:58 UTC
    Bot

    @blackdragoon26: The label(s) kind/bug cannot be applied, because the repository doesn't have them.

    <details>

    In response to this:

    >What type of PR is this?
    >/kind bug

    >

    >What this PR does / why we need it:
    >ListAndWatch already returns an error when its initial Send fails, but returns nil when sending a later health update fails. Return that error as well, so the RPC does not end successfully after a failed send.
    >Replace the inherited recovery FIXME with a description of the existing health-check behavior. Recovery behavior is unchanged.

    >Which issue(s) this PR fixes:

    >Fixes #207
    >Special notes for your reviewer:

    >- Added deterministic mocked-stream coverage for initial Send failure, health-update Send failure, normal shutdown, and a successful unhealthy-device update followed by shutdown. Response contents and send counts are checked.
    >- Before the production fix, the health-update failure case fails because ListAndWatch returns nil; the other three cases pass. All four pass after the fix.
    >- Validated on both Linux ARM64 in Docker on an Apple Silicon Mac and native Linux AMD64 on Ubuntu 24.04.5, using Go 1.27.3 with CGO enabled: go mod verify, go build ./..., go vet ./..., and go test -count=1 -timeout=10m ./... passed (261 tests/subtests passed on each architecture; one existing opt-in live informer test skipped on each without KUBECONFIG/NODE_NAME).
    >- go test -race -shuffle=on -count=1 -timeout=10m ./pkg/plugin passed on both architectures (22 tests/subtests each); golangci-lint v2.15.0 reports 0 issues on both; gofmt and git diff --check passed.
    >- I have not done, GPU integration run.
    >Does this PR introduce a user-facing change?:

    >A failed health-update Send ends ListAndWatch with its error instead of a successful return. No configuration changes.
    >AI Disclosure:

    >AI assistance was used for the fix, regression tests, validation and this description.
    >

    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 kubernetes-sigs/prow repository.
    </details>

    coderabbitai[bot] coderabbitai[bot] commented on Oct 31, 2026 19:59 UTC
    Bot

    <!-- coderabbit-ai-generated:v1 -->

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- review_stack_entry_start -->

    <a href="https://app.coderabbit.ai/change-stack/Project-HAMi/volcano-vgpu-device-plugin/pull/214?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a>

    <!-- review_stack_entry_end -->
    <!-- recent_review_start -->

    No actionable comments were generated in the recent review.

    <details>
    <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
    <dl>
    <dd>

    <!-- review_info_content -->
    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
    <dl>
    <dd>

  • Source mode: Auto

  • Repository: Unavailable

  • Branch: Unavailable

  • File: No configuration file from this repository applied

  • Commit: Unavailable

  • Layers: Organization UI

  • Review profile: CHILL

  • Plan: Advanced

  • Run ID: 17aba6ce-b816-45b0-87d5-8e798145c05b
  • </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
    <dl>
    <dd>

    Reviewing files that changed from the base of the PR and between aa2a950f38a9f28d96dd550e3358503eba99d3f3 and 90c5ee36be32bb60cb3ccb663db61152fb6ea0ea.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 1</strong></summary>
    <dl>
    <dd>

    pkg/plugin/server.go

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-similar-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-similar.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files skipped from review as they are similar to previous changes: 1</strong></summary>
    <dl>
    <dd>

    pkg/plugin/server.go

    </dd>
    </dl>
    </details>

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

    </dd>
    </dl>
    </details>

    <!-- recent_review_end -->
    <!-- walkthrough_start -->

    <details>
    <summary><strong>Walkthrough</strong></summary>
    <dl>
    <dd>

    ListAndWatch now returns an error when sending a health update fails. Unit and gRPC tests cover send failures, device health values, and shutdown behavior.

    Changes: ListAndWatch error handling

    |Layer / File(s)|Summary|
    |:---|:---|
    |Health-update send errors and test coverage <br> pkg/plugin/server.go, pkg/plugin/server_test.go, pkg/plugin/list_and_watch_grpc_test.go|ListAndWatch returns the error from a failed health-update send. Unit and gRPC tests cover send failures, health updates, and shutdown behavior. The health-check comment now states that recovery is not handled.|

    <!-- change_assessment_start -->
    Estimated code review effort: 2 (Simple) | ~10 minutes

    <!-- change_assessment_commit:"90c5ee36be32bb60cb3ccb663db61152fb6ea0ea" -->
    <!-- change_assessment_priority:{"version":1,"urgency":"p3","manual":false} -->
    Change: Bug fix · Severity of issue fixed: Low
    <!-- change_assessment_end -->

    Possibly related issues

  • Project-HAMi/volcano-vgpu-device-plugin#215 — The issue describes a later health event after a failed health-update send. This change returns the send error from ListAndWatch.

  • Project-HAMi/volcano-vgpu-device-plugin#212 — The change replaces the inherited recovery FIXME with a description of the existing health-check behavior.
  • </dd>
    </dl>
    </details>

    <!-- walkthrough_end -->
    <details>
    <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>90c5e</code></summary>
    <dl>
    <dd>

    <!-- final_review_risk_start -->
    <!-- final_review_risk_label
    Merge Risk: ⚪ Minimal · up to 90c5e
    -->
    <!-- final_review_risk_coverage:{"sourceCommitId":"90c5ee36be32bb60cb3ccb663db61152fb6ea0ea","coveredCommitId":"90c5ee36be32bb60cb3ccb663db61152fb6ea0ea","kind":"reviewed"} -->

    The change correctly reports failed health-update sends without changing clean shutdown behavior. Regression coverage supports merging; real-GPU behavior was not established by these tests.
    <!-- final_review_risk_end -->

    </dd>
    </dl>
    </details>
    <!-- pre_merge_checks_walkthrough_start -->

    <details>
    <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary>
    <dl>
    <dd>

    <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong>

    | Check name | Status | Explanation | Resolution |
    | :---------------- | :----------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- |
    | Docstring Coverage | !Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… | Write docstrings for the functions missing them to satisfy the coverage threshold. |

    <details>
    <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary>
    <dl>
    <dd>

    | Check name | Status | Explanation |
    | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Description Check | !Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
    | Title check | !Passed | The title "fix(plugin): return health update send errors" matches the main change. The raw summary and PR objectives both say ListAndWatch in pkg/plugin/server.go now returns the error from a failed h… |
    | Linked Issues check | !Passed | Issue #207 has two coding requirements. First, the health-update branch of ListAndWatch in pkg/plugin/server.go must return the s.Send error instead of nil. The whole-PR diff against the merge… |
    | Out of Scope Changes check | !Passed | The whole-PR diff of pkg/plugin/server.go changes only the health-update branch of ListAndWatch. The changes are the requested error return, a klog.ErrorS line that logs the failure with resourc… |

    <details>
    <summary><strong>Full details: Title check</strong></summary>
    <dl>
    <dd>

    Explanation

    The title "fix(plugin): return health update send errors" matches the main change. The raw summary and PR objectives both say ListAndWatch in pkg/plugin/server.go now returns the error from a failed health-update send instead of nil. The title is specific, short, and uses a conventional commit prefix. It does not mention the added tests or the FIXME rewording, but it does not need to cover every detail.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>Full details: Linked Issues check</strong></summary>
    <dl>
    <dd>

    Explanation

    Issue #207 has two coding requirements. First, the health-update branch of ListAndWatch in pkg/plugin/server.go must return the s.Send error instead of nil. The whole-PR diff against the merge base shows if err := s.Send(...); err != nil { klog.ErrorS(...); return err }, and the head file confirms this. The initial-send path already returned err. Second, the inherited FIXME: no way to recover from Unhealthy comment must be reworded or resolved. The head comment now reads Health checks report unhealthy devices; recovery is not handled here., which describes the existing behavior. Both requirements are met in production code. The test coverage described in the PR summary (TestListAndWatch in server_test.go, TestListAndWatchGRPC in list_and_watch_grpc_test.go) was not opened in this review. It is taken from the AI-generated summary, so the test claims are not independently verified here. The production requirements are verified from source.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>Full details: Out of Scope Changes check</strong></summary>
    <dl>
    <dd>

    Explanation

    The whole-PR diff of pkg/plugin/server.go changes only the health-update branch of ListAndWatch. The changes are the requested error return, a klog.ErrorS line that logs the failure with resource and device ID (matching the commit message note), and the reworded comment. No unrelated production change appears in the reviewed file diff. The summary reports added tests in pkg/plugin/server_test.go and pkg/plugin/list_and_watch_grpc_test.go. These tests verify the same ListAndWatch behavior, so they support this objective. The test files were not diffed directly in this review, so their content is not independently verified.

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>Full details: Docstring Coverage</strong></summary>
    <dl>
    <dd>

    Explanation

    Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 3 files.

    Resolution

    Write docstrings for the functions missing them to satisfy the coverage threshold.

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- pre_merge_checks_walkthrough_end -->
    <!-- finishing_touch_checkbox_start -->

    <details>
    <summary><strong>Finishing Touches</strong></summary>
    <dl>
    <dd>

    <details open>
    <summary><strong>Generate unit tests (beta)</strong></summary>
    <dl>
    <dd>

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create a new PR
  • </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- finishing_touch_checkbox_end -->

    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->
    <!-- tips_start -->

    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.

    <details>
    <summary><strong>Share</strong></summary>
    <dl>
    <dd>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </dd>
    </dl>
    </details>

    <!-- poem_footer_start -->
    <sub>A rabbit watches devices glow,<br>Then sees a send error flow.<br>The stream reports what went awry,<br>Health updates pass as tests reply.<br>At shutdown, all waits end just so.</sub>
    <!-- poem_footer_end -->

    <!-- tips_end -->

    moezdil moezdil commented on code on Oct 31, 2026 21:54 UTC
    Code Review
    pkg/plugin/server.go:1
    @@ -337,11 +337,11 @@ func (plugin *nvidiaDevicePlugin) ListAndWatch(e *pluginapi.Empty, s pluginapi.D
     		case <-plugin.stop:
     			return nil
     		case d := <-plugin.health:
    -			// FIXME: there is no way to recover from the Unhealthy state.
    +			// Health checks report unhealthy devices; recovery is not handled here.
     			d.Health = pluginapi.Unhealthy
     			klog.Infof("'%s' device marked unhealthy: %s", plugin.rm.Resource(), d.ID)
     			if err := s.Send(&pluginapi.ListAndWatchResponse{Devices: plugin.apiDevices()}); err != nil {
    -				return nil
    +				return err

    grpc drops this error silently, klog it here

    blackdragoon26 blackdragoon26 commented on code on Nov 01, 2026 07:38 UTC
    Code Review
    pkg/plugin/server.go:1
    @@ -337,11 +337,11 @@ func (plugin *nvidiaDevicePlugin) ListAndWatch(e *pluginapi.Empty, s pluginapi.D
     		case <-plugin.stop:
     			return nil
     		case d := <-plugin.health:
    -			// FIXME: there is no way to recover from the Unhealthy state.
    +			// Health checks report unhealthy devices; recovery is not handled here.
     			d.Health = pluginapi.Unhealthy
     			klog.Infof("'%s' device marked unhealthy: %s", plugin.rm.Resource(), d.ID)
     			if err := s.Send(&pluginapi.ListAndWatchResponse{Devices: plugin.apiDevices()}); err != nil {
    -				return nil
    +				return err

    fixed now.

    moezdil moezdil approved these changes on Nov 01, 2026 18:18 UTC
    Approved Reviewer

    Approved these changes.

    hami-robot[bot] hami-robot[bot] commented on Nov 01, 2026 18:18 UTC
    Bot

    [APPROVALNOTIFIER] This PR is NOT APPROVED

    This pull-request has been approved by: <a href="https://github.com/Project-HAMi/volcano-vgpu-device-plugin/pull/214#" title="Author self-approved">blackdragoon26</a>, <a href="https://github.com/Project-HAMi/volcano-vgpu-device-plugin/pull/214#pullrequestreview-5729534363" title="Approved">moezdil</a>
    Once this PR has been reviewed and has the lgtm label, please assign archlitchi for approval. For more information see the Kubernetes Code Review Process.

    The full list of commands accepted by this bot can be found here.

    <details open>
    Needs approval from an approver in each of these files:

  • OWNERS
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":["archlitchi"]} -->

    Reviewers
    Assignees
    blackdragoon26 blackdragoon26
    Labels
    risk: low confidence: 82.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.7% (MEDIUM) · Higher = larger blast radius
    37.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 82.4% · Lower = rushed or shallow review
    82.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.7% · Safe to merge
    6.7%