From ff254f1aada3067d9cda61106ed1b85eee720484 Mon Sep 17 00:00:00 2001 From: Susanta Gautam Date: Wed, 24 Mar 2021 19:10:51 +0545 Subject: [PATCH] Added post-install and post-upgrade hook on jobs in designate chart Chart upgrading was failing due to some immutable fields are needed to upgrade before the jobs can be upgraded. For solving this issue, we have added the helm.sh/hook annotations with post-install and post-upgrade values. As for hook-weight annotations, we have added these to control the flow of the jobs with hook creation as the jobs are dependent. Like, db-init jobs need to run before db-sync and so on. Change-Id: Idca6ee2422769ccb5c8a87812b4fb564b283d44b --- designate/Chart.yaml | 2 +- designate/templates/job-db-init.yaml | 8 +++++++- designate/templates/job-db-sync.yaml | 8 +++++++- designate/templates/job-ks-endpoints.yaml | 8 +++++++- designate/templates/job-ks-service.yaml | 8 +++++++- designate/templates/job-ks-user.yaml | 8 +++++++- designate/templates/job-rabbit-init.yaml | 8 +++++++- designate/templates/pdb-api.yaml | 2 +- releasenotes/notes/designate.yaml | 1 + 9 files changed, 45 insertions(+), 8 deletions(-) diff --git a/designate/Chart.yaml b/designate/Chart.yaml index 4fe6326a36..32a5e6ea15 100644 --- a/designate/Chart.yaml +++ b/designate/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Designate name: designate -version: 0.1.1 +version: 0.1.2 home: https://docs.openstack.org/designate/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Designate/OpenStack_Project_Designate_vertical.jpg sources: diff --git a/designate/templates/job-db-init.yaml b/designate/templates/job-db-init.yaml index 3d93727948..1030d86164 100644 --- a/designate/templates/job-db-init.yaml +++ b/designate/templates/job-db-init.yaml @@ -9,9 +9,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +{{- define "metadata.annotations.job.db_init" }} +helm.sh/hook: post-install,post-upgrade +helm.sh/hook-weight: "-5" +{{- end }} + {{- if .Values.manifests.job_db_init }} -{{- $dbInitJob := dict "envAll" . "serviceName" "designate" -}} +{{- $dbInitJob := dict "envAll" . "serviceName" "designate" "jobAnnotations" (include "metadata.annotations.job.db_init" . | fromYaml) -}} {{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/designate/templates/job-db-sync.yaml b/designate/templates/job-db-sync.yaml index 7feaf1efb9..77651143d8 100644 --- a/designate/templates/job-db-sync.yaml +++ b/designate/templates/job-db-sync.yaml @@ -9,9 +9,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +{{- define "metadata.annotations.job.db_sync" }} +helm.sh/hook: post-install,post-upgrade +helm.sh/hook-weight: "-4" +{{- end }} + {{- if .Values.manifests.job_db_sync }} -{{- $dbSyncJob := dict "envAll" . "serviceName" "designate" "podVolMounts" .Values.pod.mounts.designate_db_sync.designate_db_sync.volumeMounts "podVols" .Values.pod.mounts.designate_db_sync.designate_db_sync.volumes -}} +{{- $dbSyncJob := dict "envAll" . "serviceName" "designate" "podVolMounts" .Values.pod.mounts.designate_db_sync.designate_db_sync.volumeMounts "podVols" .Values.pod.mounts.designate_db_sync.designate_db_sync.volumes "jobAnnotations" (include "metadata.annotations.job.db_sync" . | fromYaml) -}} {{ $dbSyncJob | include "helm-toolkit.manifests.job_db_sync" }} {{- end }} diff --git a/designate/templates/job-ks-endpoints.yaml b/designate/templates/job-ks-endpoints.yaml index cc0510ab14..b1f3c1f9e1 100644 --- a/designate/templates/job-ks-endpoints.yaml +++ b/designate/templates/job-ks-endpoints.yaml @@ -9,9 +9,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +{{- define "metadata.annotations.job.ks_endpoints" }} +helm.sh/hook: post-install,post-upgrade +helm.sh/hook-weight: "-2" +{{- end }} + {{- if .Values.manifests.job_ks_endpoints }} -{{- $ksServiceJob := dict "envAll" . "serviceName" "designate" "serviceTypes" ( tuple "dns" ) -}} +{{- $ksServiceJob := dict "envAll" . "serviceName" "designate" "serviceTypes" ( tuple "dns" ) "jobAnnotations" (include "metadata.annotations.job.ks_endpoints" . | fromYaml) -}} {{ $ksServiceJob | include "helm-toolkit.manifests.job_ks_endpoints" }} {{- end }} diff --git a/designate/templates/job-ks-service.yaml b/designate/templates/job-ks-service.yaml index c3e3e4d2ed..b7fc4b5ae2 100644 --- a/designate/templates/job-ks-service.yaml +++ b/designate/templates/job-ks-service.yaml @@ -9,9 +9,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +{{- define "metadata.annotations.job.ks_service" }} +helm.sh/hook: post-install,post-upgrade +helm.sh/hook-weight: "-3" +{{- end }} + {{- if .Values.manifests.job_ks_service }} -{{- $ksServiceJob := dict "envAll" . "serviceName" "designate" "serviceTypes" ( tuple "dns" ) -}} +{{- $ksServiceJob := dict "envAll" . "serviceName" "designate" "serviceTypes" ( tuple "dns" ) "jobAnnotations" (include "metadata.annotations.job.ks_service" . | fromYaml) -}} {{ $ksServiceJob | include "helm-toolkit.manifests.job_ks_service" }} {{- end }} diff --git a/designate/templates/job-ks-user.yaml b/designate/templates/job-ks-user.yaml index e993b5e8b2..081f0133ca 100644 --- a/designate/templates/job-ks-user.yaml +++ b/designate/templates/job-ks-user.yaml @@ -11,9 +11,15 @@ # limitations under the License. # $% What does following represent? + +{{- define "metadata.annotations.job.ks_user" }} +helm.sh/hook: post-install,post-upgrade +helm.sh/hook-weight: "-1" +{{- end }} + {{- if .Values.manifests.job_ks_user }} -{{- $ksUserJob := dict "envAll" . "serviceName" "designate" -}} +{{- $ksUserJob := dict "envAll" . "serviceName" "designate" "jobAnnotations" (include "metadata.annotations.job.ks_user" . | fromYaml) -}} {{ $ksUserJob | include "helm-toolkit.manifests.job_ks_user" }} {{- end }} diff --git a/designate/templates/job-rabbit-init.yaml b/designate/templates/job-rabbit-init.yaml index 2d662d003a..fc6e707866 100644 --- a/designate/templates/job-rabbit-init.yaml +++ b/designate/templates/job-rabbit-init.yaml @@ -11,7 +11,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */}} + +{{- define "metadata.annotations.job.rabbit_init" }} +helm.sh/hook: post-install,post-upgrade +helm.sh/hook-weight: "-4" +{{- end }} + {{- if .Values.manifests.job_rabbit_init }} -{{- $rmqUserJob := dict "envAll" . "serviceName" "designate" -}} +{{- $rmqUserJob := dict "envAll" . "serviceName" "designate" "jobAnnotations" (include "metadata.annotations.job.rabbit_init" . | fromYaml) -}} {{ $rmqUserJob | include "helm-toolkit.manifests.job_rabbit_init" }} {{- end }} diff --git a/designate/templates/pdb-api.yaml b/designate/templates/pdb-api.yaml index bb07d3741e..498f763b3b 100644 --- a/designate/templates/pdb-api.yaml +++ b/designate/templates/pdb-api.yaml @@ -21,6 +21,6 @@ spec: minAvailable: {{ .Values.pod.lifecycle.disruption_budget.api.min_available }} selector: matchLabels: - app: + app: designate-api {{ tuple $envAll "designate" "api" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }} {{- end }} diff --git a/releasenotes/notes/designate.yaml b/releasenotes/notes/designate.yaml index d0c1b53ff8..0b3672a4a5 100644 --- a/releasenotes/notes/designate.yaml +++ b/releasenotes/notes/designate.yaml @@ -2,3 +2,4 @@ designate: - 0.1.0 Initial Chart - 0.1.1 Change helm-toolkit dependency version to ">= 0.1.0" + - 0.1.2 Added post-install and post-upgrade helm hooks on Jobs