From 248397f663f5ceb1bf20ab287deb3fd246a3d593 Mon Sep 17 00:00:00 2001 From: Takumi Sue <23391543+mikutas@users.noreply.github.com> Date: Wed, 15 Dec 2021 11:15:11 +0900 Subject: [PATCH] Make terminationGracePeriodSeconds configurable (#659) Make terminationGracePeriodSeconds configurable for server pod --- CHANGELOG.md | 1 + templates/server-statefulset.yaml | 2 +- test/unit/server-statefulset.bats | 21 +++++++++++++++++++++ values.schema.json | 24 ++++++++++++++++++------ values.yaml | 4 ++++ 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aa14de..889aeaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Features: * Added configurable podDisruptionBudget for injector [GH-653](https://github.com/hashicorp/vault-helm/pull/653) +* Make terminationGracePeriodSeconds configurable for server [GH-659](https://github.com/hashicorp/vault-helm/pull/659) ## 0.18.0 (November 17th, 2021) diff --git a/templates/server-statefulset.yaml b/templates/server-statefulset.yaml index 031b179..cbcda96 100644 --- a/templates/server-statefulset.yaml +++ b/templates/server-statefulset.yaml @@ -41,7 +41,7 @@ spec: {{- if .Values.server.priorityClassName }} priorityClassName: {{ .Values.server.priorityClassName }} {{- end }} - terminationGracePeriodSeconds: 10 + terminationGracePeriodSeconds: {{ .Values.server.terminationGracePeriodSeconds }} serviceAccountName: {{ template "vault.serviceAccount.name" . }} {{ if .Values.server.shareProcessNamespace }} shareProcessNamespace: true diff --git a/test/unit/server-statefulset.bats b/test/unit/server-statefulset.bats index b939051..65d6d96 100755 --- a/test/unit/server-statefulset.bats +++ b/test/unit/server-statefulset.bats @@ -1385,6 +1385,27 @@ load _helpers [[ "${actual}" = *"foobar"* ]] } +#-------------------------------------------------------------------- +# terminationGracePeriodSeconds +@test "server/standalone-StatefulSet: terminationGracePeriodSeconds default" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/server-statefulset.yaml \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.terminationGracePeriodSeconds' | tee /dev/stderr) + [[ "${actual}" = "10" ]] +} + +@test "server/standalone-StatefulSet: terminationGracePeriodSeconds 30" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/server-statefulset.yaml \ + --set 'server.terminationGracePeriodSeconds=30' \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.terminationGracePeriodSeconds' | tee /dev/stderr) + [[ "${actual}" = "30" ]] +} + #-------------------------------------------------------------------- # preStop @test "server/standalone-StatefulSet: preStop sleep duration default" { diff --git a/values.schema.json b/values.schema.json index 8e4e076..c3b2a27 100644 --- a/values.schema.json +++ b/values.schema.json @@ -14,6 +14,12 @@ "string" ] }, + "kubeletRootDir": { + "type": "string" + }, + "providersDir": { + "type": "string" + }, "updateStrategy": { "type": "object", "properties": { @@ -24,12 +30,6 @@ "type": "string" } } - }, - "providersDir": { - "type": "string" - }, - "kubeletRootDir": { - "type": "string" } } }, @@ -603,6 +603,9 @@ "labels": { "type": "object" }, + "pathType": { + "type": "string" + }, "tls": { "type": "array" } @@ -728,6 +731,9 @@ "enabled": { "type": "boolean" }, + "externalTrafficPolicy": { + "type": "string" + }, "port": { "type": "integer" }, @@ -781,6 +787,9 @@ } } }, + "terminationGracePeriodSeconds": { + "type": "integer" + }, "tolerations": { "type": [ "null", @@ -823,6 +832,9 @@ "externalPort": { "type": "integer" }, + "externalTrafficPolicy": { + "type": "string" + }, "publishNotReadyAddresses": { "type": "boolean" }, diff --git a/values.yaml b/values.yaml index d17ead2..713b858 100644 --- a/values.yaml +++ b/values.yaml @@ -374,6 +374,10 @@ server: # Number of seconds after which the probe times out. timeoutSeconds: 3 + # Optional duration in seconds the pod needs to terminate gracefully. + # See: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/ + terminationGracePeriodSeconds: 10 + # Used to set the sleep time during the preStop step preStopSleepSeconds: 5