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

Support StreamIdleTimeout #4350

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions api/v1alpha1/timeout_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ type HTTPClientTimeout struct {
//
// +optional
IdleTimeout *gwapiv1.Duration `json:"idleTimeout,omitempty"`
// The stream idle timeout for connections managed by the connection manager.
// If not specified, this defaults to 5 minutes. The default value was selected
// so as not to interfere with any smaller configured timeouts that may have
// existed in configurations prior to the introduction of this feature, while
// introducing robustness to TCP connections that terminate without a FIN.
//
// +optional
StreamIdleTimeout *gwapiv1.Duration `json:"streamIdleTimeout,omitempty"`
}
9 changes: 9 additions & 0 deletions internal/gatewayapi/clienttrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,15 @@ func buildClientTimeout(clientTimeout *egv1a1.ClientTimeout) (*ir.ClientTimeout,
Duration: d,
}
}
if clientTimeout.HTTP.StreamIdleTimeout != nil {
d, err := time.ParseDuration(string(*clientTimeout.HTTP.StreamIdleTimeout))
if err != nil {
return nil, fmt.Errorf("invalid HTTP StreamIdleTimeout value %s", *clientTimeout.HTTP.StreamIdleTimeout)
}
irHTTPTimeout.StreamIdleTimeout = &metav1.Duration{
Duration: d,
}
}
irClientTimeout.HTTP = irHTTPTimeout
}

Expand Down
6 changes: 6 additions & 0 deletions internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,12 @@ type HTTPClientTimeout struct {
RequestReceivedTimeout *metav1.Duration `json:"requestReceivedTimeout,omitempty" yaml:"requestReceivedTimeout,omitempty"`
// IdleTimeout for an HTTP connection. Idle time is defined as a period in which there are no active requests in the connection.
IdleTimeout *metav1.Duration `json:"idleTimeout,omitempty" yaml:"idleTimeout,omitempty"`
// The stream idle timeout for connections managed by the connection manager.
// If not specified, this defaults to 5 minutes. The default value was selected
// so as not to interfere with any smaller configured timeouts that may have
// existed in configurations prior to the introduction of this feature, while
// introducing robustness to TCP connections that terminate without a FIN.
StreamIdleTimeout *metav1.Duration `json:"idleTimeout,omitempty" yaml:"idleTimeout,omitempty"`
}

// HTTPRoute holds the route information associated with the HTTP Route
Expand Down
4 changes: 4 additions & 0 deletions internal/xds/translator/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ func (t *Translator) addHCMToXDSListener(xdsListener *listenerv3.Listener, irLis
if irListener.Timeout.HTTP.IdleTimeout != nil {
mgr.CommonHttpProtocolOptions.IdleTimeout = durationpb.New(irListener.Timeout.HTTP.IdleTimeout.Duration)
}

if irListener.Timeout.HTTP.StreamIdleTimeout != nil {
mgr.StreamIdleTimeout = durationpb.New(irListener.Timeout.HTTP.StreamIdleTimeout.Duration)
}
}

// Add the proxy protocol filter if needed
Expand Down