Skip to content
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

Make panic threshold configurable for cluster #5118

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
16 changes: 16 additions & 0 deletions api/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,22 @@ type ClusterSettings struct {
//
// +optional
HTTP2 *HTTP2Settings `json:"http2,omitempty"`

Copy link
Contributor

@arkodg arkodg Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my preference would be to add a PanicThreshold unit32 field inside HealthCheck supporting values between 0-100

type HealthCheck struct {

// Common settings for load balancer behaviour.
//
// +optional
CommonLbSettings *CommonLbSettings `json:"commonLbSettings,omitempty"`
}

// CommonLoadBalancerSettings exposes various settings that can be applied to all load balancers types for managing
// traffic distribution across the backend instances.
type CommonLbSettings struct {
// HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
// If not set, the default value is 50%. To disable panic mode, set value to `0`.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
// +optional
HealthyPanicThreshold *float64 `json:"healthyPanicThreshold,omitempty"`
}

// CIDR defines a CIDR Address range.
Expand Down
25 changes: 25 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load balancer behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
compression:
description: The compression config for the http streams.
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,17 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load balancer behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
connection:
description: Connection includes backend connection settings.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10698,6 +10698,18 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load
balancer behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
connection:
description: Connection includes backend
connection settings.
Expand Down Expand Up @@ -11675,6 +11687,18 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load
balancer behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
connection:
description: Connection includes backend
connection settings.
Expand Down Expand Up @@ -12746,6 +12770,18 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load balancer
behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
connection:
description: Connection includes backend connection
settings.
Expand Down Expand Up @@ -13731,6 +13767,17 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load balancer behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
connection:
description: Connection includes backend connection
settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,17 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load balancer behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
connection:
description: Connection includes backend connection settings.
properties:
Expand Down Expand Up @@ -1562,6 +1573,17 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load balancer behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
connection:
description: Connection includes backend connection settings.
properties:
Expand Down Expand Up @@ -2571,6 +2593,17 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load balancer behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
connection:
description: Connection includes backend connection
settings.
Expand Down Expand Up @@ -3593,6 +3626,17 @@ spec:
minimum: 0
type: integer
type: object
commonLbSettings:
description: Common settings for load balancer behaviour.
properties:
healthyPanicThreshold:
description: |-
HealthyPanicThreshold sets the maximum number of concurrent streams allowed per connection.
If not set, the default value is 50%. To disable panic mode, set value to `0`.
maximum: 100
minimum: 0
type: number
type: object
connection:
description: Connection includes backend connection settings.
properties:
Expand Down
80 changes: 51 additions & 29 deletions internal/gatewayapi/backendtrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,22 @@
resources *resource.Resources,
) error {
var (
rl *ir.RateLimit
lb *ir.LoadBalancer
pp *ir.ProxyProtocol
hc *ir.HealthCheck
cb *ir.CircuitBreaker
fi *ir.FaultInjection
to *ir.Timeout
ka *ir.TCPKeepalive
rt *ir.Retry
bc *ir.BackendConnection
ds *ir.DNS
h2 *ir.HTTP2Settings
ro *ir.ResponseOverride
cp []*ir.Compression
err, errs error
rl *ir.RateLimit
lb *ir.LoadBalancer
pp *ir.ProxyProtocol
hc *ir.HealthCheck
cb *ir.CircuitBreaker
fi *ir.FaultInjection
to *ir.Timeout
ka *ir.TCPKeepalive
rt *ir.Retry
bc *ir.BackendConnection
ds *ir.DNS
h2 *ir.HTTP2Settings
ro *ir.ResponseOverride
cp []*ir.Compression
lbSettings *ir.CommonLbSettings
err, errs error
)

// Build IR
Expand Down Expand Up @@ -355,6 +356,14 @@
err = perr.WithMessage(err, "ResponseOverride")
errs = errors.Join(errs, err)
}

