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

Commit

Permalink
Simplify linkerd admin shutdown pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
thedodd committed Dec 7, 2023
1 parent 9ffe03d commit 2e96eac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
3 changes: 1 addition & 2 deletions charts/timescaledb-single/docs/admin-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ The following table lists the configurable parameters of the TimescaleDB Helm ch
| `image.pullPolicy` | The pull policy | `IfNotPresent` |
| `image.repository` | The image to pull | `timescale/timescaledb-ha` |
| `image.tag` | The version of the image to pull | `pg13-ts2.1-latest`
| `linkerd.enabled` | Enabled limited linkerd support. | `false`
| `linkerd.shutdownAfterCheckpoint` | When `true`, configures the StatefulSet Pod's `lifecycle.preStop` to issue a shutdown call to the local linkerd-proxy sidecar after checkpointing is complete. | `false`
| `linkerd.adminShutdownOnExit` | If `true`, then the main TimescaleDB container will be configured to call the local linkerd-proxy sidecar container's `/shutdown` endpoint as soon as Patroni exits. | `false` |
| `service.primary.type` | The service type to use for the primary service | `ClusterIP` |
| `service.primary.port` | The service port to use for the primary service | `5432` |
| `service.primary.nodePort` | The service nodePort to use for the primary service when `type` is `NodePort` | `null` |
Expand Down
4 changes: 0 additions & 4 deletions charts/timescaledb-single/scripts/prestop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,3 @@ 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
12 changes: 10 additions & 2 deletions charts/timescaledb-single/templates/statefulset-timescaledb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ 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 Expand Up @@ -168,7 +167,16 @@ spec:
export PATRONI_POSTGRESQL_PGPASS="${HOME}/.pgpass.patroni"
exec patroni /etc/timescaledb/patroni.yaml
patroni /etc/timescaledb/patroni.yaml
rcode=$?
{{- if .Values.linkerd.adminShutdownOnExit }}
# Once Patroni exits, when running with a linkerd-proxy sidecar, we call linkerd-proxy shutdown.
curl -s -m 5 -X POST http://localhost:4191/shutdown
{{- end }}
# Ensure we exit with the code which was returned by Patroni.
exit $rcode
env:
# We use mixed case environment variables for Patroni User management,
# as the variable themselves are documented to be PATRONI_<username>_OPTIONS.
Expand Down
8 changes: 3 additions & 5 deletions charts/timescaledb-single/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,6 @@ debug:

# 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
# If true, then the main TimescaleDB container will be configured to call the local
# linkerd-proxy sidecar container's /shutdown endpoint as soon as Patroni exits.
adminShutdownOnExit: false

0 comments on commit 2e96eac

Please sign in to comment.