From 29e0998e732547c474f72f0ef9c660d565e22f1e Mon Sep 17 00:00:00 2001 From: Serguei Bezverkhi Date: Thu, 1 Jun 2017 13:59:02 -0400 Subject: [PATCH] Adding extra condition for simple cell0 create job Adding extra condition for simple cell0 create job, nova api will be checked to confirm there is at least one compute in UP state. Change-Id: Ic788397b114828ac5c36b7d6c0e4d6cc9ac71a56 --- helm/all_values.yaml | 10 +++ .../templates/nova-api-create-cell.yaml | 81 +++++++++++++++++++ helm/service/nova-compute/values.yaml | 2 - tests/bin/common_workflow_config.sh | 1 + tests/bin/deploy_iscsi_common.sh | 2 +- 5 files changed, 93 insertions(+), 3 deletions(-) diff --git a/helm/all_values.yaml b/helm/all_values.yaml index 72c4e9c76..ec737ff17 100755 --- a/helm/all_values.yaml +++ b/helm/all_values.yaml @@ -466,6 +466,16 @@ nova-api-delete-db-job: database_name: "nova_api" database_user: "nova_api" +nova-api-create-simple-cell-job: + global: + kolla: + nova: + api: + create_cell: + all: + cell_wait_compute: true + cell_wait_compute_sleep: 5 + nova-cell0-create-db-job: global: kolla: diff --git a/helm/microservice/nova-api-create-simple-cell-job/templates/nova-api-create-cell.yaml b/helm/microservice/nova-api-create-simple-cell-job/templates/nova-api-create-cell.yaml index fb87a8a39..5c22cc448 100644 --- a/helm/microservice/nova-api-create-simple-cell-job/templates/nova-api-create-cell.yaml +++ b/helm/microservice/nova-api-create-simple-cell-job/templates/nova-api-create-cell.yaml @@ -11,6 +11,19 @@ {{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" $searchPath "Values" .Values ) }} {{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" $searchPath "Values" .Values ) }} {{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" $searchPath "Values" .Values ) }} +{{- $keystoneSearchPath := ":global.kolla.keystone.all:global.kolla.all" }} +{{- $keystonePort := include "kolla_val_get_str" (dict "key" "port" "searchPath" $keystoneSearchPath "Values" .Values ) }} +{{- $elementName := include "kolla_val_get_str" (dict "key" "element_name" "searchPath" $keystoneSearchPath "Values" .Values ) | default "keystone" }} +{{- $keystoneURL := printf "%s-internal" $elementName }} +{{- $localVals := dict }} +{{- $c1 := dict "key" "cell_wait_compute" "searchPath" $searchPath "Values" .Values }} +{{- $_ := set $c1 "retDict" $localVals }} +{{- $_ := set $c1 "retKey" "cell_wait_compute" }} +{{- $_ := include "kolla_val_get_raw" $c1 }} +{{- $c2 := dict "key" "cell_wait_compute_sleep" "searchPath" $searchPath "Values" .Values }} +{{- $_ := set $c2 "retDict" $localVals }} +{{- $_ := set $c2 "retKey" "cell_wait_compute_sleep" }} +{{- $_ := include "kolla_val_get_raw" $c2 }} {{- with $env := dict "resourceName" $resourceName "serviceName" $serviceName "podTypeBootstrap" $podTypeBootstrap "imageFull" $imageFull "Values" .Values "Release" .Release "searchPath" $searchPath }} apiVersion: batch/v1 kind: Job @@ -21,6 +34,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ +{{- include "common_dependency_container_multi" $env | indent 10 }} { "name": "initialize-cell-api-logs", "image": "{{ $imageFull }}", @@ -37,7 +51,74 @@ spec: "mountPath": "/var/log/kolla" } ] + }{{- if $localVals.cell_wait_compute }}, + { + "name": "wait-for-nova-compute-up", + "image": {{ include "kolla_toolbox_image_full" . | quote }}, + "imagePullPolicy": "{{ $imagePullPolicy }}", + "env": [ + { + "name": "OS_PASSWORD", + "valueFrom": + { + "secretKeyRef": + { + "name": "keystone-admin-password", + "key": "password" + } + } + }, + { + "name": "OS_AUTH_URL", + "value": "http://{{ $keystoneURL }}:{{ $keystonePort }}/v3" + }, + { + "name": "OS_PROJECT_NAME", + "value": "admin" + }, + { + "name": "OS_USER_DOMAIN_NAME", + "value": "Default" + }, + { + "name": "OS_USERNAME", + "value": "admin" + }, + { + "name": "OS_PROJECT_DOMAIN_NAME", + "value": "Default" + }, + { + "name": "OS_IDENTITY_API_VERSION", + "value": "3" + }, + { + "name": "OS_REGION_NAME", + "value": "RegionOne" + } + ], + "command": [ + "sh", + "-ce", + "touch /tmp/not_found; + while [[ -f /tmp/not_found ]]; do + openstack hypervisor list -f value -c State | while read compute_state; do + if [ ''x''$compute_state == ''xup'' ]; then + echo ''Detected at least one compute node in UP state. Exiting...''; + rm -f /tmp/not_found; + fi; + done; + sleep {{ $localVals.cell_wait_compute_sleep }}; + done; + "], + "volumeMounts": [ + { + "name": "kolla-logs", + "mountPath": "/var/log/kolla" + } + ] } +{{- end }} ]' spec: nodeSelector: diff --git a/helm/service/nova-compute/values.yaml b/helm/service/nova-compute/values.yaml index f8dd22862..6bd579c46 100644 --- a/helm/service/nova-compute/values.yaml +++ b/helm/service/nova-compute/values.yaml @@ -12,8 +12,6 @@ global: service: - nova-metadata - nova-api - socket: - - /var/run/libvirt/libvirt-sock compute: daemonset: dependencies: diff --git a/tests/bin/common_workflow_config.sh b/tests/bin/common_workflow_config.sh index abfcf86f6..84e5eb463 100755 --- a/tests/bin/common_workflow_config.sh +++ b/tests/bin/common_workflow_config.sh @@ -12,6 +12,7 @@ function common_workflow_config { echo " all:" echo " admin_port_external: true" echo " dns_name: $IP" + echo " port: 5000" echo " public:" echo " all:" echo " port_external: true" diff --git a/tests/bin/deploy_iscsi_common.sh b/tests/bin/deploy_iscsi_common.sh index 1e8f823dc..73144c26b 100755 --- a/tests/bin/deploy_iscsi_common.sh +++ b/tests/bin/deploy_iscsi_common.sh @@ -531,7 +531,7 @@ $DIR/tools/build_local_admin_keystonerc.sh wait_for_openstack if [ "x$branch" != "x2" -a "x$branch" != "x3" ]; then -helm install kolla/nova-cell0-create-db-job --debug --version $VERSION \ +helm install kolla/nova-cell0-create-db-job --version $VERSION \ --namespace kolla --name nova-cell0-create-db-job \ --values /tmp/general_config.yaml --values /tmp/iscsi_config.yaml