if policy.Spec.CommonLbSettings != nil {
if lbSettings, err = buildCommonLbSettings(policy.Spec.CommonLbSettings); err != nil {
err = perr.WithMessage(err, "CommonLbSettings")
errs = errors.Join(errs, err)
}

Check warning on line 364 in internal/gatewayapi/backendtrafficpolicy.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/backendtrafficpolicy.go#L362-L364

Added lines #L362 - L364 were not covered by tests
}

cp = buildCompression(policy.Spec.Compression)

ds = translateDNS(policy.Spec.ClusterSettings)
Expand All @@ -374,6 +383,7 @@
r.Timeout = to
r.BackendConnection = bc
r.DNS = ds
r.CommonLbSettings = lbSettings
}
}
}
Expand All @@ -385,6 +395,7 @@
if strings.HasPrefix(r.Destination.Name, prefix) {
r.LoadBalancer = lb
r.DNS = ds
r.CommonLbSettings = lbSettings
}
}
}
Expand Down Expand Up @@ -420,6 +431,7 @@
Timeout: to,
ResponseOverride: ro,
Compression: cp,
CommonLbSettings: lbSettings,
}

// Update the Host field in HealthCheck, now that we have access to the Route Hostname.
Expand All @@ -444,20 +456,21 @@
resources *resource.Resources,
) error {
var (
rl *ir.RateLimit
lb *ir.LoadBalancer
pp *ir.ProxyProtocol
hc *ir.HealthCheck
cb *ir.CircuitBreaker
fi *ir.FaultInjection
ct *ir.Timeout
ka *ir.TCPKeepalive
rt *ir.Retry
ds *ir.DNS
h2 *ir.HTTP2Settings
ro *ir.ResponseOverride
cp []*ir.Compression
err, errs error
rl *ir.RateLimit
lb *ir.LoadBalancer
pp *ir.ProxyProtocol
hc *ir.HealthCheck
cb *ir.CircuitBreaker
fi *ir.FaultInjection
ct *ir.Timeout
ka *ir.TCPKeepalive
rt *ir.Retry
ds *ir.DNS
h2 *ir.HTTP2Settings
ro *ir.ResponseOverride
cp []*ir.Compression
lbSettings *ir.CommonLbSettings
err, errs error
)

// Build IR
Expand All @@ -471,6 +484,12 @@
err = perr.WithMessage(err, "LoadBalancer")
errs = errors.Join(errs, err)
}
if policy.Spec.CommonLbSettings != nil {
if lbSettings, err = buildCommonLbSettings(policy.Spec.CommonLbSettings); err != nil {
err = perr.WithMessage(err, "CommonLbSettings")
errs = errors.Join(errs, err)
}

Check warning on line 491 in internal/gatewayapi/backendtrafficpolicy.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/backendtrafficpolicy.go#L489-L491

Added lines #L489 - L491 were not covered by tests
}
pp = buildProxyProtocol(policy.Spec.ClusterSettings)
hc = buildHealthCheck(policy.Spec.ClusterSettings)
if cb, err = buildCircuitBreaker(policy.Spec.ClusterSettings); err != nil {
Expand Down Expand Up @@ -528,6 +547,7 @@
setIfNil(&r.TCPKeepalive, ka)
setIfNil(&r.Timeout, ct)
setIfNil(&r.DNS, ds)
setIfNil(&r.CommonLbSettings, lbSettings)
}
}

Expand All @@ -547,6 +567,7 @@
// specific policy
setIfNil(&route.LoadBalancer, lb)
setIfNil(&route.DNS, ds)
setIfNil(&route.CommonLbSettings, lbSettings)
}

for _, http := range x.HTTP {
Expand Down Expand Up @@ -585,6 +606,7 @@
DNS: ds,
ResponseOverride: ro,
Compression: cp,
CommonLbSettings: lbSettings,
}

// Update the Host field in HealthCheck, now that we have access to the Route Hostname.
Expand Down
Loading
Loading