fix(manifest): keep bid close independent of shutdown#410
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (8)
WalkthroughIntroduces a configurable ChangesWatchdog broadcast context isolation and configurable timeout
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Watchdog
participant BroadcastContext
participant Session
participant Lifecycle
Watchdog->>BroadcastContext: Create independent timeout context
Watchdog->>Session: BroadcastMsgs(close-bid)
Lifecycle-->>Watchdog: Request shutdown
Session-->>Watchdog: Return result or deadline error
Watchdog->>Lifecycle: Signal shutdown completion
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
b05aaae to
f6b3312
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
cmd/provider-services/cmd/run.go (2)
832-834: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winValidate the webhook port before narrowing it.
A configured value above
65535can wrap atint32(webhookPort): registration may succeed with a different valid port whileListenAndServeTLSfails on the original invalid port. The fail-closed webhook then blocks tenant pod creation.Proposed fix
webhookPort := viper.GetInt(FlagAttestationWebhookPort) + if webhookPort < 1 || webhookPort > 65535 { + return fmt.Errorf("%w: %s must be between 1 and 65535", + errInvalidConfig, FlagAttestationWebhookPort) + } webhookAddr := fmt.Sprintf(":%d", webhookPort)Also applies to: 916-919
🤖 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 `@cmd/provider-services/cmd/run.go` around lines 832 - 834, Validate the value returned by viper.GetInt(FlagAttestationWebhookPort) in both webhook setup paths before converting or passing it to any narrower integer type. Reject values outside the valid TCP port range 1–65535 and fail closed before registration or ListenAndServeTLS, keeping the validated value consistent across webhook configuration.Source: Linters/SAST tools
932-943: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winBound webhook deregistration during shutdown.
DeregisterWebhookConfigurationreceivescontext.Background(), so an unavailable Kubernetes API can block shutdown indefinitely beforewebhookSrv.Shutdownruns. Use a timeout context for the delete as well.Proposed fix
<-ctx.Done() + deregisterCtx, deregisterCancel := context.WithTimeout(context.Background(), 5*time.Second) + defer deregisterCancel() if webhookKC, kcErr := fromctx.KubeClientFromCtx(ctx); kcErr == nil { attestwebhook.DeregisterWebhookConfiguration( - context.Background(), webhookKC, webhookLog, + deregisterCtx, webhookKC, webhookLog, ) }🤖 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 `@cmd/provider-services/cmd/run.go` around lines 932 - 943, The shutdown handler currently calls DeregisterWebhookConfiguration with an unbounded context, which can delay webhook server shutdown indefinitely. Create and use a bounded timeout context for deregistration in the group.Go shutdown flow, ensuring the context is canceled appropriately, then preserve the existing webhookSrv.Shutdown timeout behavior.
🤖 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.
Outside diff comments:
In `@cmd/provider-services/cmd/run.go`:
- Around line 832-834: Validate the value returned by
viper.GetInt(FlagAttestationWebhookPort) in both webhook setup paths before
converting or passing it to any narrower integer type. Reject values outside the
valid TCP port range 1–65535 and fail closed before registration or
ListenAndServeTLS, keeping the validated value consistent across webhook
configuration.
- Around line 932-943: The shutdown handler currently calls
DeregisterWebhookConfiguration with an unbounded context, which can delay
webhook server shutdown indefinitely. Create and use a bounded timeout context
for deregistration in the group.Go shutdown flow, ensuring the context is
canceled appropriately, then preserve the existing webhookSrv.Shutdown timeout
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3307ca19-41af-4c05-b8da-74998e76eb68
📒 Files selected for processing (8)
cmd/provider-services/cmd/flags.gocmd/provider-services/cmd/run.goconfig.gomanifest/config.gomanifest/service.gomanifest/watchdog.gomanifest/watchdog_test.goservice.go
🚧 Files skipped from review as they are similar to previous changes (5)
- config.go
- cmd/provider-services/cmd/flags.go
- manifest/service.go
- manifest/watchdog.go
- manifest/watchdog_test.go
Manifest timeout close bids used a context tied to watchdog shutdown. If provider shutdown arrived after timeout fired, the broadcast could fail with context canceled and leave the bid open. Use a fresh bounded tx context for the close-bid broadcast and wire the existing broadcast timeout into the manifest watchdog. Refs akash-network/support#435 Signed-off-by: Joseph Chalabi <chalabi.joseph@gmail.com>
f6b3312 to
1c55090
Compare
Summary
Testing