From 467b81a3e4624b1a04c5b8c019cb0104a72c6428 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Wed, 24 Jul 2019 12:01:26 -0500 Subject: [PATCH] Nova: Update DB sync job to update transport url If the transport url changes, cell needs to be updated to use new transport. Change-Id: I1a931b5ce272a731be710c43f3fea08abc79af71 Signed-off-by: Pete Birley --- nova/templates/bin/_db-sync.sh.tpl | 15 ++++++++++++++- nova/templates/job-db-sync.yaml | 13 ++++++++++++- nova/templates/secret_rabbitmq.yaml | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/nova/templates/bin/_db-sync.sh.tpl b/nova/templates/bin/_db-sync.sh.tpl index c44666574a..60213c6c21 100644 --- a/nova/templates/bin/_db-sync.sh.tpl +++ b/nova/templates/bin/_db-sync.sh.tpl @@ -17,7 +17,6 @@ limitations under the License. */}} set -ex - NOVA_VERSION=$(nova-manage --version 2>&1) function manage_cells () { @@ -27,6 +26,20 @@ function manage_cells () { nova-manage cell_v2 map_cell0 nova-manage cell_v2 list_cells | grep -q " cell1 " || \ nova-manage cell_v2 create_cell --name=cell1 --verbose + + # NOTE: We do this to allow the transport url to be updated. + CELL1_ID=$(nova-manage cell_v2 list_cells | awk -F '|' '/ cell1 / { print $3 }' | tr -d ' ') + set +x + if [ -z "${TRANSPORT_URL}" ]; then + echo "Error: Transport URL is not set, exiting." + exit 1 + else + nova-manage cell_v2 update_cell \ + --cell_uuid="${CELL1_ID}" \ + --name="cell1" \ + --transport-url="${TRANSPORT_URL}" + fi + set -x fi } diff --git a/nova/templates/job-db-sync.yaml b/nova/templates/job-db-sync.yaml index e88778a55d..5bad61a45b 100644 --- a/nova/templates/job-db-sync.yaml +++ b/nova/templates/job-db-sync.yaml @@ -14,7 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. */}} +{{- define "nova.templates._job_db_sync.env_vars" -}} +{{- $envAll := index . 0 }} +env: + - name: TRANSPORT_URL + valueFrom: + secretKeyRef: + name: {{ $envAll.Values.secrets.oslo_messaging.nova }} + key: TRANSPORT_URL +{{- end }} + {{- if .Values.manifests.job_db_sync }} -{{- $dbSyncJob := dict "envAll" . "serviceName" "nova" "podVolMounts" .Values.pod.mounts.nova_db_sync.nova_db_sync.volumeMounts "podVols" .Values.pod.mounts.nova_db_sync.nova_db_sync.volumes -}} +{{- $podEnvVars := include "nova.templates._job_db_sync.env_vars" (tuple .) | toString | fromYaml }} +{{- $dbSyncJob := dict "envAll" . "serviceName" "nova" "podVolMounts" .Values.pod.mounts.nova_db_sync.nova_db_sync.volumeMounts "podVols" .Values.pod.mounts.nova_db_sync.nova_db_sync.volumes "podEnvVars" $podEnvVars.env -}} {{ $dbSyncJob | include "helm-toolkit.manifests.job_db_sync" }} {{- end }} diff --git a/nova/templates/secret_rabbitmq.yaml b/nova/templates/secret_rabbitmq.yaml index 623b6779f2..a90df90f58 100644 --- a/nova/templates/secret_rabbitmq.yaml +++ b/nova/templates/secret_rabbitmq.yaml @@ -26,5 +26,6 @@ metadata: type: Opaque data: RABBITMQ_CONNECTION: {{ tuple "oslo_messaging" "internal" $userClass "http" $envAll | include "helm-toolkit.endpoints.authenticated_endpoint_uri_lookup" | b64enc }} + TRANSPORT_URL: {{ tuple "oslo_messaging" "internal" $userClass "amqp" $envAll | include "helm-toolkit.endpoints.authenticated_endpoint_uri_lookup" | b64enc }} {{- end }} {{- end }}