fix(errors): retry transient "failed calling webhook" apiserver 500s - #16259
fix(errors): retry transient "failed calling webhook" apiserver 500s#16259HsiuChuanHsu wants to merge 1 commit into
Conversation
Signed-off-by: HsiuChuanHsu <hchsu2106@gmail.com>
21db4b6 to
50f2422
Compare
📝 WalkthroughWalkthroughThe transient error classifier now treats internal apiserver errors containing ChangesTransient webhook error handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 `@util/errors/errors.go`:
- Around line 92-95: Restrict isTransientWebhookErr in util/errors/errors.go to
classify only explicitly retryable webhook causes rather than relying on the
shared “failed calling webhook” text; preserve structured failure information if
needed before classification. Add a regression case in
util/errors/errors_test.go covering a non-transient failed-calling-webhook error
and verify it is not classified as transient.
🪄 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: Pro Plus
Run ID: 636a3860-24c3-4f63-96bf-c867bfc2db17
📒 Files selected for processing (2)
util/errors/errors.goutil/errors/errors_test.go
| // isTransientWebhookErr reports whether the error is a transient apiserver failure to reach an admission webhook. | ||
| func isTransientWebhookErr(err error) bool { | ||
| return apierr.IsInternalError(err) && strings.Contains(err.Error(), "failed calling webhook") | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Keep webhook retries within the intended transient boundary.
The classifier treats the shared failed calling webhook wrapper as sufficient evidence of a transient failure. Kubernetes uses this path for additional webhook-call failures, including client construction and response errors. (raw.githubusercontent.com)
util/errors/errors.go#L92-L95: Match only retryable causes, or preserve structured failure information before classification.util/errors/errors_test.go#L78-L82: Add a non-transientfailed calling webhookregression case.
📍 Affects 2 files
util/errors/errors.go#L92-L95(this comment)util/errors/errors_test.go#L78-L82
🤖 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 `@util/errors/errors.go` around lines 92 - 95, Restrict isTransientWebhookErr
in util/errors/errors.go to classify only explicitly retryable webhook causes
rather than relying on the shared “failed calling webhook” text; preserve
structured failure information if needed before classification. Add a regression
case in util/errors/errors_test.go covering a non-transient
failed-calling-webhook error and verify it is not classified as transient.
Fixes #14220
Motivation
A webhook can be briefly unreachable during normal operation. While it is unreachable, the kube-apiserver
rejects the request with an HTTP 500
InternalError:An earlier attempt (PR #16038) treated all 500s as transient which was not that correct. Blindly retrying them would mask real failures and pile load onto an already-unhealthy apiserver.
So this task is to retry only this known-transient case while leaving every other 500 classified as permanent.
Modifications
Added a single targeted classifier in
util/errors/errors.go, same style as the existingisResourceQuotaTimeoutErr:And added into isTransientErr` alongside the other transient checks.
Verification
Documentation
AI
Claude Sonnet 4.8
Summary by CodeRabbit
Bug Fixes
Tests