-
Notifications
You must be signed in to change notification settings - Fork 349
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
Allow setting a min delay before termination is initiated, e.g. --min-delay-before-term #1333
Comments
Maybe I'm missing something, but wouldn't For example,
Possibly related to #828. |
It would if an application kept at least 1 active connection for its lifetime.
|
Are you using a client side connection pooling library? That would probably alleviate the problems you're seeing. |
Well, I'm aware of potential solutions to this problem, and using connection pool is one of them. |
In almost all cases we recommend using a client side connection pool -- that would open connections for your app, maintain a pool of connections, and abstract away the concern of connection pool management from your application code (or deployment). I'd suggest giving that a try, and reporting back here if you're still running into issues. Hope that helps. |
Feature Description
Imagine an application that is running in Kubernetes pod with Cloud SQL proxy (as a side-car container) to connect to the DB-server. To allow the application to shutdown gracefully, it's important to finish all active client requests before existing. Cloud SQL proxy has a flag -term_timeout that makes proxy to wait for active connections to close before termination, and it might help in some cases. However consider the scenario when the application:
If termination of pod is requested when step 1 is running, there will be no active DB-connections and the container with Cloud SQL proxy will be stopped, however when the application proceeds to step 2, it will immediately fail due to unavailability of Cloud SQL proxy.
Alternatives Considered
It's possible to use Alpine- or Debian-based Docker images and configure preStop hook for the container with Cloud SQL proxy to run something like "sleep 10", however the "default" image is distroless, and it would be good if such functionality can be achieved without using external commands.
Another option is to use preStop hook in the container with the application itself. Since preStop hooks are executed before Kubernetes sends SIGTERM to the pod's containers, the application can exit before the Cloud SQL proxy termination is initiated.
The text was updated successfully, but these errors were encountered: