Skip to content

fix(client): retry transient API failures - #34

Merged
jingxiang-z merged 3 commits into
mainfrom
fix/retry-transient-api-requests
Aug 5, 2026
Merged

fix(client): retry transient API failures#34
jingxiang-z merged 3 commits into
mainfrom
fix/retry-transient-api-requests

Conversation

@jingxiang-z

@jingxiang-z jingxiang-z commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Description

Checklist

Summary by CodeRabbit

  • New Features

    • Added automatic retries for transient network failures and selected temporary server errors.
    • Honors server-provided retry timing and stops promptly when requests are canceled.
    • Signing-key retrieval now benefits from the same retry behavior.
  • Bug Fixes

    • Paginated “list all” operations retry only the failed page, avoiding duplicate requests and results.
    • Improved pagination error messages with page and progress details.

Signed-off-by: Jingxiang Zhang <jingzhang@nvidia.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 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: dd50e7a8-3080-4df5-8cbc-ae78ad22b302

📥 Commits

Reviewing files that changed from the base of the PR and between 24e5508 and 85fee0c.

📒 Files selected for processing (3)
  • cmd/nvfleetint/node_test.go
  • nvfleetint/client.go
  • nvfleetint/client_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • cmd/nvfleetint/node_test.go
  • nvfleetint/client_test.go
  • nvfleetint/client.go

📝 Walkthrough

Walkthrough

The client adds bounded retries for idempotent requests, including Retry-After handling and cancellation-aware backoff. Signing-key retrieval uses the retry path. Pagination reports contextual errors, and tests verify failed-page-only retries without duplicate nodes.

Changes

HTTP retry engine

Layer / File(s) Summary
Bounded request retry engine
nvfleetint/client.go, nvfleetint/client_test.go
The client retries selected transient GET and HEAD failures with bounded jittered backoff, Retry-After support, response cleanup, and context cancellation. Tests cover transient and permanent statuses, delay parsing, and cancellation.

Signing-key retry integration

Layer / File(s) Summary
Signing-key retry integration
nvfleetint/client.go, nvfleetint/verify_test.go
Signing-key retrieval uses the retrying request doer. Tests verify recovery from a transient 503 response.

Pagination validation

Layer / File(s) Summary
Pagination retry and error reporting
internal/clihelpers/pagination.go, cmd/nvfleetint/node_test.go
Pagination errors include the item, API page, and completed-page count. The node listing test verifies that only the failed page is retried and nodes are not duplicated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant RetryingRequestDoer
  participant HTTPServer
  Client->>RetryingRequestDoer: Send idempotent GET or HEAD
  RetryingRequestDoer->>HTTPServer: Execute request
  HTTPServer-->>RetryingRequestDoer: Return transient failure
  RetryingRequestDoer->>RetryingRequestDoer: Apply Retry-After or backoff
  RetryingRequestDoer->>HTTPServer: Retry request
  HTTPServer-->>Client: Return final response
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: retrying transient API failures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/retry-transient-api-requests

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

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

🤖 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 `@cmd/nvfleetint/node_test.go`:
- Around line 327-340: Strengthen the merged-output assertions in the test
around the decoded got.Items value: unmarshal each item’s nodeUUID and verify
the returned identities are node-1 followed by node-2. Keep the existing
item-count, pagination, and page-call assertions, but ensure the test rejects
duplicate first-page nodes.

In `@nvfleetint/client.go`:
- Around line 388-389: Update the Retry-After parsing logic around the seconds
conversion to validate that the parsed value does not exceed the maximum
representable time.Duration in seconds before multiplying by time.Second; reject
or clamp oversized values so the resulting duration never wraps negative. Add
boundary coverage for the largest valid value and an overflowing value,
including the resulting waitForRetry behavior.
🪄 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: fed230a7-3229-4c71-8398-83ef883a54b8

📥 Commits

Reviewing files that changed from the base of the PR and between 0f5a58a and 3a0f8d7.

📒 Files selected for processing (5)
  • cmd/nvfleetint/node_test.go
  • internal/clihelpers/pagination.go
  • nvfleetint/client.go
  • nvfleetint/client_test.go
  • nvfleetint/verify_test.go

Comment thread cmd/nvfleetint/node_test.go
Comment thread nvfleetint/client.go Outdated
Signed-off-by: Jingxiang Zhang <jingzhang@nvidia.com>
Signed-off-by: Jingxiang Zhang <jingzhang@nvidia.com>
@jingxiang-z jingxiang-z self-assigned this Aug 5, 2026
@jingxiang-z
jingxiang-z merged commit 9105d43 into main Aug 5, 2026
6 checks passed
@jingxiang-z
jingxiang-z deleted the fix/retry-transient-api-requests branch August 5, 2026 19:56
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.

2 participants