Skip to content

Commit

Permalink
[release/v1.1] Cherry-Pick envoyproxy#4279, envoyproxy#4296, envoypro…
Browse files Browse the repository at this point in the history
…xy#4230 (envoyproxy#4315)

* fix: Reconcile on HTTPRoute labels change (envoyproxy#4279)

* added label change predicate

Signed-off-by: Luv <luvk1412@gmail.com>

* added labels predicate for xroute and gw

Signed-off-by: Luv <luvk1412@gmail.com>

* changed predicate to use .Or

Signed-off-by: Luv <luvk1412@gmail.com>

---------

Signed-off-by: Luv <luvk1412@gmail.com>
Co-authored-by: zirain <zirain2009@gmail.com>
(cherry picked from commit 0d1ccae)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* fix: handle invalid sectionName in BackendTLSPolicy for Backend (envoyproxy#4296)

(cherry picked from commit 73c223e)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* fix: Switch to an immediate drain strategy (envoyproxy#4230)

Switch to a immediate drain strategy

* Ensures clients immediately receive a `connection: close` / `GOAWAY`
instead of a probabilistic approach of receiving one b/w drain start and
drain end (defaults to 600s). This should speed up shutdown with clients
reconnecting to newer upgraded proxies.

Fixes: envoyproxy#4205

Signed-off-by: Arko Dasgupta <arko@tetrate.io>
(cherry picked from commit 14f687f)
Signed-off-by: Guy Daich <guy.daich@sap.com>

---------

Signed-off-by: Luv <luvk1412@gmail.com>
Signed-off-by: Guy Daich <guy.daich@sap.com>
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Co-authored-by: Luv <luvk1412@gmail.com>
Co-authored-by: zirain <zirain2009@gmail.com>
Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com>
  • Loading branch information
4 people authored Sep 24, 2024
1 parent 563fb3c commit 8bd641f
Show file tree
Hide file tree
Showing 160 changed files with 147 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,6 @@ xds:
statPrefix: http
useRemoteAddress: true
name: default/eg/http
drainType: MODIFY_ONLY
name: default/eg/http
perConnectionBufferLimitBytes: 32768
- activeState:
Expand Down Expand Up @@ -989,7 +988,6 @@ xds:
statPrefix: http
useRemoteAddress: true
name: default/eg/grpc
drainType: MODIFY_ONLY
name: default/eg/grpc
perConnectionBufferLimitBytes: 32768
- activeState:
Expand All @@ -1012,7 +1010,6 @@ xds:
socketAddress:
address: 0.0.0.0
portValue: 1234
drainType: MODIFY_ONLY
filterChains:
- filters:
- name: envoy.filters.network.tcp_proxy
Expand Down Expand Up @@ -1052,7 +1049,6 @@ xds:
socketAddress:
address: 0.0.0.0
portValue: 8443
drainType: MODIFY_ONLY
filterChains:
- filterChainMatch:
serverNames:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,6 @@
],
"name": "default/eg/http"
},
"drainType": "MODIFY_ONLY",
"name": "default/eg/http",
"perConnectionBufferLimitBytes": 32768
}
Expand Down Expand Up @@ -794,7 +793,6 @@
],
"name": "default/eg/grpc"
},
"drainType": "MODIFY_ONLY",
"name": "default/eg/grpc",
"perConnectionBufferLimitBytes": 32768
}
Expand Down Expand Up @@ -831,7 +829,6 @@
"portValue": 1234
}
},
"drainType": "MODIFY_ONLY",
"filterChains": [
{
"filters": [
Expand Down Expand Up @@ -897,7 +894,6 @@
"portValue": 8443
}
},
"drainType": "MODIFY_ONLY",
"filterChains": [
{
"filterChainMatch": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ xds:
statPrefix: http
useRemoteAddress: true
name: default/eg/http
drainType: MODIFY_ONLY
name: default/eg/http
perConnectionBufferLimitBytes: 32768
- activeState:
Expand Down Expand Up @@ -470,7 +469,6 @@ xds:
statPrefix: http
useRemoteAddress: true
name: default/eg/grpc
drainType: MODIFY_ONLY
name: default/eg/grpc
perConnectionBufferLimitBytes: 32768
- activeState:
Expand All @@ -493,7 +491,6 @@ xds:
socketAddress:
address: 0.0.0.0
portValue: 1234
drainType: MODIFY_ONLY
filterChains:
- filters:
- name: envoy.filters.network.tcp_proxy
Expand Down Expand Up @@ -533,7 +530,6 @@ xds:
socketAddress:
address: 0.0.0.0
portValue: 8443
drainType: MODIFY_ONLY
filterChains:
- filterChainMatch:
serverNames:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ xds:
statPrefix: http
useRemoteAddress: true
name: default/eg/http
drainType: MODIFY_ONLY
name: default/eg/http
perConnectionBufferLimitBytes: 32768
- activeState:
Expand Down Expand Up @@ -127,7 +126,6 @@ xds:
statPrefix: http
useRemoteAddress: true
name: default/eg/grpc
drainType: MODIFY_ONLY
name: default/eg/grpc
perConnectionBufferLimitBytes: 32768
- activeState:
Expand All @@ -150,7 +148,6 @@ xds:
socketAddress:
address: 0.0.0.0
portValue: 1234
drainType: MODIFY_ONLY
filterChains:
- filters:
- name: envoy.filters.network.tcp_proxy
Expand Down Expand Up @@ -190,7 +187,6 @@ xds:
socketAddress:
address: 0.0.0.0
portValue: 8443
drainType: MODIFY_ONLY
filterChains:
- filterChainMatch:
serverNames:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@
],
"name": "envoy-gateway-system/eg/http"
},
"drainType": "MODIFY_ONLY",
"name": "envoy-gateway-system/eg/http",
"perConnectionBufferLimitBytes": 32768
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ xds:
statPrefix: http
useRemoteAddress: true
name: envoy-gateway-system/eg/http
drainType: MODIFY_ONLY
name: envoy-gateway-system/eg/http
perConnectionBufferLimitBytes: 32768
- '@type': type.googleapis.com/envoy.admin.v3.RoutesConfigDump
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,5 @@ xds:
statPrefix: http
useRemoteAddress: true
name: envoy-gateway-system/eg/http
drainType: MODIFY_ONLY
name: envoy-gateway-system/eg/http
perConnectionBufferLimitBytes: 32768
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ xds:
statPrefix: http
useRemoteAddress: true
name: envoy-gateway-system/eg/http
drainType: MODIFY_ONLY
name: envoy-gateway-system/eg/http
perConnectionBufferLimitBytes: 32768
- '@type': type.googleapis.com/envoy.admin.v3.RoutesConfigDump
Expand Down
13 changes: 4 additions & 9 deletions internal/cmd/envoy/shutdown_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func shutdownReadyHandler(w http.ResponseWriter, readyTimeout time.Duration, rea
}

// Shutdown is called from a preStop hook on the shutdown-manager container where
// it will initiate a graceful drain sequence on the Envoy proxy and block until
// it will initiate a drain sequence on the Envoy proxy and block until
// connections are drained or a timeout is exceeded.
func Shutdown(drainTimeout time.Duration, minDrainDuration time.Duration, exitAtConnections int) error {
startTime := time.Now()
Expand All @@ -125,19 +125,14 @@ func Shutdown(drainTimeout time.Duration, minDrainDuration time.Duration, exitAt
logger = logging.FileLogger("/proc/1/fd/1", "shutdown-manager", egv1a1.LogLevelInfo)
}

logger.Info(fmt.Sprintf("initiating graceful drain with %.0f second minimum drain period and %.0f second timeout",
logger.Info(fmt.Sprintf("initiating drain with %.0f second minimum drain period and %.0f second timeout",
minDrainDuration.Seconds(), drainTimeout.Seconds()))

// Start failing active health checks
if err := postEnvoyAdminAPI("healthcheck/fail"); err != nil {
logger.Error(err, "error failing active health checks")
}

// Initiate graceful drain sequence
if err := postEnvoyAdminAPI("drain_listeners?graceful&skip_exit"); err != nil {
logger.Error(err, "error initiating graceful drain")
}

// Poll total connections from Envoy admin API until minimum drain period has
// been reached and total connections reaches threshold or timeout is exceeded
for {
Expand All @@ -154,10 +149,10 @@ func Shutdown(drainTimeout time.Duration, minDrainDuration time.Duration, exitAt
}

if elapsedTime > drainTimeout {
logger.Info("graceful drain sequence timeout exceeded")
logger.Info("drain sequence timeout exceeded")
break
} else if allowedToExit && conn != nil && *conn <= exitAtConnections {
logger.Info("graceful drain sequence completed")
logger.Info("drain sequence completed")
break
}

Expand Down
5 changes: 4 additions & 1 deletion internal/gatewayapi/backendtlspolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ func backendTLSTargetMatched(policy gwapiv1a3.BackendTLSPolicy, target gwapiv1a2
target.Kind == currTarget.Kind &&
backendNamespace == policy.Namespace &&
target.Name == currTarget.Name {
if currTarget.SectionName != nil && *currTarget.SectionName != *target.SectionName {
if currTarget.SectionName != nil {
if target.SectionName != nil && *currTarget.SectionName == *target.SectionName {
return true
}
return false
}
return true
Expand Down
39 changes: 35 additions & 4 deletions internal/gatewayapi/testdata/backendtlspolicy-default-ns.in.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ httpRoutes:
- name: http-backend
namespace: default
port: 8080
- name: backend-ip-tls
- name: backend-ip-tls-1
namespace: default
kind: Backend
group: gateway.envoyproxy.io
- name: backend-ip-tls-2
namespace: default
kind: Backend
group: gateway.envoyproxy.io
Expand Down Expand Up @@ -140,13 +144,30 @@ backendTLSPolicies:
- apiVersion: gateway.networking.k8s.io/v1alpha2
kind: BackendTLSPolicy
metadata:
name: policy-btls-backend-ip
name: policy-btls-backend-ip-1
namespace: default
spec:
targetRefs:
- group: gateway.envoyproxy.io
kind: Backend
name: backend-ip-tls
name: backend-ip-tls-1
validation:
caCertificateRefs:
- name: ca-cmap
group: ''
kind: ConfigMap
hostname: ip-backend
- apiVersion: gateway.networking.k8s.io/v1alpha2
kind: BackendTLSPolicy
metadata:
name: policy-btls-backend-ip-2
namespace: default
spec:
targetRefs:
- group: gateway.envoyproxy.io
kind: Backend
name: backend-ip-tls-2
sectionName: 3443
validation:
caCertificateRefs:
- name: ca-cmap
Expand All @@ -157,10 +178,20 @@ backends:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: Backend
metadata:
name: backend-ip-tls
name: backend-ip-tls-1
namespace: default
spec:
endpoints:
- ip:
address: 2.2.2.2
port: 3443
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: Backend
metadata:
name: backend-ip-tls-2
namespace: default
spec:
endpoints:
- ip:
address: 3.3.3.3
port: 3443
57 changes: 52 additions & 5 deletions internal/gatewayapi/testdata/backendtlspolicy-default-ns.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ backendTLSPolicies:
kind: BackendTLSPolicy
metadata:
creationTimestamp: null
name: policy-btls-backend-ip
name: policy-btls-backend-ip-1
namespace: default
spec:
targetRefs:
- group: gateway.envoyproxy.io
kind: Backend
name: backend-ip-tls
name: backend-ip-tls-1
validation:
caCertificateRefs:
- group: ""
Expand All @@ -60,12 +60,32 @@ backendTLSPolicies:
status: "True"
type: Accepted
controllerName: gateway.envoyproxy.io/gatewayclass-controller
- apiVersion: gateway.networking.k8s.io/v1alpha2
kind: BackendTLSPolicy
metadata:
creationTimestamp: null
name: policy-btls-backend-ip-2
namespace: default
spec:
targetRefs:
- group: gateway.envoyproxy.io
kind: Backend
name: backend-ip-tls-2
sectionName: "3443"
validation:
caCertificateRefs:
- group: ""
kind: ConfigMap
name: ca-cmap
hostname: ip-backend
status:
ancestors: null
backends:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: Backend
metadata:
creationTimestamp: null
name: backend-ip-tls
name: backend-ip-tls-1
namespace: default
spec:
endpoints:
Expand All @@ -79,6 +99,24 @@ backends:
reason: Accepted
status: "True"
type: Accepted
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: Backend
metadata:
creationTimestamp: null
name: backend-ip-tls-2
namespace: default
spec:
endpoints:
- ip:
address: 3.3.3.3
port: 3443
status:
conditions:
- lastTransitionTime: null
message: The Backend was accepted
reason: Accepted
status: "True"
type: Accepted
gateways:
- apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
Expand Down Expand Up @@ -139,7 +177,11 @@ httpRoutes:
port: 8080
- group: gateway.envoyproxy.io
kind: Backend
name: backend-ip-tls
name: backend-ip-tls-1
namespace: default
- group: gateway.envoyproxy.io
kind: Backend
name: backend-ip-tls-2
namespace: default
matches:
- path:
Expand Down Expand Up @@ -221,9 +263,14 @@ xdsIR:
tls:
caCertificate:
certificate: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURKekNDQWcrZ0F3SUJBZ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qd2RWaURSRUdTams3SlcxN3ZsNTc2SGpEa2RmUndpNEUyOFN5ZFJJblpmNkoKaThIWmNaN2NhSDZEeFIzMzVmZ0hWekxpNU5pVGNlL09qTkJRelEyTUpYVkRkOERCbUc1ZnlhdEppT0pRNGJXRQpBN0ZsUDBSZFAzQ08zR1dFME01aVhPQjJtMXFXa0UyZXlPNFVIdndUcU5RTGRyZEFYZ0RRbGJhbTllNEJHM0dnCmQvNnRoQWtXRGJ0L1FOVCtFSkhEQ3ZoRFJLaDFSdUdIeWcrWSsvbmViVFdXckZXc2t0UnJiT29IQ1ppQ3BYSTEKM2VYRTZudDBZa2d0RHhHMjJLcW5ocEFnOWdVU3MyaGxob3h5dmt6eUYwbXU2TmhQbHdBZ25xNysvUT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
name: policy-btls-backend-ip/default-ca
name: policy-btls-backend-ip-1/default-ca
sni: ip-backend
weight: 1
- addressType: IP
endpoints:
- host: 3.3.3.3
port: 3443
weight: 1
hostname: '*'
isHTTP2: false
metadata:
Expand Down
1 change: 1 addition & 0 deletions internal/infrastructure/kubernetes/proxy/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func expectedProxyContainers(infra *ir.ProxyInfra,
fmt.Sprintf("--config-yaml %s", bootstrapConfigurations),
fmt.Sprintf("--log-level %s", logging.DefaultEnvoyProxyLoggingLevel()),
"--cpuset-threads",
"--drain-strategy immediate",
}

if infra.Config != nil &&
Expand Down
Loading

0 comments on commit 8bd641f

Please sign in to comment.