From b4e2a85b49cac1102b570fef8f0f5cac39058a23 Mon Sep 17 00:00:00 2001 From: Susanta Gautam Date: Tue, 16 Mar 2021 16:42:57 +0545 Subject: [PATCH] Add helm.sh/hook related annotation for neutron Chart upgrading was failing due to some immutable fields in job are needed to upgrade. So, we thought using the post-install and post-upgrade helm hook for job to force the job resource to execute after all resources are created. And as some jobs are dependent on each other i.e. some jobs needs to run in order for helm hook to be successful. For that we used hook-weight to control resource creation order. Change-Id: I26881324d101a986b7367d4682e9adcd07a24b13 --- neutron/Chart.yaml | 2 +- neutron/templates/job-bootstrap.yaml | 7 ++++++- neutron/templates/job-db-init.yaml | 7 ++++++- neutron/templates/job-db-sync.yaml | 7 ++++++- neutron/templates/job-image-repo-sync.yaml | 6 +++++- neutron/templates/job-ks-endpoints.yaml | 7 ++++++- neutron/templates/job-ks-service.yaml | 7 ++++++- neutron/templates/job-ks-user.yaml | 7 ++++++- neutron/templates/job-rabbit-init.yaml | 8 +++++++- releasenotes/notes/neutron.yaml | 1 + 10 files changed, 50 insertions(+), 9 deletions(-) diff --git a/neutron/Chart.yaml b/neutron/Chart.yaml index 33ce880f..85677361 100644 --- a/neutron/Chart.yaml +++ b/neutron/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Neutron name: neutron -version: 0.1.10 +version: 0.1.11 home: https://docs.openstack.org/neutron/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Neutron/OpenStack_Project_Neutron_vertical.png sources: diff --git a/neutron/templates/job-bootstrap.yaml b/neutron/templates/job-bootstrap.yaml index d3edb310..4312aaaf 100644 --- a/neutron/templates/job-bootstrap.yaml +++ b/neutron/templates/job-bootstrap.yaml @@ -12,8 +12,13 @@ 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" "neutron" "keystoneUser" .Values.bootstrap.ks_user "logConfigFile" .Values.conf.neutron.DEFAULT.log_config_append -}} +{{- $bootstrapJob := dict "envAll" . "serviceName" "neutron" "keystoneUser" .Values.bootstrap.ks_user "logConfigFile" .Values.conf.neutron.DEFAULT.log_config_append "jobAnnotations" (include "metadata.annotations.job.bootstrap" . | fromYaml) -}} {{- if .Values.manifests.certificates -}} {{- $_ := set $bootstrapJob "tlsSecret" .Values.secrets.tls.network.server.internal -}} {{- end -}} diff --git a/neutron/templates/job-db-init.yaml b/neutron/templates/job-db-init.yaml index d8185861..1a74a535 100644 --- a/neutron/templates/job-db-init.yaml +++ b/neutron/templates/job-db-init.yaml @@ -12,8 +12,13 @@ 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" "neutron" -}} +{{- $dbInitJob := dict "envAll" . "serviceName" "neutron" "jobAnnotations" (include "metadata.annotations.job.db_init" . | fromYaml) -}} {{- if .Values.manifests.certificates -}} {{- $_ := set $dbInitJob "dbAdminTlsSecret" .Values.endpoints.oslo_db.auth.admin.secret.tls.internal -}} {{- end -}} diff --git a/neutron/templates/job-db-sync.yaml b/neutron/templates/job-db-sync.yaml index de5dad7b..95a941a3 100644 --- a/neutron/templates/job-db-sync.yaml +++ b/neutron/templates/job-db-sync.yaml @@ -12,8 +12,13 @@ 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" "neutron" "podVolMounts" .Values.pod.mounts.neutron_db_sync.neutron_db_sync.volumeMounts "podVols" .Values.pod.mounts.neutron_db_sync.neutron_db_sync.volumes -}} +{{- $dbSyncJob := dict "envAll" . "serviceName" "neutron" "podVolMounts" .Values.pod.mounts.neutron_db_sync.neutron_db_sync.volumeMounts "podVols" .Values.pod.mounts.neutron_db_sync.neutron_db_sync.volumes "jobAnnotations" (include "metadata.annotations.job.db_sync" . | fromYaml) -}} {{- if .Values.manifests.certificates -}} {{- $_ := set $dbSyncJob "dbAdminTlsSecret" .Values.endpoints.oslo_db.auth.admin.secret.tls.internal -}} {{- end -}} diff --git a/neutron/templates/job-image-repo-sync.yaml b/neutron/templates/job-image-repo-sync.yaml index a34d4b94..d534171c 100644 --- a/neutron/templates/job-image-repo-sync.yaml +++ b/neutron/templates/job-image-repo-sync.yaml @@ -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" "neutron" -}} +{{- $imageRepoSyncJob := dict "envAll" . "serviceName" "neutron" "jobAnnotations" (include "metadata.annotations.job.repo_sync" . | fromYaml) -}} {{ $imageRepoSyncJob | include "helm-toolkit.manifests.job_image_repo_sync" }} {{- end }} diff --git a/neutron/templates/job-ks-endpoints.yaml b/neutron/templates/job-ks-endpoints.yaml index d045dec3..380c9eeb 100644 --- a/neutron/templates/job-ks-endpoints.yaml +++ b/neutron/templates/job-ks-endpoints.yaml @@ -12,8 +12,13 @@ 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" "neutron" "serviceTypes" ( tuple "network" ) -}} +{{- $ksServiceJob := dict "envAll" . "serviceName" "neutron" "serviceTypes" ( tuple "network" ) "jobAnnotations" (include "metadata.annotations.job.ks_endpoints" . | fromYaml) -}} {{- if .Values.manifests.certificates -}} {{- $_ := set $ksServiceJob "tlsSecret" .Values.secrets.tls.network.server.internal -}} {{- end -}} diff --git a/neutron/templates/job-ks-service.yaml b/neutron/templates/job-ks-service.yaml index 9e9d5376..f8c12d2e 100644 --- a/neutron/templates/job-ks-service.yaml +++ b/neutron/templates/job-ks-service.yaml @@ -12,8 +12,13 @@ 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" "neutron" "serviceTypes" ( tuple "network" ) -}} +{{- $ksServiceJob := dict "envAll" . "serviceName" "neutron" "serviceTypes" ( tuple "network" ) "jobAnnotations" (include "metadata.annotations.job.ks_service" . | fromYaml) -}} {{- if .Values.manifests.certificates -}} {{- $_ := set $ksServiceJob "tlsSecret" .Values.secrets.tls.network.server.internal -}} {{- end -}} diff --git a/neutron/templates/job-ks-user.yaml b/neutron/templates/job-ks-user.yaml index 6976ad9f..7fab81d0 100644 --- a/neutron/templates/job-ks-user.yaml +++ b/neutron/templates/job-ks-user.yaml @@ -12,8 +12,13 @@ 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" "neutron" -}} +{{- $ksUserJob := dict "envAll" . "serviceName" "neutron" "jobAnnotations" (include "metadata.annotations.job.ks_user" . | fromYaml) -}} {{- if .Values.manifests.certificates -}} {{- $_ := set $ksUserJob "tlsSecret" .Values.secrets.tls.network.server.internal -}} {{- end -}} diff --git a/neutron/templates/job-rabbit-init.yaml b/neutron/templates/job-rabbit-init.yaml index f456ffa5..a35b2fca 100644 --- a/neutron/templates/job-rabbit-init.yaml +++ b/neutron/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" "neutron" -}} +{{- $rmqUserJob := dict "envAll" . "serviceName" "neutron" "jobAnnotations" (include "metadata.annotations.job.rabbit_init" . | fromYaml) -}} {{ $rmqUserJob | include "helm-toolkit.manifests.job_rabbit_init" }} {{- end }} diff --git a/releasenotes/notes/neutron.yaml b/releasenotes/notes/neutron.yaml index 9e7ae7d2..9e8e122a 100644 --- a/releasenotes/notes/neutron.yaml +++ b/releasenotes/notes/neutron.yaml @@ -11,3 +11,4 @@ neutron: - 0.1.8 Revert Change Issuer to ClusterIssuer - 0.1.9 Update ovs agent to support host/label overrides - 0.1.10 Change Issuer to ClusterIssuer + - 0.1.11 Added the helm.sh/hook, helm.sh/hook-weight annotations