Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Opt to enable linkerd proxy shutdown from lifecycle preStop
Browse files Browse the repository at this point in the history
Added a new `linkerd` object to values & schema. If `enabled=true` &
`shutdownAfterCheckpoint=true`, then the STS pod's `lifecycle.preStop`
hook will be configured to issue a shutdown call to the local
linkerd-proxy.

This is entirely optional. If a deployment is not using linkerd, then
this option should be left in the default disabled state.
  • Loading branch information
thedodd committed Dec 6, 2023
1 parent 7ded6b6 commit 8073965
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions charts/timescaledb-single/scripts/prestop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ CHECKPOINT;
SELECT 'We are a primary: Successfully invoked checkpoints, now issuing a switchover.';
\! curl -s http://localhost:8008/switchover -XPOST -d '{"leader": "$(hostname)"}'
\endif

\if :linkerdShutdown
\! curl -s -m 5 -X POST http://localhost:4191/shutdown
\endif
1 change: 0 additions & 1 deletion charts/timescaledb-single/templates/configmap-scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ data:
{{- .Files.Get "scripts/patroni_callback.sh" | nindent 4 }}
lifecycle_preStop.sql: |-
{{- .Files.Get "scripts/prestop.sql" | nindent 4 }}
...
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ spec:
command:
- psql
- -X
- --set=linkerdShutdown="{{ if and .Values.linkerd.enabled .Values.linkerd.terminateAfterCheckpoint }}1{{else}}0{{end}}"
- --file
- "{{ template "scripts_dir" . }}/lifecycle_preStop.sql"
# When reusing an already existing volume it sometimes happens that the permissions
Expand Down
17 changes: 17 additions & 0 deletions charts/timescaledb-single/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@
},
"type": "object"
},
"linkerd": {
"additionalProperties": false,
"properties": {
"enabled": {
"type": [
"boolean"
]
},
"terminateAfterCheckpoint": {
"type": [
"boolean"
]
}
},
"type": "object"
},
"enabled": {
"additionalProperties": true
},
Expand Down Expand Up @@ -818,6 +834,7 @@
"fullnameOverride",
"image",
"curlImage",
"linkerd",
"networkPolicy",
"nodeSelector",
"patroni",
Expand Down
9 changes: 9 additions & 0 deletions charts/timescaledb-single/values.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ required:
- fullnameOverride
- image
- curlImage
- linkerd
- networkPolicy
- nodeSelector
- patroni
Expand Down Expand Up @@ -432,6 +433,14 @@ properties:
type:
- string
- "null"
linkerd:
type: object
additionalProperties: false
properties:
enabled:
type: boolean
terminateAfterCheckpoint:
type: boolean
env:
type:
- array
Expand Down
8 changes: 8 additions & 0 deletions charts/timescaledb-single/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -597,3 +597,11 @@ debug:
# This command will be executed *before* the main container starts. In the
# example below, we can mimick a slow restore by sleeping for 5 minutes before starting
execStartPre: # sleep 300

# Support for specific use cases when deploying with the linkerd service mesh.
linkerd:
enabled: false
# As part of the statefulset pod's `lifecycle.preStop`, call the local linkerd sidecar
# to cleanly terminate the proxy. If this is not performed, then the proxy will remain
# alive unnecessarily, blocking pod termination for a period of time.
terminateAfterCheckpoint: true

0 comments on commit 8073965

Please sign in to comment.