From 97aff35e2b6053dd2655ca45def88a786278ed34 Mon Sep 17 00:00:00 2001 From: mikutas <23391543+mikutas@users.noreply.github.com> Date: Thu, 9 Dec 2021 20:01:37 +0900 Subject: [PATCH 1/5] Make terminationGracePeriodSeconds configurable for server pod --- templates/server-statefulset.yaml | 2 +- values.yaml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/server-statefulset.yaml b/templates/server-statefulset.yaml index 031b17905..cbcda967d 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/values.yaml b/values.yaml index 5ba57d41c..7c14dae2b 100644 --- a/values.yaml +++ b/values.yaml @@ -368,6 +368,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 From 51b367d31235819aa3d35368dd8daf6179cf9d9a Mon Sep 17 00:00:00 2001 From: mikutas <23391543+mikutas@users.noreply.github.com> Date: Tue, 14 Dec 2021 22:07:57 +0900 Subject: [PATCH 2/5] Add unit test --- test/unit/server-statefulset.bats | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/unit/server-statefulset.bats b/test/unit/server-statefulset.bats index b93905188..eb6f7520d 100755 --- a/test/unit/server-statefulset.bats +++ b/test/unit/server-statefulset.bats @@ -1385,6 +1385,17 @@ 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" ]] +} + #-------------------------------------------------------------------- # preStop @test "server/standalone-StatefulSet: preStop sleep duration default" { From a57914b6b21337c70c1127f1cb50de8818bcc0bc Mon Sep 17 00:00:00 2001 From: mikutas <23391543+mikutas@users.noreply.github.com> Date: Wed, 15 Dec 2021 09:36:43 +0900 Subject: [PATCH 3/5] Modify values.schema.json manually first ran `make values-schema` second modified manually to revert unnecessary changes --- values.schema.json | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/values.schema.json b/values.schema.json index 26f136748..fe1ba2dc7 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" } } }, @@ -600,6 +600,9 @@ "labels": { "type": "object" }, + "pathType": { + "type": "string" + }, "tls": { "type": "array" } @@ -725,6 +728,9 @@ "enabled": { "type": "boolean" }, + "externalTrafficPolicy": { + "type": "string" + }, "port": { "type": "integer" }, @@ -778,6 +784,9 @@ } } }, + "terminationGracePeriodSeconds": { + "type": "integer" + }, "tolerations": { "type": [ "null", @@ -820,6 +829,9 @@ "externalPort": { "type": "integer" }, + "externalTrafficPolicy": { + "type": "string" + }, "publishNotReadyAddresses": { "type": "boolean" }, From 772dbaa41c039d5aec7b2002904ad5f3c5a2c8fa Mon Sep 17 00:00:00 2001 From: mikutas <23391543+mikutas@users.noreply.github.com> Date: Wed, 15 Dec 2021 09:41:45 +0900 Subject: [PATCH 4/5] Add unit test --- test/unit/server-statefulset.bats | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unit/server-statefulset.bats b/test/unit/server-statefulset.bats index eb6f7520d..65d6d9688 100755 --- a/test/unit/server-statefulset.bats +++ b/test/unit/server-statefulset.bats @@ -1396,6 +1396,16 @@ load _helpers [[ "${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" { From 7b6c41089fc3a4ad431da5b2b9969ccd709a926e Mon Sep 17 00:00:00 2001 From: Theron Voran Date: Tue, 14 Dec 2021 17:10:01 -0900 Subject: [PATCH 5/5] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aa14de9c..889aeaaf7 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)