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

Feature Request: always configure pre-stop hook to call /quitquitquit #361

Closed
hessjcg opened this issue May 23, 2023 · 1 comment · Fixed by #425 or #430
Closed

Feature Request: always configure pre-stop hook to call /quitquitquit #361

hessjcg opened this issue May 23, 2023 · 1 comment · Fixed by #425 or #430
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@hessjcg
Copy link
Collaborator

hessjcg commented May 23, 2023

The proxy exits with exiting with exit code 143 when it receives a SIGTERM from kubernetes. cloud-sql-proxy #1803

To ensure that proxy containers exit with code 0, even when they are

  • Always configure the --exit-zero-on-sigterm flag so that the proxy process plays nice with k8s. When another
    container on the same pod exits, k8s sends the proxy a SIGTERM, and then the proxy exits with code 0.

  • This should be applied to all proxy containers, since we don't want the exit code of the proxy to impact the overall exit status of the pod.

@enocom enocom assigned hessjcg and unassigned enocom May 23, 2023
@jackwotherspoon
Copy link
Collaborator

@hessjcg want to throw a priority and feature request label on this issue?

@hessjcg hessjcg added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p2 Moderately-important priority. Fix may not be included in next release. labels May 28, 2023
hessjcg added a commit that referenced this issue Sep 19, 2023
Add the following configuration to the workload pods so that the proxy can gracefully exit
when the main container is done.

Configure the proxy container to exit 0 when it is terminated. Send a SIGTERM to the proxy container. We want
the proxy to exit with code 0, indicating a clean termination. Without this change the proxy container would
exit with exit code 140 (meaning terminated), which would cause kubernetes to report the
pod as "exited in an error state."

Configure a workload lifecycle handler so that kubernetes calls GET /quitquitquit before terminating the proxy 
container. This should give the proxy container the chance to exit gracefully before kubernetes sends a SIGTERM
to the proxy process.

Always enable the /quitquitquit proxy api.

Always set the CSQL_QUIT_URLS environment variable to a space-separated list of proxy quitquitquit urls. 
This way, when the main workload container is ready to exit, it can on workload pods. When a job or cronjob's 
main process is done, that container can iterate over

```
echo Starting job

# execute the job process
run_job

# Tell proxy containers to shut down gracefully
for url in $CSQL_QUIT_URLS ; do 
   wget --post-data '' $url
done
```
Fixes #361
hessjcg added a commit that referenced this issue Sep 22, 2023
hessjcg added a commit that referenced this issue Oct 3, 2023
)

All proxy and operator-related environment variables need to use the prefix CSQL_PROXY_ for consistency.

Related to #361
hessjcg added a commit that referenced this issue Oct 9, 2023
hessjcg added a commit that referenced this issue Oct 9, 2023
…#436)

Demonstrate how to configure a job so that job containers exit successfully when the job completes.

Related to #361
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
3 participants