diff --git a/helm/all_values.yaml b/helm/all_values.yaml index edec2e8bc..6bf999298 100755 --- a/helm/all_values.yaml +++ b/helm/all_values.yaml @@ -46,6 +46,7 @@ pod-http-termination: all: haproxy_python_termination: true haproxy_image_tag: 3.0.2 + grace_period_seconds: 172800 stateful-service: global: @@ -585,6 +586,14 @@ glance-create-db-job: database_name: "glance" database_user: "glance" +glance-delete-db-job: + global: + kolla: + glance: + all: + database_name: "glance" + database_user: "glance" + glance-manage-db-job: global: kolla: @@ -607,6 +616,18 @@ glance-create-keystone-user-job: all: keystone_user_name: glance +glance-delete-keystone-user-job: + global: + kolla: + all: + keystone_user_project: service + keystone_user_project_domain: Default + keystone_user_domain: Default + keystone_user_role: admin + glance: + all: + keystone_user_name: glance + glance-create-keystone-endpoint-public-job: global: kolla: diff --git a/helm/kolla-common/templates/_common_api_apache_deployment.yaml b/helm/kolla-common/templates/_common_api_apache_deployment.yaml index 4050c8b06..53bad7afa 100644 --- a/helm/kolla-common/templates/_common_api_apache_deployment.yaml +++ b/helm/kolla-common/templates/_common_api_apache_deployment.yaml @@ -6,6 +6,7 @@ {{- $replicas := include "kolla_val_get_str" (dict "key" "replicas" "searchPath" .searchPath "Values" .Values ) }} {{- $port := include "kolla_val_get_str" (dict "key" "port" "searchPath" .searchPath "Values" .Values ) }} {{- $adminPort := include "kolla_val_get_str" (dict "key" "admin_port" "searchPath" .searchPath "Values" .Values ) }} +{{- $gracePeriodSeconds := include "kolla_val_get_str" (dict "key" "grace_period_seconds" "searchPath" .searchPath "Values" .Values ) }} apiVersion: extensions/v1beta1 kind: Deployment metadata: @@ -29,7 +30,7 @@ spec: {{- end }} spec: #You've got 2 days to drain or figure out why it won't. - terminationGracePeriodSeconds: 172800 + terminationGracePeriodSeconds: {{ $gracePeriodSeconds }} nodeSelector: {{ $selectorKey }}: {{ $selectorValue | quote }} containers: diff --git a/helm/kolla-common/templates/_common_api_python_deployment.yaml b/helm/kolla-common/templates/_common_api_python_deployment.yaml index c1348304f..69e44ad05 100644 --- a/helm/kolla-common/templates/_common_api_python_deployment.yaml +++ b/helm/kolla-common/templates/_common_api_python_deployment.yaml @@ -7,6 +7,7 @@ {{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }} {{- $novaMetadataSearchPath := ":global.kolla.nova.metadata.deployment:global.kolla.nova.metadata.all:global.kolla.nova.all:global.kolla.all" }} {{- $novaMetadataPort := include "kolla_val_get_str" (dict "key" "port" "searchPath" $novaMetadataSearchPath "Values" .Values ) }} +{{- $gracePeriodSeconds := include "kolla_val_get_str" (dict "key" "grace_period_seconds" "searchPath" .searchPath "Values" .Values ) }} {{- $localVals := dict }} {{- $c := dict "searchPath" .searchPath "key" "haproxy_python_termination" "retDict" $localVals "retKey" "haproxy" "Values" .Values }} {{- include "kolla_val_get_raw" $c }} @@ -76,7 +77,7 @@ spec: ]' spec: #You've got 2 days to drain or figure out why it won't. - terminationGracePeriodSeconds: 172800 + terminationGracePeriodSeconds: {{ $gracePeriodSeconds }} nodeSelector: {{ $selectorKey }}: {{ $selectorValue | quote }} containers: diff --git a/helm/microservice/glance-api-deployment/templates/glance-api.yaml b/helm/microservice/glance-api-deployment/templates/glance-api.yaml index 0842685e9..3e45a44bb 100644 --- a/helm/microservice/glance-api-deployment/templates/glance-api.yaml +++ b/helm/microservice/glance-api-deployment/templates/glance-api.yaml @@ -16,6 +16,8 @@ {{- $_ := set $c1 "retDict" $localVals }} {{- $_ := set $c1 "retKey" "ceph_backend" }} {{- $_ := include "kolla_val_get_raw" $c1 }} +{{- $c := dict "searchPath" .searchPath "key" "haproxy_python_termination" "retDict" $localVals "retKey" "haproxy" "Values" .Values }} +{{- include "kolla_val_get_raw" $c }} {{- $resourceName := "glance-api" }} {{- $netHostTrue := false }} {{- $podTypeBootstrap := false }} @@ -26,7 +28,7 @@ {{- $portName := "glance-api" }} {{- $checkPath := "/healthcheck" }} {{- $privileged := false }} -{{- $gracePeriodSeconds := 172800 }} +{{- $gracePeriodSeconds := include "kolla_val_get_str" (dict "key" "grace_period_seconds" "searchPath" $searchPath "Values" .Values ) }} {{- with $env := dict "netHostTrue" $netHostTrue "podTypeBootstrap" $podTypeBootstrap "resourceName" $resourceName "Values" .Values "Release" .Release "searchPath" $searchPath }} apiVersion: extensions/v1beta1 kind: Deployment @@ -69,10 +71,12 @@ spec: cp -a /srv/ceph.conf /srv/pod-main-config/; cp -a /srv/ceph.client.glance.keyring /srv/pod-main-config/; {{- end }} +{{- if $localVals.haproxy }} CONF=/srv/pod-main-config/glance-api.conf; crudini --set $CONF DEFAULT bind_host 127.0.0.1; - crudini --set $CONF DEFAULT bind_port 8080;" - ], + crudini --set $CONF DEFAULT bind_port 8080; +{{- end }} + "], "volumeMounts": [ {{- if $localVals.ceph_backend }} { @@ -104,8 +108,11 @@ spec: nodeSelector: {{ $selectorKey }}: {{ $selectorValue | quote }} #You've got 2 days to drain or figure out why it won't. +{{- if $localVals.haproxy }} terminationGracePeriodSeconds: {{ $gracePeriodSeconds }} +{{- end }} containers: +{{- if $localVals.haproxy }} - name: haproxy image: {{ include "haproxy_image_full" . | quote }} command: @@ -143,8 +150,10 @@ spec: ports: - containerPort: {{ $port }} name: {{ $portName | trunc 15 | quote }} +{{- end }} - name: main image: "{{ $imageFull }}" +{{- if $localVals.haproxy }} lifecycle: preStop: exec: @@ -152,6 +161,7 @@ spec: - /bin/bash - -c - while true; do sleep 1; [ -f /var/lib/kolla-kubernetes/event/shutdown ] && break; done +{{- end }} volumeMounts: {{- include "common_volume_mounts" $env | indent 12 }} - mountPath: /var/lib/kolla-kubernetes/event @@ -173,9 +183,11 @@ spec: - name: service-configmap configMap: name: {{ $resourceName }} +{{- if $localVals.haproxy }} - name: haproxy-config configMap: name: glance-api-haproxy +{{- end }} {{- if not $localVals.ceph_backend }} - name: glance-persistent-storage persistentVolumeClaim: diff --git a/helm/microservice/glance-delete-db-job/Chart.yaml b/helm/microservice/glance-delete-db-job/Chart.yaml new file mode 100644 index 000000000..cd505d9b8 --- /dev/null +++ b/helm/microservice/glance-delete-db-job/Chart.yaml @@ -0,0 +1,12 @@ +name: glance-delete-db-job +version: 0.4.0-1 +description: Helm chart to delete the glance database +keywords: + - openstack + - glance + - delete + - database +sources: + - http://github.com/openstack +engine: gotpl +#icon: A URL to an SVG or PNG image to be used as an icon (optional). make this point to the new project icons when ready diff --git a/helm/microservice/glance-delete-db-job/templates/glance-delete-db.yaml b/helm/microservice/glance-delete-db-job/templates/glance-delete-db.yaml new file mode 100644 index 000000000..88537396c --- /dev/null +++ b/helm/microservice/glance-delete-db-job/templates/glance-delete-db.yaml @@ -0,0 +1,7 @@ +{{- $searchPath := ":global.kolla.glance.delete_db.job:global.kolla.glance.delete_db.all:global.kolla.glance.api.all:global.kolla.glance.all:global.kolla.all" }} +{{- $resourceName := "glance" }} +{{- $serviceName := "glance" }} +{{- $podTypeBootstrap := true }} +{{- with $env := dict "resourceName" $resourceName "serviceName" $serviceName "podTypeBootstrap" $podTypeBootstrap "Values" .Values "Release" .Release "searchPath" $searchPath }} +{{- include "common_delete_db_job" $env }} +{{- end }} diff --git a/helm/microservice/glance-delete-keystone-service-job/Chart.yaml b/helm/microservice/glance-delete-keystone-service-job/Chart.yaml new file mode 100644 index 000000000..d0aca069d --- /dev/null +++ b/helm/microservice/glance-delete-keystone-service-job/Chart.yaml @@ -0,0 +1,12 @@ +name: glance-delete-keystone-service-job +version: 0.4.0-1 +description: Helm chart to delete the glance keystone service +keywords: + - openstack + - glance + - delete + - service +sources: + - http://github.com/openstack +engine: gotpl +#icon: A URL to an SVG or PNG image to be used as an icon (optional). make this point to the new project icons when ready diff --git a/helm/microservice/glance-delete-keystone-service-job/templates/glance-delete-keystone-service.yaml b/helm/microservice/glance-delete-keystone-service-job/templates/glance-delete-keystone-service.yaml new file mode 100644 index 000000000..a9c6b0d19 --- /dev/null +++ b/helm/microservice/glance-delete-keystone-service-job/templates/glance-delete-keystone-service.yaml @@ -0,0 +1,10 @@ +{{- $searchPath := ":global.kolla.glance.delete_keystone_service.job:global.kolla.glance.delete_keystone_service.all:global.kolla.glance.all:global.kolla.all" }} +{{- $resourceName := "glance-delete-keystone-service" }} +{{- $netHostTrue := false }} +{{- $podTypeBootstrap := true }} +{{- $serviceName := "glance" }} +{{- $serviceType := "image" }} +{{- $description := "Openstack Image Service" }} +{{- with $env := dict "netHostTrue" $netHostTrue "podTypeBootstrap" $podTypeBootstrap "resourceName" $resourceName "serviceName" $serviceName "serviceType" $serviceType "description" $description "Values" .Values "Release" .Release "searchPath" $searchPath }} +{{- include "common_delete_keystone_service" $env }} +{{- end }} diff --git a/helm/microservice/glance-delete-keystone-user-job/Chart.yaml b/helm/microservice/glance-delete-keystone-user-job/Chart.yaml new file mode 100644 index 000000000..29cce5bdf --- /dev/null +++ b/helm/microservice/glance-delete-keystone-user-job/Chart.yaml @@ -0,0 +1,12 @@ +name: glance-delete-keystone-user-job +version: 0.4.0-1 +description: Helm chart to delete the glance keystone user +keywords: + - openstack + - glance + - delete + - user +sources: + - http://github.com/openstack +engine: gotpl +#icon: A URL to an SVG or PNG image to be used as an icon (optional). make this point to the new project icons when ready diff --git a/helm/microservice/glance-delete-keystone-user-job/templates/glance-delete-keystone-user.yaml b/helm/microservice/glance-delete-keystone-user-job/templates/glance-delete-keystone-user.yaml new file mode 100644 index 000000000..a330fb6de --- /dev/null +++ b/helm/microservice/glance-delete-keystone-user-job/templates/glance-delete-keystone-user.yaml @@ -0,0 +1,20 @@ +{{- $searchPath := ":global.kolla.glance.delete_keystone_user.job:global.kolla.glance.delete_keystone_user.all:global.kolla.glance.all:global.kolla.all" }} +{{- $resourceName := "glance-delete-keystone-user" }} +{{- $serviceName := "glance" }} +{{- $serviceType := "delete-keystone-user" }} +{{- $elementName := .Values.element_name | default $serviceName }} +{{- $elementType := .Values.element_type | $serviceType }} + +{{- $userName := include "kolla_val_get_str" (dict "key" "keystone_user_name" "searchPath" $searchPath "Values" .Values ) }} +{{- $userDomain := include "kolla_val_get_str" (dict "key" "keystone_user_domain" "searchPath" $searchPath "Values" .Values ) }} +{{- $userProject := include "kolla_val_get_str" (dict "key" "keystone_user_project" "searchPath" $searchPath "Values" .Values ) }} +{{- $userProjectDomain := include "kolla_val_get_str" (dict "key" "keystone_user_project_domain" "searchPath" $searchPath "Values" .Values ) }} +{{- $userRole := include "kolla_val_get_str" (dict "key" "keystone_user_role" "searchPath" $searchPath "Values" .Values ) }} + +{{- $netHostTrue := false }} +{{- $podTypeBootstrap := true }} + +{{- with $env := dict "resourceName" $resourceName "serviceName" $serviceName "serviceType" $serviceType "elementName" $elementName "elementType" $elementType "podTypeBootstrap" $podTypeBootstrap "userName" $userName "userDomain" $userDomain "userProject" $userProject "userProjectDomain" $userProjectDomain "userRole" $userRole "Values" .Values "Release" .Release "searchPath" $searchPath }} + +{{- include "common_delete_keystone_user" $env }} +{{- end }} diff --git a/helm/service/glance-cleanup/Chart.yaml b/helm/service/glance-cleanup/Chart.yaml new file mode 100644 index 000000000..c75e5c349 --- /dev/null +++ b/helm/service/glance-cleanup/Chart.yaml @@ -0,0 +1,13 @@ +name: glance-cleanup +version: 0.4.0-1 +description: Helm chart for glance cleanup package +keywords: + - openstack + - glance + - delete-user + - delete-service + - delete-db +sources: + - http://github.com/openstack +engine: gotpl +#icon: A URL to an SVG or PNG image to be used as an icon (optional). make this point to the new project icons when ready diff --git a/helm/service/glance-cleanup/requirements.yaml b/helm/service/glance-cleanup/requirements.yaml new file mode 100644 index 000000000..96e817e74 --- /dev/null +++ b/helm/service/glance-cleanup/requirements.yaml @@ -0,0 +1,10 @@ +dependencies: + - name: glance-delete-db-job + repository: http://localhost:10191 + version: 0.4.0-1 + - name: glance-delete-keystone-service-job + repository: http://localhost:10191 + version: 0.4.0-1 + - name: glance-delete-keystone-user-job + repository: http://localhost:10191 + version: 0.4.0-1 diff --git a/helm/service/glance-cleanup/values.yaml b/helm/service/glance-cleanup/values.yaml new file mode 100644 index 000000000..231cb344e --- /dev/null +++ b/helm/service/glance-cleanup/values.yaml @@ -0,0 +1,20 @@ +global: + kolla: + all: + kubernetes_entrypoint: true + glance: + delete_db: + job: + dependencies: + service: + - mariadb + delete_keystone_user: + job: + dependencies: + service: + - keystone-admin + delete_keystone_service: + job: + dependencies: + service: + - keystone-admin diff --git a/tests/bin/cleanup_tests.sh b/tests/bin/cleanup_tests.sh new file mode 100755 index 000000000..178c767fb --- /dev/null +++ b/tests/bin/cleanup_tests.sh @@ -0,0 +1,34 @@ +#!/bin/bash -xe + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" + +function delete_and_cleanup { + +### Removing previous deployment +helm ls | grep $1 | awk {'print $1'} | xargs helm delete --purge +$DIR/tools/wait_for_pods_termination.sh kolla + +### Cleaning service leftovers +helm install kolla/$1-cleanup --namespace=kolla --name $1-cleanup +$DIR/tools/wait_for_pods.sh kolla + +### Checking for leftovers +if [ $(openstack service list --column Name --format value | grep $1 | wc -l) -ne 0 ]; then + exit -1 +fi +if [ $(openstack user list --column Name --format value | grep $1 | wc -l) -ne 0 ]; then + exit -1 +fi +user='root' +password=$(python -c 'import yaml; print yaml.load(open("/etc/kolla/passwords.yml"))["database_password"]') +if [ $(kubectl exec mariadb-0 -n kolla -- mysql --user=$user --password=$password -e 'show databases;' | grep $1 | wc -l) -ne 0 ]; then + exit -1 +fi +} + +delete_and_cleanup glance + +delete_and_cleanup cinder + +### All clean!!! +exit 0 diff --git a/tools/helm_prebuild_microservices.py b/tools/helm_prebuild_microservices.py index 40a85a7a2..46bcb5878 100755 --- a/tools/helm_prebuild_microservices.py +++ b/tools/helm_prebuild_microservices.py @@ -48,7 +48,8 @@ common_mariadb = [ 'nova-api-create-db-job', 'cinder-create-db-job', 'glance-create-db-job', - 'cinder-delete-db-job' + 'cinder-delete-db-job', + 'glance-delete-db-job' ] common_create_keystone_admin = [ @@ -78,7 +79,9 @@ common_create_keystone_admin = [ 'cinder-create-keystone-endpoint-adminv2-job', 'cinder-delete-keystone-service-job', 'cinder-delete-keystone-servicev2-job', - 'cinder-delete-keystone-user-job' + 'cinder-delete-keystone-user-job', + 'glance-delete-keystone-service-job', + 'glance-delete-keystone-user-job' ] diff --git a/tools/setup_gate.sh b/tools/setup_gate.sh index f926a5160..9f9b5a3c2 100755 --- a/tools/setup_gate.sh +++ b/tools/setup_gate.sh @@ -215,4 +215,5 @@ fi kubectl get pods --namespace=kolla kubectl get svc --namespace=kolla tests/bin/basic_tests.sh +tests/bin/cleanup_tests.sh tests/bin/build_docker_images.sh $WORKSPACE/logs $DISTRO $TYPE $CONFIG $PIPELINE diff --git a/tools/setup_gate_iscsi.sh b/tools/setup_gate_iscsi.sh index 6f26bce82..ee6a316fb 100755 --- a/tools/setup_gate_iscsi.sh +++ b/tools/setup_gate_iscsi.sh @@ -128,4 +128,5 @@ sudo vgs >> $WORKSPACE/logs/vgs.txt sudo lvs >> $WORKSPACE/logs/lvs.txt tests/bin/basic_tests.sh +tests/bin/cleanup_tests.sh tests/bin/build_docker_images.sh $WORKSPACE/logs $DISTRO $TYPE $CONFIG $PIPELINE diff --git a/tools/wait_for_pods_termination.sh b/tools/wait_for_pods_termination.sh new file mode 100755 index 000000000..a311ac2a6 --- /dev/null +++ b/tools/wait_for_pods_termination.sh @@ -0,0 +1,16 @@ +#!/bin/bash -e +set +x +end=$(date +%s) +end=$((end + 300)) +while true; do + kubectl get pods --namespace=$1 | grep Terminating > /dev/null && \ + TERMINATING=True || TERMINATING=False + [ $TERMINATING == "False" ] && \ + break || true + sleep 1 + now=$(date +%s) + echo 'Waitng for pod to terminate: ' $now + [ $now -gt $end ] && echo containers failed to terminate. && \ + kubectl get pods --namespace $1 && exit -1 +done +set -x