]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-{ansible,container}*: Globally destroy all stale VMs 1835/head
authorDavid Galloway <dgallowa@redhat.com>
Mon, 14 Jun 2021 20:11:51 +0000 (16:11 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Mon, 14 Jun 2021 21:35:28 +0000 (17:35 -0400)
Signed-off-by: David Galloway <dgallowa@redhat.com>
ceph-ansible-nightly/build/build
ceph-ansible-prs/build/build
ceph-ansible-scenario/build/build
ceph-container-nighlity/build/build
ceph-container-prs/build/build
scripts/build_utils.sh

index 7b53d9d23979a03500fb9160f9d182637be083fb..dd809f5ad5bc434f304a0449e7b297e60f8d3b22 100644 (file)
@@ -52,6 +52,7 @@ function run_tox {
 ########
 # MAIN #
 ########
+prune_stale_vagrant_running_vms
 delete_libvirt_vms
 clear_libvirt_networks
 restart_libvirt_services
index 9a70a950fda4e2904738806d48560da2612c76ed..84d770a335d55415c54bf9823b8d7b37fd8fb998 100644 (file)
@@ -11,6 +11,7 @@ source $VENV/activate
 
 WORKDIR=$(mktemp -td tox.XXXXXXXXXX)
 
+prune_stale_vagrant_running_vms
 delete_libvirt_vms
 clear_libvirt_networks
 restart_libvirt_services
index 2144e9bfc2f8afa67cb54c5c837fbc082ed3b795..637f9c13e1d52cc2f5bdf413c94d1243863068b7 100644 (file)
@@ -11,6 +11,7 @@ source $VENV/activate
 
 WORKDIR=$(mktemp -td tox.XXXXXXXXXX)
 
+prune_stale_vagrant_running_vms
 delete_libvirt_vms
 clear_libvirt_networks
 restart_libvirt_services
index 027c276af7a8e4c397282879f3792477bff10cde..b8e20b778db95ed45ab871ad346dddf943aa652f 100644 (file)
@@ -11,6 +11,7 @@ source $VENV/activate
 
 WORKDIR=$(mktemp -td tox.XXXXXXXXXX)
 
+prune_stale_vagrant_running_vms
 delete_libvirt_vms
 clear_libvirt_networks
 restart_libvirt_services
index 027c276af7a8e4c397282879f3792477bff10cde..b8e20b778db95ed45ab871ad346dddf943aa652f 100644 (file)
@@ -11,6 +11,7 @@ source $VENV/activate
 
 WORKDIR=$(mktemp -td tox.XXXXXXXXXX)
 
+prune_stale_vagrant_running_vms
 delete_libvirt_vms
 clear_libvirt_networks
 restart_libvirt_services
index 09c362b6d9169fd9d7094b0520c60a925a2b2b36..b2dadf77c887be100f69de360b84741755d00aba 100644 (file)
@@ -1018,6 +1018,29 @@ prune_stale_vagrant_vms() {
     vagrant global-status --prune || true
 }
 
+prune_stale_vagrant_running_vms() {
+    # The method of cleaning up VMs in the function above isn't aggressive enough.
+    cd $HOME
+    running_vagrant_vms=$(vagrant global-status | grep "running" | awk '{ print $1 }')
+    for uuid in $running_vagrant_vms; do
+        if ! vagrant destroy -f $uuid; then
+            echo "Destroying $uuid failed.  Deleting its directory."
+            failed_path=$(vagrant global-status | grep $uuid | awk '{ print $5 }')
+            if [ -z ${failed_path+x} ]; then
+                echo "Didn't get a path for $uuid.  Skipping."
+            else
+                if [[ $failed_path =~ $WORKSPACE ]]; then
+                    echo "Skipping $failed_path.  That's the current job."
+                else
+                    rm -rf $failed_path
+                fi
+            fi
+            vagrant global-status --prune
+        fi
+    done
+    cd $WORKSPACE
+}
+
 delete_libvirt_vms() {
     # Delete any VMs leftover from previous builds.
     # Primarily used for Vagrant VMs leftover from docker builds.