config: add circuit breaker thresholds (#5650)

## Summary
Add a new `circuit_breaker_thresholds` option:

```yaml
circuit_breaker_thresholds:
  max_connections: 1
  max_pending_requests: 2
  max_requests: 3
  max_retries: 4
  max_connection_pools: 5
```

This option can be set at the global level or at the route level. Each
threshold is optional and when not set a default will be used. For
internal clusters we will disable the circuit breaker. For normal routes
we will use the envoy defaults.

## Related issues
-
[ENG-2310](https://linear.app/pomerium/issue/ENG-2310/add-circuit-breaker-settings-per-route)

## Checklist
- [x] reference any related issues
- [x] updated unit tests
- [x] add appropriate label (`enhancement`, `bug`, `breaking`,
`dependencies`, `ci`)
- [x] ready for review
This commit is contained in:
Caleb Doxsey 2025-06-16 09:38:39 -06:00 committed by GitHub
parent e320a532de
commit 5ac7ae9c26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 1571 additions and 1127 deletions

View file

@ -291,7 +291,8 @@ type Options struct {
RuntimeFlags RuntimeFlags `mapstructure:"runtime_flags" yaml:"runtime_flags,omitempty"`
HTTP3AdvertisePort null.Uint32 `mapstructure:"-" yaml:"-" json:"-"`
HTTP3AdvertisePort null.Uint32 `mapstructure:"-" yaml:"-" json:"-"`
CircuitBreakerThresholds *CircuitBreakerThresholds `mapstructure:"circuit_breaker_thresholds" yaml:"circuit_breaker_thresholds" json:"circuit_breaker_thresholds"`
}
type certificateFilePair struct {
@ -1593,6 +1594,9 @@ func (o *Options) ApplySettings(ctx context.Context, certsIndex *cryptutil.Certi
return RuntimeFlag(k), v
})
o.HTTP3AdvertisePort = null.Uint32FromPtr(settings.Http3AdvertisePort)
if settings.CircuitBreakerThresholds != nil {
o.CircuitBreakerThresholds = CircuitBreakerThresholdsFromPB(settings.CircuitBreakerThresholds)
}
}
func (o *Options) ToProto() *config.Config {
@ -1720,6 +1724,9 @@ func (o *Options) ToProto() *config.Config {
return string(k), v
})
settings.Http3AdvertisePort = o.HTTP3AdvertisePort.Ptr()
if o.CircuitBreakerThresholds != nil {
settings.CircuitBreakerThresholds = CircuitBreakerThresholdsToPB(o.CircuitBreakerThresholds)
}
routes := make([]*config.Route, 0, o.NumPolicies())
for p := range o.GetAllPolicies() {