Skip to content

Commit

Permalink
feat: ✨ Added Lifecycle Hook and Termination Grace Period
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcrisap authored and nineinchnick committed May 10, 2024
1 parent 3239a09 commit 50e5089
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions charts/trino/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ The following table lists the configurable parameters of the Trino chart and the
| `coordinator.resources` | | `{}` |
| `coordinator.livenessProbe` | | `{}` |
| `coordinator.readinessProbe` | | `{}` |
| `coordinator.lifecycle` | | `{}` |
| `coordinator.terminationGracePeriodSeconds` | | `30` |
| `coordinator.nodeSelector` | | `{}` |
| `coordinator.tolerations` | | `[]` |
| `coordinator.affinity` | | `{}` |
Expand All @@ -90,6 +92,8 @@ The following table lists the configurable parameters of the Trino chart and the
| `worker.resources` | | `{}` |
| `worker.livenessProbe` | | `{}` |
| `worker.readinessProbe` | | `{}` |
| `worker.lifecycle` | | `{}` |
| `worker.terminationGracePeriodSeconds` | | `30` |
| `worker.nodeSelector` | | `{}` |
| `worker.tolerations` | | `[]` |
| `worker.affinity` | | `{}` |
Expand Down
3 changes: 3 additions & 0 deletions charts/trino/templates/deployment-coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ spec:
{{- end }}
imagePullSecrets:
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.coordinator.terminationGracePeriodSeconds }}
containers:
- name: {{ .Chart.Name }}-coordinator
image: {{ include "trino.image" . }}
Expand Down Expand Up @@ -168,6 +169,8 @@ spec:
timeoutSeconds: {{ .Values.coordinator.readinessProbe.timeoutSeconds | default 5 }}
failureThreshold: {{ .Values.coordinator.readinessProbe.failureThreshold | default 6 }}
successThreshold: {{ .Values.coordinator.readinessProbe.successThreshold | default 1 }}
lifecycle:
{{- toYaml .Values.coordinator.lifecycle | nindent 12 }}
resources:
{{- toYaml .Values.coordinator.resources | nindent 12 }}
{{- if .Values.sidecarContainers.coordinator }}
Expand Down
3 changes: 3 additions & 0 deletions charts/trino/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ spec:
{{- end }}
imagePullSecrets:
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.worker.terminationGracePeriodSeconds }}
containers:
- name: {{ .Chart.Name }}-worker
image: {{ include "trino.image" . }}
Expand Down Expand Up @@ -132,6 +133,8 @@ spec:
timeoutSeconds: {{ .Values.worker.readinessProbe.timeoutSeconds | default 5 }}
failureThreshold: {{ .Values.worker.readinessProbe.failureThreshold | default 6 }}
successThreshold: {{ .Values.worker.readinessProbe.successThreshold | default 1 }}
lifecycle:
{{- toYaml .Values.worker.lifecycle | nindent 12 }}
resources:
{{- toYaml .Values.worker.resources | nindent 12 }}
{{- if .Values.sidecarContainers.worker }}
Expand Down
19 changes: 19 additions & 0 deletions charts/trino/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ coordinator:
# failureThreshold: 6
# successThreshold: 1

lifecycle: {}
# preStop:
# exec:
# command: ["/bin/sh", "-c", "sleep 120"]

terminationGracePeriodSeconds: 30

nodeSelector: {}

tolerations: []
Expand Down Expand Up @@ -364,6 +371,18 @@ worker:
# failureThreshold: 6
# successThreshold: 1

lifecycle: {}
# To enable Graceful shutdown, Define a lifecycle preStop like bellow,
# Set the `terminationGracePeriodSeconds` to a value greater than or equal to the configured `shutdown.grace-period`.
# Configure `shutdown.grace-period` in `additionalConfigProperties` as `shutdown.grace-period=2m` (default is 2 minutes).
# Allow the operation on `accessControl` because isn't allow by default.
# Check the documentaion on https://trino.io/docs/current/admin/graceful-shutdown.html
# preStop:
# exec:
# command: ["/bin/sh", "-c", "curl -v -X PUT -d '\"SHUTTING_DOWN\"' -H \"Content-type: application/json\" http://localhost:8081/v1/info/state"]

terminationGracePeriodSeconds: 30

nodeSelector: {}

tolerations: []
Expand Down

0 comments on commit 50e5089

Please sign in to comment.