Added post-install and post-upgrade hook for jobs in mistral

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: Ia8eebf87a646aa0e25f89721ebda0e237dcf23af
This commit is contained in:
Susanta Gautam 2021-03-24 19:41:58 +05:45
parent ad97431545
commit 79eefa97a5
10 changed files with 49 additions and 9 deletions

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Mistral
name: mistral
version: 0.1.1
version: 0.1.2
home: https://docs.openstack.org/mistral/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Mistral/OpenStack_Project_Mistral_vertical.png
sources:

View File

@ -12,7 +12,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{- define "metadata.annotations.job.bootstrap" }}
helm.sh/hook: post-install,post-upgrade
helm.sh/hook-weight: "5"
{{- end }}
{{- if and .Values.manifests.job_bootstrap .Values.bootstrap.enabled }}
{{- $bootstrapJob := dict "envAll" . "serviceName" "mistral" "keystoneUser" .Values.bootstrap.ks_user "logConfigFile" .Values.conf.mistral.DEFAULT.log_config_append -}}
{{- $bootstrapJob := dict "envAll" . "serviceName" "mistral" "keystoneUser" .Values.bootstrap.ks_user "logConfigFile" .Values.conf.mistral.DEFAULT.log_config_append "jobAnnotations" (include "metadata.annotations.job.bootstrap" . | fromYaml) -}}
{{ $bootstrapJob | include "helm-toolkit.manifests.job_bootstrap" }}
{{- end }}

View File

@ -12,7 +12,12 @@ 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" "mistral" -}}
{{- $dbInitJob := dict "envAll" . "serviceName" "mistral" "jobAnnotations" (include "metadata.annotations.job.db_init" . | fromYaml) -}}
{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }}
{{- end }}

View File

@ -13,7 +13,12 @@ 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" "mistral" "podVolMounts" .Values.pod.mounts.mistral_db_sync.mistral_db_sync.volumeMounts "podVols" .Values.pod.mounts.mistral_db_sync.mistral_db_sync.volumes -}}
{{- $dbSyncJob := dict "envAll" . "serviceName" "mistral" "podVolMounts" .Values.pod.mounts.mistral_db_sync.mistral_db_sync.volumeMounts "podVols" .Values.pod.mounts.mistral_db_sync.mistral_db_sync.volumes "jobAnnotations" (include "metadata.annotations.job.db_sync" . | fromYaml) -}}
{{ $dbSyncJob | include "helm-toolkit.manifests.job_db_sync" }}
{{- end }}

View File

@ -12,7 +12,11 @@ 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" "mistral" -}}
{{- $imageRepoSyncJob := dict "envAll" . "serviceName" "mistral" "jobAnnotations" (include "metadata.annotations.job.repo_sync" . | fromYaml) -}}
{{ $imageRepoSyncJob | include "helm-toolkit.manifests.job_image_repo_sync" }}
{{- end }}

View File

@ -12,7 +12,12 @@ 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" "mistral" "serviceTypes" ( tuple "workflowv2" ) -}}
{{- $ksServiceJob := dict "envAll" . "serviceName" "mistral" "serviceTypes" ( tuple "workflowv2" ) "jobAnnotations" (include "metadata.annotations.job.ks_endpoints" . | fromYaml) -}}
{{ $ksServiceJob | include "helm-toolkit.manifests.job_ks_endpoints" }}
{{- end }}

View File

@ -12,7 +12,12 @@ 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" "mistral" "serviceTypes" ( tuple "workflowv2" ) -}}
{{- $ksServiceJob := dict "envAll" . "serviceName" "mistral" "serviceTypes" ( tuple "workflowv2" ) "jobAnnotations" (include "metadata.annotations.job.ks_service" . | fromYaml) -}}
{{ $ksServiceJob | include "helm-toolkit.manifests.job_ks_service" }}
{{- end }}

View File

@ -12,7 +12,12 @@ 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" "mistral" -}}
{{- $ksUserJob := dict "envAll" . "serviceName" "mistral" "jobAnnotations" (include "metadata.annotations.job.ks_user" . | fromYaml) -}}
{{ $ksUserJob | include "helm-toolkit.manifests.job_ks_user" }}
{{- end }}

View File

@ -12,7 +12,12 @@ 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" "mistral" -}}
{{- $rmqUserJob := dict "envAll" . "serviceName" "mistral" "jobAnnotations" (include "metadata.annotations.job.rabbit_init" . | fromYaml) -}}
{{ $rmqUserJob | include "helm-toolkit.manifests.job_rabbit_init" }}
{{- end }}

View File

@ -2,3 +2,4 @@
mistral:
- 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 hook for Jobs