openstack-helm/nova/templates/bin/_nova-service-cleaner.sh.tpl
Pete Birley 69fca6be30 Nova: Reap dead services
This PS adds a cron job that reaps dead services from Nova.

Change-Id: I59e74c7520b0341d7cb7ebddd4c21e459e9c2049
Signed-off-by: Pete Birley <pete@port.direct>
2018-07-16 18:38:50 +00:00

28 lines
1012 B
Smarty

#!/bin/bash
{{/*
Copyright 2018 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.
*/}}
set -xe
NOVA_SERVICES_TO_CLEAN="$(openstack compute service list -f value -c Binary | sort | uniq | grep -v '^nova-compute$')"
for NOVA_SERVICE in ${NOVA_SERVICES_TO_CLEAN}; do
DEAD_SERVICE_IDS=$(openstack compute service list --service ${NOVA_SERVICE} -f json | jq -r '.[] | select(.State == "down") | .ID')
for SERVICE_ID in ${DEAD_SERVICE_IDS}; do
openstack compute service delete "${SERVICE_ID}"
done
done