From bab4f8827e8ac3a43fc1e444007f9bf7f6b0a1e5 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Fri, 20 May 2022 09:17:23 -0400 Subject: [PATCH] Introduced helm hooks for senlin jobs Chart upgrade fails when there is changes in config as jobs fields are immutable. Having hooks in jobs forces them to be recreated at every upgrade which will solve the immutable fields error in jobs Change-Id: I05c91fb59355789a2de4295c69b18d01761996e7 --- releasenotes/notes/senlin.yaml | 1 + senlin/Chart.yaml | 2 +- senlin/templates/job-db-init.yaml | 8 ++++++++ senlin/templates/job-db-sync.yaml | 8 ++++++++ senlin/templates/job-image-repo-sync.yaml | 7 +++++++ senlin/templates/job-ks-endpoints.yaml | 8 ++++++++ senlin/templates/job-ks-service.yaml | 8 ++++++++ senlin/templates/job-ks-user.yaml | 8 ++++++++ senlin/templates/job-rabbit-init.yaml | 9 +++++++++ senlin/values.yaml | 2 ++ 10 files changed, 60 insertions(+), 1 deletion(-) diff --git a/releasenotes/notes/senlin.yaml b/releasenotes/notes/senlin.yaml index b6c87649a1..50472a45e9 100644 --- a/releasenotes/notes/senlin.yaml +++ b/releasenotes/notes/senlin.yaml @@ -8,4 +8,5 @@ senlin: - 0.2.3 Add conductor & health manager - 0.2.4 Update default image release - 0.2.5 Migrated CronJob resource to batch/v1 API version & PodDisruptionBudget to policy/v1 + - 0.2.6 Add helm.sh/hook annotations for Jobs ... diff --git a/senlin/Chart.yaml b/senlin/Chart.yaml index 7ea668689a..2ef42fc85a 100644 --- a/senlin/Chart.yaml +++ b/senlin/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Senlin name: senlin -version: 0.2.5 +version: 0.2.6 home: https://docs.openstack.org/senlin/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Senlin/OpenStack_Project_Senlin_vertical.png sources: diff --git a/senlin/templates/job-db-init.yaml b/senlin/templates/job-db-init.yaml index c953818c57..47822ad0b3 100644 --- a/senlin/templates/job-db-init.yaml +++ b/senlin/templates/job-db-init.yaml @@ -12,7 +12,15 @@ 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" "senlin" -}} +{{- if .Values.helm3_hook }} +{{- $_ := set $dbInitJob "jobAnnotations" (include "metadata.annotations.job.db_init" . | fromYaml) }} +{{- end }} {{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/senlin/templates/job-db-sync.yaml b/senlin/templates/job-db-sync.yaml index f00664e4ed..7e5f0bad23 100644 --- a/senlin/templates/job-db-sync.yaml +++ b/senlin/templates/job-db-sync.yaml @@ -12,7 +12,15 @@ 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" "senlin" "podVolMounts" .Values.pod.mounts.senlin_db_sync.senlin_db_sync.volumeMounts "podVols" .Values.pod.mounts.senlin_db_sync.senlin_db_sync.volumes -}} +{{- if .Values.helm3_hook }} +{{- $_ := set $dbSyncJob "jobAnnotations" (include "metadata.annotations.job.db_sync" . | fromYaml) }} +{{- end }} {{ $dbSyncJob | include "helm-toolkit.manifests.job_db_sync" }} {{- end }} diff --git a/senlin/templates/job-image-repo-sync.yaml b/senlin/templates/job-image-repo-sync.yaml index 8937839837..d5b87b111e 100644 --- a/senlin/templates/job-image-repo-sync.yaml +++ b/senlin/templates/job-image-repo-sync.yaml @@ -12,7 +12,14 @@ See the License for the specific language governing permissions and limitations under the License. */}} +{{- define "metadata.annotations.job.repo_sync" }} +helm.sh/hook: post-install,post-upgrade +{{- end }} + {{- if and .Values.manifests.job_image_repo_sync .Values.images.local_registry.active }} {{- $imageRepoSyncJob := dict "envAll" . "serviceName" "senlin" -}} +{{- if .Values.helm3_hook }} +{{- $_ := $imageRepoSyncJob "jobAnnotations" (include "metadata.annotations.job.repo_sync" . | fromYaml) }} +{{- end }} {{ $imageRepoSyncJob | include "helm-toolkit.manifests.job_image_repo_sync" }} {{- end }} diff --git a/senlin/templates/job-ks-endpoints.yaml b/senlin/templates/job-ks-endpoints.yaml index 37318ed3fa..8c8b2e305e 100644 --- a/senlin/templates/job-ks-endpoints.yaml +++ b/senlin/templates/job-ks-endpoints.yaml @@ -12,7 +12,15 @@ 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" "senlin" "serviceTypes" ( tuple "clustering" ) -}} +{{- if .Values.helm3_hook }} +{{- $_ := set $ksServiceJob "jobAnnotations" (include "metadata.annotations.job.ks_endpoints" . | fromYaml) }} +{{- end }} {{ $ksServiceJob | include "helm-toolkit.manifests.job_ks_endpoints" }} {{- end }} diff --git a/senlin/templates/job-ks-service.yaml b/senlin/templates/job-ks-service.yaml index 4467f7ae0d..0012d883b7 100644 --- a/senlin/templates/job-ks-service.yaml +++ b/senlin/templates/job-ks-service.yaml @@ -12,7 +12,15 @@ 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" "senlin" "serviceTypes" ( tuple "clustering" ) -}} +{{- if .Values.helm3_hook }} +{{- $_ := set $ksServiceJob "jobAnnotations" (include "metadata.annotations.job.ks_service" . | fromYaml) }} +{{- end }} {{ $ksServiceJob | include "helm-toolkit.manifests.job_ks_service" }} {{- end }} diff --git a/senlin/templates/job-ks-user.yaml b/senlin/templates/job-ks-user.yaml index e504285a10..aa86dc11ee 100644 --- a/senlin/templates/job-ks-user.yaml +++ b/senlin/templates/job-ks-user.yaml @@ -12,7 +12,15 @@ See the License for the specific language governing permissions and limitations under the License. */}} +{{- 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" "senlin" -}} +{{- if .Values.helm3_hook }} +{{- $_ := set $ksUserJob "jobAnnotations" (include "metadata.annotations.job.ks_user" . | fromYaml) }} +{{- end }} {{ $ksUserJob | include "helm-toolkit.manifests.job_ks_user" }} {{- end }} diff --git a/senlin/templates/job-rabbit-init.yaml b/senlin/templates/job-rabbit-init.yaml index 60fc32543c..eca7f03c5d 100644 --- a/senlin/templates/job-rabbit-init.yaml +++ b/senlin/templates/job-rabbit-init.yaml @@ -11,7 +11,16 @@ 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" "senlin" -}} +{{- if .Values.helm3_hook }} +{{- $_ := set $rmqUserJob "jobAnnotations" (include "metadata.annotations.job.rabbit_init" . | fromYaml) }} +{{- end }} {{ $rmqUserJob | include "helm-toolkit.manifests.job_rabbit_init" }} {{- end }} diff --git a/senlin/values.yaml b/senlin/values.yaml index 13cc4e8d1e..b245bd32a2 100644 --- a/senlin/values.yaml +++ b/senlin/values.yaml @@ -718,6 +718,8 @@ network_policy: egress: - {} +helm3_hook: true + manifests: configmap_bin: true configmap_etc: true