From: Thanh Ha Date: Wed, 14 Feb 2018 13:33:48 +0000 (-0500) Subject: Re-enable orphaned nodes cleanup script X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;ds=sidebyside;h=2e2056fb43b101c8ee11968f0ad54f1ef4e9235d;p=releng%2Fbuilder.git Re-enable orphaned nodes cleanup script With lftools v0.12.0 now available we can switch this script back on. Improve the script to remove servers only if they are 15 minutes old to give them time to connect to Jenkins. Change-Id: Ia5792a937e41f4da73188b4b38f95028f689345c Signed-off-by: Thanh Ha --- diff --git a/jjb/odl-openstack-cleanup-orphaned-nodes.sh b/jjb/odl-openstack-cleanup-orphaned-nodes.sh index 953dadc81..1b7f0c68e 100644 --- a/jjb/odl-openstack-cleanup-orphaned-nodes.sh +++ b/jjb/odl-openstack-cleanup-orphaned-nodes.sh @@ -10,9 +10,6 @@ ############################################################################## echo "---> Cleanup orphaned servers" -# shellcheck source=/tmp/v/openstack/bin/activate disable=SC1091 -source "/tmp/v/openstack/bin/activate" - minion_in_jenkins() { # Usage: check_stack_in_jenkins STACK_NAME JENKINS_URL [JENKINS_URL...] # Returns: 0 If stack is in Jenkins and 1 if stack is not in Jenkins. @@ -46,13 +43,22 @@ minion_in_jenkins() { # Fetch server list before fetching active minions to minimize race condition # where we might be trying to delete servers while jobs are trying to start +# shellcheck source=/tmp/v/openstack/bin/activate disable=SC1091 +source "/tmp/v/openstack/bin/activate" + # We purposely need word splitting here to create the OS_SERVERS array. # shellcheck disable=SC2207 -OS_SERVERS=($(openstack server list -f value -c "Name" | grep -E 'prd|snd')) +mapfile -t OS_SERVERS < <(openstack server list -f value -c "Name" | grep -E 'prd|snd') + +deactivate ############################# ## DELETE ORPHANED SERVERS ## ############################# + +# shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091 +source "/tmp/v/lftools/bin/activate" + # Search for servers that are not in use by either releng or sandbox silos and # delete them. for server in "${OS_SERVERS[@]}"; do @@ -64,6 +70,9 @@ for server in "${OS_SERVERS[@]}"; do continue else echo "Deleting $server" - openstack server delete "$server" + lftools openstack --os-cloud vex \ + server remove --minutes 15 "$server" fi done + +deactivate diff --git a/jjb/releng-jobs.yaml b/jjb/releng-jobs.yaml index 6ae1b9ea3..c1f41b551 100644 --- a/jjb/releng-jobs.yaml +++ b/jjb/releng-jobs.yaml @@ -212,9 +212,7 @@ # Servers - odl-openstack-cleanup-stale-stacks - odl-openstack-cleanup-stale-nodes - # Disable orphaned nodes script. See: - # https://jira.linuxfoundation.org/browse/RELENG-780 - # - odl-openstack-cleanup-orphaned-nodes + - odl-openstack-cleanup-orphaned-nodes # Images - odl-openstack-check-image-protection - odl-openstack-cleanup-old-images