Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 3 additions & 47 deletions internal/gatewayapi/clienttrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,11 @@ func (t *Translator) translateClientTrafficPolicyForListener(policy *egv1a1.Clie
}

// Translate HTTP2 Settings
if err = translateHTTP2Settings(policy.Spec.HTTP2, httpIR); err != nil {
if h2, err := buildIRHTTP2Settings(policy.Spec.HTTP2); err != nil {
err = perr.WithMessage(err, "HTTP2")
errs = errors.Join(errs, err)
} else {
httpIR.HTTP2 = h2
}

// enable http3 if set and TLS is enabled
Expand Down Expand Up @@ -745,52 +747,6 @@ func translateHTTP1Settings(http1Settings *egv1a1.HTTP1Settings, connection *ir.
return nil
}

func translateHTTP2Settings(http2Settings *egv1a1.HTTP2Settings, httpIR *ir.HTTPListener) error {
if http2Settings == nil {
return nil
}

var (
http2 = &ir.HTTP2Settings{}
errs error
)

if http2Settings.InitialStreamWindowSize != nil {
initialStreamWindowSize, ok := http2Settings.InitialStreamWindowSize.AsInt64()
switch {
case !ok:
errs = errors.Join(errs, fmt.Errorf("invalid InitialStreamWindowSize value %s", http2Settings.InitialStreamWindowSize.String()))
case initialStreamWindowSize < MinHTTP2InitialStreamWindowSize || initialStreamWindowSize > MaxHTTP2InitialStreamWindowSize:
errs = errors.Join(errs, fmt.Errorf("InitialStreamWindowSize value %s is out of range, must be between %d and %d",
http2Settings.InitialStreamWindowSize.String(),
MinHTTP2InitialStreamWindowSize,
MaxHTTP2InitialStreamWindowSize))
default:
http2.InitialStreamWindowSize = ptr.To(uint32(initialStreamWindowSize))
}
}

if http2Settings.InitialConnectionWindowSize != nil {
initialConnectionWindowSize, ok := http2Settings.InitialConnectionWindowSize.AsInt64()
switch {
case !ok:
errs = errors.Join(errs, fmt.Errorf("invalid InitialConnectionWindowSize value %s", http2Settings.InitialConnectionWindowSize.String()))
case initialConnectionWindowSize < MinHTTP2InitialConnectionWindowSize || initialConnectionWindowSize > MaxHTTP2InitialConnectionWindowSize:
errs = errors.Join(errs, fmt.Errorf("InitialConnectionWindowSize value %s is out of range, must be between %d and %d",
http2Settings.InitialConnectionWindowSize.String(),
MinHTTP2InitialConnectionWindowSize,
MaxHTTP2InitialConnectionWindowSize))
default:
http2.InitialConnectionWindowSize = ptr.To(uint32(initialConnectionWindowSize))
}
}

http2.MaxConcurrentStreams = http2Settings.MaxConcurrentStreams

httpIR.HTTP2 = http2
return errs
}

func translateHealthCheckSettings(healthCheckSettings *egv1a1.HealthCheckSettings, httpIR *ir.HTTPListener) {
// Return early if not set
if healthCheckSettings == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ clientTrafficPolicies:
initialStreamWindowSize: 64Ki
initialConnectionWindowSize: 32Mi
maxConcurrentStreams: 200
onInvalidMessage: TerminateConnection
targetRef:
group: gateway.networking.k8s.io
kind: Gateway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ clientTrafficPolicies:
initialConnectionWindowSize: 32Mi
initialStreamWindowSize: 64Ki
maxConcurrentStreams: 200
onInvalidMessage: TerminateConnection
targetRef:
group: gateway.networking.k8s.io
kind: Gateway
Expand Down Expand Up @@ -191,6 +192,7 @@ xdsIR:
initialConnectionWindowSize: 65536
initialStreamWindowSize: 33554432
maxConcurrentStreams: 200
resetStreamOnError: false
isHTTP2: false
metadata:
kind: Gateway
Expand All @@ -206,8 +208,6 @@ xdsIR:
externalPort: 8080
hostnames:
- www.example.com
http2:
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like translateHTTP2Settings did not perform a no-op in case of an error and translated some of the fields. I'm ok with the change... cc @arkodg

maxConcurrentStreams: 200
isHTTP2: false
metadata:
kind: Gateway
Expand Down