PS adds glance cleanup service

PS adds glance cleanup service

Change-Id: I885e39c1b184ac1fd73a51d694dd147011d0dc51
Partially-Implements: blueprint helm-service-cleanup
This commit is contained in:
Serguei Bezverkhi 2017-01-27 19:31:57 -05:00
parent a8956537c1
commit f214d310df
18 changed files with 213 additions and 7 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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

View File

@ -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 }}

View File

@ -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

View File

@ -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 }}

View File

@ -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

View File

@ -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 }}

View File

@ -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

View File

@ -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

View File

@ -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

34
tests/bin/cleanup_tests.sh Executable file
View File

@ -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

View File

@ -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'
]

View File

@ -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

View File

@ -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

View File

@ -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