Skip to content

Conversation

@alam-cloud
Copy link

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

  1. cmd/atc-installer/installer/run.go

    • Added timeout fields to the Config struct
    • Added environment variable setup for all timeout configurations
  2. cmd/atc/config.go

    • Added timeout fields to the main Config struct
    • Added environment variable loading via conf.Var
  3. cmd/atc/resources.go

    • Updated webhook configurations to use separate timeout values for each webhook type
    • Fixed duplicate TimeoutSeconds field in flightValidation webhook

Testing

  • All files compile successfully
  • Webhook configurations now use the appropriate timeout values
  • Environment variables are properly passed from installer to ATC container

Backward Compatibility

All timeout fields default to their previous hardcoded values if not explicitly configured, ensuring backward compatibility.

if cfg.ExternalResourceValidationWebhookTimeout > 0 {
return ptr.To(cfg.ExternalResourceValidationWebhookTimeout)
}
return ptr.To[int32](30)
Copy link
Collaborator

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.

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)"`
Copy link
Collaborator

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.

}

// Get timeout value for airway validation webhook, defaulting to 10 seconds if not configured
airwayTimeoutSeconds := func() *int32 {
Copy link
Collaborator

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)

@alam-cloud alam-cloud force-pushed the atc-configure-validation-webhook-timeout-v2 branch from 6274844 to cb52118 Compare December 3, 2025 21:48
flightTimeoutSeconds := withDefault(cfg.FlightValidationWebhookTimeout, 30)
resourceTimeoutSeconds := withDefault(cfg.ResourceValidationWebhookTimeout, 10)
externalResourceTimeoutSeconds := withDefault(cfg.ExternalResourceValidationWebhookTimeout, 1)
airwayValidation := &admissionregistrationv1.ValidatingWebhookConfiguration{
Copy link
Collaborator

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?

@alam-cloud alam-cloud force-pushed the atc-configure-validation-webhook-timeout-v2 branch from cb52118 to 48614aa Compare December 15, 2025 16:03
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