Skip to content

Commit

Permalink
Create preStop sentinal file for web deployments (#774)
Browse files Browse the repository at this point in the history
This allows us to start failing readiness checks when we are terminating
so we stop receiving new traffic but can gracefully finish existing
traffic
  • Loading branch information
frankh authored Oct 11, 2023
1 parent 32bc4e8 commit d6cd325
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/posthog/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 30.30.0
version: 30.31.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
Expand Down
6 changes: 3 additions & 3 deletions charts/posthog/templates/_snippet-web-deployments.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ lifecycle:
exec:
command: [
"sh", "-c",
"(echo '{\"event\": \"preStop_started\"}'; sleep 10; echo '{\"event\": \"preStop_ended\"}') > /proc/1/fd/1"
"(echo '{\"event\": \"preStop_started\"}'; touch /tmp/posthog_prestop || true; sleep 20; echo '{\"event\": \"preStop_ended\"}') > /proc/1/fd/1"
]
{{- end -}}


{{/*
Set a grace period that is 10 seconds delay (from
Set a grace period that is 20 seconds delay (from
lifecycle.exec.preStop) + 30 seconds for Gunicorn to gracefully shutdown
+ 5 seconds leeway
*/}}
{{- define "snippet.web-deployments.terminationGracePeriodSeconds" -}}
45
55
{{- end -}}
2 changes: 1 addition & 1 deletion charts/posthog/tests/web-deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ tests:
asserts:
- equal:
path: spec.template.spec.terminationGracePeriodSeconds
value: 45
value: 55
- isNotNull:
path: spec.template.spec.containers[0].lifecycle

0 comments on commit d6cd325

Please sign in to comment.