Skip to content

Commit db0128c

Browse files
committed
Allow clusters that do not use kubeproxy to disable presleep
When I tried using "0", it was somehow converted to an integer in the yaml file causing some failures during helm upgrade. So, this also adds quotes around the preStopSleep. Also, the changelog was missing the PR that added the preStopSleep, so add it, and fix the order of another changelog entry to follow the merge order and link to the PR instead of the issue.
1 parent 80f80b4 commit db0128c

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Development
4+
* Allow clusters that do not use kubeproxy to disable presleep. (#416) (by @cognifloyd)
45

56
## v1.1.0
67
* Fix syntax with ensure-packs-volumes-are-writable job (#403, #411) (by @skiedude)
@@ -25,8 +26,9 @@
2526
* Add `st2canary` job as a Helm Hook that runs before install/upgrade to ensure `st2.packs.volumes` is configured correctly (if `st2.packs.volumes.enabled`). (#323) (by @cognifloyd)
2627
* Enable using existing `st2-auth` secret. This allows users to manage this secret outside of the Helm process. (#359) (by @bmarick)
2728
* Add terminationGracePeriodSeconds to workflow and actionrunner pods to allow adjustment of grace period in k8 (#374) (by @guzzijones12)
29+
* Fix st2 client config issue affecting addon jobs using jobs.extra_hooks (#371) (by @cars)
2830
* Prevent duplicate init containers on helm upgrade (#375) (by @guzzijones12)
29-
* Fix st2 client config issue affecting addon jobs using jobs.extra_hooks (#370) (by @cars)
31+
* Workaround kubeproxy+kubelet race: Add presleep for st2auth, st2web, st2api, st2stream (#382) (by @guzzijones12)
3032

3133
## v0.110.0
3234
* Switch st2 to `v3.8` as a new default stable version (#347)

templates/deployments.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,13 @@ spec:
100100
mountPath: /post-start.sh
101101
subPath: post-start.sh
102102
lifecycle:
103+
{{- if .Values.st2auth.preStopSleep | toString | ne "0" }}
103104
preStop:
104105
exec: # https://blog.laputa.io/graceful-shutdown-in-kubernetes-85f1c8d586da
105106
# kubeproxy and kubelet both race
106107
# wait a bit to ensure kubeproxy has removed the iptables rule.
107-
command: [ "sleep", {{ .Values.st2auth.preStopSleep | toString }} ]
108+
command: [ "sleep", "{{ .Values.st2auth.preStopSleep | toString }}" ]
109+
{{- end }}
108110
postStart:
109111
exec:
110112
command: ["/bin/bash", "/post-start.sh"]
@@ -233,11 +235,13 @@ spec:
233235
mountPath: /post-start.sh
234236
subPath: post-start.sh
235237
lifecycle:
238+
{{- if .Values.st2api.preStopSleep | toString | ne "0" }}
236239
preStop:
237240
exec: # https://blog.laputa.io/graceful-shutdown-in-kubernetes-85f1c8d586da
238241
# kubeproxy and kubelet both race
239242
# wait a bit to ensure kubeproxy has removed the iptables rule.
240-
command: [ "sleep", {{ .Values.st2api.preStopSleep | toString }} ]
243+
command: [ "sleep", "{{ .Values.st2api.preStopSleep | toString }}" ]
244+
{{- end }}
241245
postStart:
242246
exec:
243247
command: ["/bin/bash", "/post-start.sh"]
@@ -357,11 +361,13 @@ spec:
357361
mountPath: /post-start.sh
358362
subPath: post-start.sh
359363
lifecycle:
364+
{{- if .Values.st2stream.preStopSleep | toString | ne "0" }}
360365
preStop:
361366
exec: # https://blog.laputa.io/graceful-shutdown-in-kubernetes-85f1c8d586da
362367
# kubeproxy and kubelet both race
363368
# wait a bit to ensure kubeproxy has removed the iptables rule.
364-
command: [ "sleep", {{ .Values.st2stream.preStopSleep | toString }} ]
369+
command: [ "sleep", "{{ .Values.st2stream.preStopSleep | toString }}" ]
370+
{{- end }}
365371
postStart:
366372
exec:
367373
command: ["/bin/bash", "/post-start.sh"]
@@ -483,11 +489,13 @@ spec:
483489
mountPath: /post-start.sh
484490
subPath: post-start.sh
485491
lifecycle:
492+
{{- if .Values.st2web.preStopSleep | toString | ne "0" }}
486493
preStop:
487494
exec: # https://blog.laputa.io/graceful-shutdown-in-kubernetes-85f1c8d586da
488495
# kubeproxy and kubelet both race
489496
# wait a bit to ensure kubeproxy has removed the iptables rule.
490-
command: [ "sleep", {{ .Values.st2web.preStopSleep | toString }} ]
497+
command: [ "sleep", "{{ .Values.st2web.preStopSleep | toString }}" ]
498+
{{- end }}
491499
postStart:
492500
exec:
493501
command: ["/bin/bash", "/post-start.sh"]

values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ st2web:
391391
# The pod will not be marked as "running" until this script completes successfully.
392392
# see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
393393
postStartScript: ""
394+
# preStopSleep works around iptables race conditions in kubeproxy and kubelet.
395+
# https://blog.laputa.io/graceful-shutdown-in-kubernetes-85f1c8d586da
396+
# If you use an alternative to kubeproxy, like Calico, disable this by setting it to "0".
394397
preStopSleep: "10"
395398

396399
# https://docs.stackstorm.com/reference/ha.html#st2auth
@@ -427,6 +430,9 @@ st2auth:
427430
# The pod will not be marked as "running" until this script completes successfully.
428431
# see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
429432
postStartScript: ""
433+
# preStopSleep works around iptables race conditions in kubeproxy and kubelet.
434+
# https://blog.laputa.io/graceful-shutdown-in-kubernetes-85f1c8d586da
435+
# If you use an alternative to kubeproxy, like Calico, disable this by setting it to "0".
430436
preStopSleep: "10"
431437
# mount extra volumes on the st2auth pod(s) (primarily useful for custom logging conf)
432438
## Note that Helm templating is supported in 'mount' and 'volume'
@@ -467,6 +473,9 @@ st2api:
467473
# The pod will not be marked as "running" until this script completes successfully.
468474
# see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
469475
postStartScript: ""
476+
# preStopSleep works around iptables race conditions in kubeproxy and kubelet.
477+
# https://blog.laputa.io/graceful-shutdown-in-kubernetes-85f1c8d586da
478+
# If you use an alternative to kubeproxy, like Calico, disable this by setting it to "0".
470479
preStopSleep: "10"
471480
# mount extra volumes on the st2api pod(s) (primarily useful for custom logging conf)
472481
## Note that Helm templating is supported in 'mount' and 'volume'
@@ -507,6 +516,9 @@ st2stream:
507516
# The pod will not be marked as "running" until this script completes successfully.
508517
# see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
509518
postStartScript: ""
519+
# preStopSleep works around iptables race conditions in kubeproxy and kubelet.
520+
# https://blog.laputa.io/graceful-shutdown-in-kubernetes-85f1c8d586da
521+
# If you use an alternative to kubeproxy, like Calico, disable this by setting it to "0".
510522
preStopSleep: "10"
511523
# mount extra volumes on the st2stream pod(s) (primarily useful for custom logging conf)
512524
## Note that Helm templating is supported in 'mount' and 'volume'

0 commit comments

Comments
 (0)