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 DelayedCloseTimeout #4348

Open
wants to merge 4 commits 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
13 changes: 12 additions & 1 deletion api/v1alpha1/timeout_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

package v1alpha1

import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
import (
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)

// Timeout defines configuration for timeouts related to connections.
type Timeout struct {
Expand Down Expand Up @@ -81,4 +83,13 @@
//
// +optional
IdleTimeout *gwapiv1.Duration `json:"idleTimeout,omitempty"`

// The delayed close timeout is for downstream connections managed by the HTTP connection manager.
// It is defined as a grace period after connection close processing has been locally initiated
// during which Envoy will wait for the peer to close (i.e., a TCP FIN/RST is received by Envoy
// from the downstream connection) prior to Envoy closing the socket associated with that
// connection.
//The default timeout is 1000 ms if this option is not specified.

Check failure on line 92 in api/v1alpha1/timeout_types.go

View workflow job for this annotation

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
// +optional
DelayedCloseTimeout *gwapiv1.Duration `json:"delayedCloseTimeout,omitempty" yaml:"delayedCloseTimeout,omitempty"`
}
9 changes: 9 additions & 0 deletions internal/gatewayapi/clienttrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,15 @@
Duration: d,
}
}
if clientTimeout.HTTP.DelayedCloseTimeout != nil {
d, err := time.ParseDuration(string(*clientTimeout.HTTP.DelayedCloseTimeout))
if err != nil {
return nil, fmt.Errorf("invalid HTTP DelayedCloseTimeout value %s", *clientTimeout.HTTP.DelayedCloseTimeout)
}
irHTTPTimeout.DelayedCloseTimeout = &metav1.Duration{
Duration: d,
}

Check warning on line 613 in internal/gatewayapi/clienttrafficpolicy.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/clienttrafficpolicy.go#L607-L613

Added lines #L607 - L613 were not covered by tests
}
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 @@ -642,6 +642,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 delayed close timeout is for downstream connections managed by the HTTP connection manager.
// It is defined as a grace period after connection close processing has been locally initiated
// during which Envoy will wait for the peer to close (i.e., a TCP FIN/RST is received by Envoy
// from the downstream connection) prior to Envoy closing the socket associated with that
// connection.
DelayedCloseTimeout *metav1.Duration `json:"delayedCloseTimeout,omitempty" yaml:"delayedCloseTimeout,omitempty"`
}

// HTTPRoute holds the route information associated with the HTTP Route
Expand Down
4 changes: 3 additions & 1 deletion internal/xds/translator/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,12 @@
if irListener.Timeout.HTTP.RequestReceivedTimeout != nil {
mgr.RequestTimeout = durationpb.New(irListener.Timeout.HTTP.RequestReceivedTimeout.Duration)
}

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

Check warning on line 323 in internal/xds/translator/listener.go

View check run for this annotation

Codecov / codecov/patch

internal/xds/translator/listener.go#L322-L323

Added lines #L322 - L323 were not covered by tests
}

// Add the proxy protocol filter if needed
Expand Down
Loading