feat(gateway): add shutdown-delay and grace-period caddy settings#471
Conversation
Expose Caddy's global `shutdown_delay` and `grace_period` directives via two new settings under `gateway.caddyfile.*`. Both are optional with no default — when unset, Caddy's own defaults apply. Add `settings.GetDuration` / `GetDurationOrDefault` helpers and register them in the catalog generator so future duration settings are picked up automatically. Confidence: high Scope-risk: narrow Not-tested: no unit/e2e test added for the new caddyfile directives
WalkthroughThis PR adds type-safe duration configuration for Caddy gateway shutdown behavior. New ChangesGateway Caddy shutdown and grace-period settings
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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: 0
🧹 Nitpick comments (1)
internal/resources/settings/helpers.go (1)
437-440: ⚡ Quick winInclude setting key context in duration parse errors.
When parsing fails, the error should identify which setting key was invalid to make reconciliation failures actionable.
Proposed change
func GetDuration(ctx core.Context, stack string, keys ...string) (*time.Duration, error) { value, err := GetString(ctx, stack, keys...) if err != nil { return nil, err } @@ duration, err := time.ParseDuration(*value) if err != nil { - return nil, err + return nil, errors.Wrapf(err, "invalid duration for setting '%s'", strings.Join(keys, ".")) } return &duration, nil }🤖 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 `@internal/resources/settings/helpers.go` around lines 437 - 440, The time.ParseDuration call that parses *value should return an error that includes the setting key so callers know which setting failed; replace the bare return of err after time.ParseDuration(*value) with a wrapped error that references the setting key (e.g., using fmt.Errorf("invalid duration for setting %q: %w", key, err)) so the function (surrounding symbols: time.ParseDuration, value, duration) returns the original error wrapped with the setting key context.
🤖 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.
Nitpick comments:
In `@internal/resources/settings/helpers.go`:
- Around line 437-440: The time.ParseDuration call that parses *value should
return an error that includes the setting key so callers know which setting
failed; replace the bare return of err after time.ParseDuration(*value) with a
wrapped error that references the setting key (e.g., using fmt.Errorf("invalid
duration for setting %q: %w", key, err)) so the function (surrounding symbols:
time.ParseDuration, value, duration) returns the original error wrapped with the
setting key context.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1e406d2e-31ab-40ea-af67-e2fb3da962be
⛔ Files ignored due to path filters (1)
docs/09-Configuration reference/settings.catalog.jsonis excluded by!**/*.json
📒 Files selected for processing (6)
cmd/settings-catalog/main.godocs/09-Configuration reference/01-Settings.mdinternal/resources/gateways/Caddyfile.gotplinternal/resources/gateways/caddyfile.gointernal/resources/gateways/configuration.gointernal/resources/settings/helpers.go
Expose Caddy's global
shutdown_delayandgrace_perioddirectives via two new settings undergateway.caddyfile.*. Both are optional with no default — when unset, Caddy's own defaults apply.Add
settings.GetDuration/GetDurationOrDefaulthelpers and register them in the catalog generator so future duration settings are picked up automatically.Confidence: high
Scope-risk: narrow
Not-tested: no unit/e2e test added for the new caddyfile directives