From 19ade859c21e6cef7f1d14e4502f8f0c913ab415 Mon Sep 17 00:00:00 2001 From: Oleh Hryhorov Date: Thu, 13 Aug 2020 10:17:32 +0300 Subject: [PATCH] Un-hardcode restartPolicy for ks-* jobs The patch makes it possible to pass restartPolicy for jobs which create different keystone resources. However default behaviour is still the same and if restartPolicy is undefined then it will be OnFailure as it was before. Change-Id: I0e355cfd6947db72f77d76a0f6696e9bcef175e9 --- helm-toolkit/templates/manifests/_job-ks-endpoints.tpl | 9 ++++++++- helm-toolkit/templates/manifests/_job-ks-service.tpl | 9 ++++++++- helm-toolkit/templates/manifests/_job-ks-user.yaml.tpl | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/helm-toolkit/templates/manifests/_job-ks-endpoints.tpl b/helm-toolkit/templates/manifests/_job-ks-endpoints.tpl index a497af11f..a32ffd2fd 100644 --- a/helm-toolkit/templates/manifests/_job-ks-endpoints.tpl +++ b/helm-toolkit/templates/manifests/_job-ks-endpoints.tpl @@ -28,6 +28,13 @@ limitations under the License. {{- $backoffLimit := index . "backoffLimit" | default "1000" -}} {{- $activeDeadlineSeconds := index . "activeDeadlineSeconds" -}} {{- $serviceNamePretty := $serviceName | replace "_" "-" -}} +{{- $restartPolicy_ := "OnFailure" -}} +{{- if hasKey $envAll.Values "jobs" -}} +{{- if hasKey $envAll.Values.jobs "ks_endpoints" -}} +{{- $restartPolicy_ = $envAll.Values.jobs.ks_endpoints.restartPolicy | default $restartPolicy_ }} +{{- end }} +{{- end }} +{{- $restartPolicy := index . "restartPolicy" | default $restartPolicy_ -}} {{- $serviceAccountName := printf "%s-%s" $serviceNamePretty "ks-endpoints" }} {{ tuple $envAll "ks_endpoints" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} @@ -49,7 +56,7 @@ spec: {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }} spec: serviceAccountName: {{ $serviceAccountName }} - restartPolicy: OnFailure + restartPolicy: {{ $restartPolicy }} nodeSelector: {{ toYaml $nodeSelector | indent 8 }} initContainers: diff --git a/helm-toolkit/templates/manifests/_job-ks-service.tpl b/helm-toolkit/templates/manifests/_job-ks-service.tpl index daac49c17..e5a0cb69a 100644 --- a/helm-toolkit/templates/manifests/_job-ks-service.tpl +++ b/helm-toolkit/templates/manifests/_job-ks-service.tpl @@ -28,6 +28,13 @@ limitations under the License. {{- $backoffLimit := index . "backoffLimit" | default "1000" -}} {{- $activeDeadlineSeconds := index . "activeDeadlineSeconds" -}} {{- $serviceNamePretty := $serviceName | replace "_" "-" -}} +{{- $restartPolicy_ := "OnFailure" -}} +{{- if hasKey $envAll.Values "jobs" -}} +{{- if hasKey $envAll.Values.jobs "ks_service" -}} +{{- $restartPolicy_ = $envAll.Values.jobs.ks_service.restartPolicy | default $restartPolicy_ }} +{{- end }} +{{- end }} +{{- $restartPolicy := index . "restartPolicy" | default $restartPolicy_ -}} {{- $serviceAccountName := printf "%s-%s" $serviceNamePretty "ks-service" }} {{ tuple $envAll "ks_service" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} @@ -49,7 +56,7 @@ spec: {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }} spec: serviceAccountName: {{ $serviceAccountName }} - restartPolicy: OnFailure + restartPolicy: {{ $restartPolicy }} nodeSelector: {{ toYaml $nodeSelector | indent 8 }} initContainers: diff --git a/helm-toolkit/templates/manifests/_job-ks-user.yaml.tpl b/helm-toolkit/templates/manifests/_job-ks-user.yaml.tpl index 875247eca..b977b5a6b 100644 --- a/helm-toolkit/templates/manifests/_job-ks-user.yaml.tpl +++ b/helm-toolkit/templates/manifests/_job-ks-user.yaml.tpl @@ -28,6 +28,13 @@ limitations under the License. {{- $backoffLimit := index . "backoffLimit" | default "1000" -}} {{- $activeDeadlineSeconds := index . "activeDeadlineSeconds" -}} {{- $serviceUserPretty := $serviceUser | replace "_" "-" -}} +{{- $restartPolicy_ := "OnFailure" -}} +{{- if hasKey $envAll.Values "jobs" -}} +{{- if hasKey $envAll.Values.jobs "ks_user" -}} +{{- $restartPolicy_ = $envAll.Values.jobs.ks_user.restartPolicy | default $restartPolicy_ }} +{{- end }} +{{- end }} +{{- $restartPolicy := index . "restartPolicy" | default $restartPolicy_ -}} {{- $serviceAccountName := printf "%s-%s" $serviceUserPretty "ks-user" }} {{ tuple $envAll "ks_user" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} @@ -49,7 +56,7 @@ spec: {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }} spec: serviceAccountName: {{ $serviceAccountName | quote }} - restartPolicy: OnFailure + restartPolicy: {{ $restartPolicy }} nodeSelector: {{ toYaml $nodeSelector | indent 8 }} initContainers: