fix(plugin): return health update send errors #214
@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>
<!-- 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&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>
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
ListAndWatch.</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>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- autopilot:start -->
<!-- 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>
</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 -->
grpc drops this error silently, klog it here
fixed now.
Approved these changes.
[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:
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"]} -->
moezdil
blackdragoon26
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:
ListAndWatchreturns an error when its initialSendfails, but previously returnednilwhen 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:
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 andgit diff --checkpassed.Serve,RegisterandListAndWatch: 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.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.TestLiveMonitorInformerCutsPodListskipped 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.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
- 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.
- 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 -->