X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fopendaylight-infra-cleanup-stale-stacks.sh;h=4c59d8c61bb27bf8a82696e0b3bf1c9cd43ef628;hb=444295f63ad63e08f51606c3a232521096b39a12;hp=091e212bc87ae3624edea2b6bbc33f4597fd32d9;hpb=ebf4bc5604d4a055be55c142f12bbfbd1f6b8a07;p=releng%2Fbuilder.git diff --git a/jjb/opendaylight-infra-cleanup-stale-stacks.sh b/jjb/opendaylight-infra-cleanup-stale-stacks.sh index 091e212bc..4c59d8c61 100644 --- a/jjb/opendaylight-infra-cleanup-stale-stacks.sh +++ b/jjb/opendaylight-infra-cleanup-stale-stacks.sh @@ -8,6 +8,15 @@ pip freeze ######################### ## FETCH ACTIVE BUILDS ## ######################### +# Fetch stack list before fetching active builds to minimize race condition +# where we might be try to delete stacks while jobs are trying to start +OS_STACKS=(`openstack --os-cloud rackspace stack list \ + -f json -c "Stack Name" -c "Stack Status" \ + --property "stack_status=CREATE_COMPLETE" \ + --property "stack_status=DELETE_FAILED" \ + --property "stack_status=CREATE_FAILED" \ + | jq -r '.[] | ."Stack Name"'`) + # Make sure we fetch active builds on both the releng and sandbox silos ACTIVE_BUILDS=() for silo in releng sandbox; do @@ -24,12 +33,6 @@ done ########################## # Search for stacks taht are not in use by either releng or sandbox silos and # delete them. -OS_STACKS=(`openstack --os-cloud rackspace stack list \ - -f json -c "Stack Name" -c "Stack Status" \ - --property "stack_status=CREATE_COMPLETE" \ - --property "stack_status=DELETE_FAILED" \ - --property "stack_status=CREATE_FAILED" \ - | jq -r '.[] | ."Stack Name"'`) for stack in ${OS_STACKS[@]}; do if [[ "${ACTIVE_BUILDS[@]}" =~ $stack ]]; then # No need to delete stacks if there exists an active build for them