-
Notifications
You must be signed in to change notification settings - Fork 687
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 for draining node during pod termination #1473
Comments
Related issue for nginx ingress controller: nginxinc/kubernetes-ingress#267 |
Somewhat related use-case cc: @AaronTriplett: Could someone answer the following question regarding the use of We’re using multiple long-lived gRPC connections for each user (Chat app) and have the idea of using session affinity to ensure any connections for a specific user end up on the same pod. When set up in this fashion, it would allow us to have those server / pod instances reroute data to the appropriate pod in which is affinitzed to a specific user by setting the user-id header to the “destination” user and essentially calling their own route through Ambassador. It seems like its worth a try, but I want to ensure that if a pod is downed, all of the user-id header values affinitized to said pod get evicted and the next incoming request with that header is forwarded and affinitized to a new pod. (edited) Aaron Triplett [11:45 PM] |
I've also opened this on the envoy side: envoyproxy/envoy#6730 |
Wanted to note this needs to happen on any host change, scaling up, scaling down, and pod termination or failure. |
I'm estimating this at 5 story points because it involves Envoy and Kubernetes and Ambassador. Honestly fitting this into |
I'm currently working on this, and this is at a state where the terminating pods have made their way to Envoy - but indicating Envoy that this connection is being drained is proving to be a problem. I've opened an issue in Envoy regarding this at envoyproxy/envoy#7218 Also, from Slack -
Any leads/pointers appreciated. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
not stale |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
not stale |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
not stale |
not stale |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
not stale |
Hi, Would this issue include other active connections? Like draining TCP connections |
Contour already has this and their implementation seems pretty solid projectcontour/contour#145 |
Any updates on this one? I see Contour has added a shutdown manager sidecar for handling clean shutdowns in https://github.com/projectcontour/contour/pull/2227/files . I tried to to add a preStop hook for draining connections and failing envoy healthchecks, but |
We have a patch we'll put up soon for this in legacy mode, but non-legacy is looking a bit tricky, because dgroup makes assumptions - in particular that there are no actions accessible to clients of dgroup during graceful shutdowns: https://github.com/datawire/dlib/blob/master/dgroup/group.go#L294 One possible way is to permit fallible user supplied calls to be called-back-to by the graceful shutdown logic. But also dgroup explicitly doesn't support dependencies (https://github.com/datawire/dlib/blob/master/dgroup/group.go#L19) I note ambex that similarly needs to manage TERM logic and doesn't use dgroup. Another possibility would be a config option that disables signal handling for TERM, allowing the TERM logic to be written outside of dgroup, rather than the all-or-nothing signal handling present today. Some guidance on this would be needed before we start investing in coding. |
Yeah, I've been growing increasingly dissatisfied with dgroup's signal That said, I'm not sure I follow what you need dgroup to do that it grp.Go("drainer", func(ctx context.Context) error {
<-ctx.Done() // wait for graceful shutdown to start
ctx = dcontext.HardContext(ctx)
// graceful shutdown code goes here
}) That said, if you're still unsure, but you've got a working patch for |
Ah, thanks for the hint. Yes, we'll get the legacy patch up in a day or two , just sorting attribution stuff internally and validating the most recent forward port - its currently against master, since all the code is still there as of late last week, but we'll see :) |
A lot of the legacy-mode code is still on |
@LukeShu the problem is that dexec.CommandContext kills off things when the graceful shutdown starts. Which is the opposite of graceful when dealing with longer lived sockets in a subprocess. We could perhaps write a layered Context.Background() :
This might also need the same done for ambex, to ensure that envoy doesn't get configuration errors during draining. Thoughts? |
Righto, PR up at #3926 |
@LukeShu ping [on the PR and the golang thoughts here] |
Any updates on this one? We were seeing 5XXs during pod restarts which we were able to fix by calling |
Hey @marianafranco and thread, apologies for the delay, the team will get back to you on this shortly! |
@marianafranco you could use our patch from #3926 for legacy mode. We haven't got a patch for non-legacy together yet. |
@rbtcollins Thanks for this fix! I tested it in one of our staging environments and it's working (no 5XXs during pod restarts/termination) when AMBASSADOR_LEGACY_MODE=true is set. Unfortunately, I was mistaken and we are not using the AMBASSADOR_LEGACY_MODE in production today. Do you know what would be the downside of move back to the AMBASSADOR_LEGACY_MODE vs the default one (we are using v1.14.2)? |
I don't know - needless to say we're using legacy mode just fine :). |
Hi, any updates if this is supported on the non-legacy versions? If not, curious to understand if switching to LEGACY mode will have any consequences. |
Hi @mohitreddy1996 , the docs indicate that AMBASSADOR_LEGACY_MODE is not recommended when performance is critical. Closing as it appears the original issue has been addressed. |
@cindymullins-dw I'm not sure this has been addressed… The patch @rbtcollins shared is for legacy mode only, and as you point out legacy mode is not recommended if one needs high performance. |
Please describe your use case / problem.
We have a legacy very-stateful application (tomcat/java), which needs sticky sessions. When we deploy new versions of our applications, or a scale down event happens, we need to stop sending new connections to a server, while sending bound sessions to the old server. Please note: this is not referring to in-flight requests, we're needing the active tomcat sessions to expire, which normally takes about an hour.
We have this working currently in Kubernetes with HAProxy-Ingress by setting its
drain-support
flag, which drains a pod when it transitions toTerminating
, but keeps existing sessions attached to that pod. We then have apreStop
hook which blocks the shutdown until users have finished their sessions.When looking at Ambassador to fulfill this ingress role, we see the pod being removed from routing as soon as it transitions to Terminating. This was tested with a simple application returning the hostname of the pod:
Describe the solution you'd like
We'd love for ambassador to drain a pod when it is in Terminating, and keep existing connections alive, whilst routing new connections to other active Pods.
Additional context
Looking at the Kubernetes docs, it looks like they are dropping the pods from the Service registry, as soon as they pod moves to terminating. As per: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods
Test Details
Ambassador Service Configuration
Ambassador Target Service Configuration:
The text was updated successfully, but these errors were encountered: