-
Notifications
You must be signed in to change notification settings - Fork 28
Add configurable timeout settings for all validation webhooks #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add configurable timeout settings for all validation webhooks #218
Conversation
cmd/atc/resources.go
Outdated
| if cfg.ExternalResourceValidationWebhookTimeout > 0 { | ||
| return ptr.To(cfg.ExternalResourceValidationWebhookTimeout) | ||
| } | ||
| return ptr.To[int32](30) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should be very short.
This is because this webhook applies to all resources, and we if the airway is not available we don't want to block admission if we can avoid it.
Also, the entirety of the implementation of this webhook is in memory:
- looking up a sync.Map key/value
- writing an event to an in-memory queue
And so should take on the order of milliseconds to execute.
cmd/atc-installer/installer/run.go
Outdated
| CacheFS string `json:"cacheFS,omitzero" Description:"controls location to mount empty dir for wasm module fs cache. Defaults to /tmp if unset"` | ||
| AirwayValidationWebhookTimeout int `json:"airwayValidationWebhookTimeout,omitzero" Description:"timeout in seconds for airway instance validation webhooks (default: 10)"` | ||
| ResourceValidationWebhookTimeout int `json:"resourceValidationWebhookTimeout,omitzero" Description:"timeout in seconds for resource/event dispatching validation webhooks (default: 5)"` | ||
| ExternalResourceValidationWebhookTimeout int `json:"externalResourceValidationWebhookTimeout,omitzero" Description:"timeout in seconds for external resource validation webhooks (default: 30)"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to change the default here to 1.
cmd/atc/resources.go
Outdated
| } | ||
|
|
||
| // Get timeout value for airway validation webhook, defaulting to 10 seconds if not configured | ||
| airwayTimeoutSeconds := func() *int32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps wrap this logic of checking an int32 and returning a default if <=0 into a small utility function?
This is taking up a lot of vertical space for something that could probably be read inline in a declarative way:
Example:
Timeout: withDefault(cfg.AirwayValidationWebhookTimeout, 10)6274844 to
cb52118
Compare
| flightTimeoutSeconds := withDefault(cfg.FlightValidationWebhookTimeout, 30) | ||
| resourceTimeoutSeconds := withDefault(cfg.ResourceValidationWebhookTimeout, 10) | ||
| externalResourceTimeoutSeconds := withDefault(cfg.ExternalResourceValidationWebhookTimeout, 1) | ||
| airwayValidation := &admissionregistrationv1.ValidatingWebhookConfiguration{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we inline these values into CRD definitions using standard cmp.Or and ptr.To?
cb52118 to
48614aa
Compare
Add configurable timeout settings for all validation webhooks
Summary
This PR adds configurable timeout settings for all four types of validation webhooks in the ATC (Air Traffic Controller) system. Previously, timeouts were hardcoded or only partially configurable. Now each webhook type can have its own timeout configuration.
Changes
New Configuration Fields
Added four new timeout configuration fields to the installer:
AirwayValidationWebhookTimeout- Timeout for airway instance validation webhooks (default: 10 seconds)ResourceValidationWebhookTimeout- Timeout for resource/event dispatching validation webhooks (default: 5 seconds)ExternalResourceValidationWebhookTimeout- Timeout for external resource validation webhooks (default: 30 seconds)FlightValidationWebhookTimeout- Timeout for flight validation webhooks (default: 30 seconds)Files Modified
cmd/atc-installer/installer/run.goConfigstructcmd/atc/config.goConfigstructconf.Varcmd/atc/resources.goTimeoutSecondsfield inflightValidationwebhookTesting
Backward Compatibility
All timeout fields default to their previous hardcoded values if not explicitly configured, ensuring backward compatibility.