Merge "Fix: Use lf-activate-venv to reuse venv" v0.82.1
authorEric Ball <eball@linuxfoundation.org>
Mon, 17 Oct 2022 17:53:38 +0000 (17:53 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Mon, 17 Oct 2022 17:53:38 +0000 (17:53 +0000)
releasenotes/notes/fix-os-objects-exit-status-97d6a6c4a6cb1f6c.yaml [new file with mode: 0644]
shell/openstack-cleanup-orphaned-objects.sh
shell/openstack-cleanup-orphaned-ports.sh

diff --git a/releasenotes/notes/fix-os-objects-exit-status-97d6a6c4a6cb1f6c.yaml b/releasenotes/notes/fix-os-objects-exit-status-97d6a6c4a6cb1f6c.yaml
new file mode 100644 (file)
index 0000000..563c009
--- /dev/null
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    Addresses a bug whereby the openstack orphaned objects/ports scripts
+    exit early with an error when grep/awk do not match any orphaned
+    objects. The fix allows jobs using the scripts to continue when no
+    cleanups operations are required.
index 3a3dbc2..6d845b7 100755 (executable)
@@ -74,11 +74,11 @@ _cleanup()
 if [[ -n ${filters} ]]; then
     # If a filter/match condition is requested/set
     openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID $attributes \
-     | $filters | awk '{print $1}'> "$tmpfile"
+     | { $filters || true; } | { awk '{print $1}' || true; } > "$tmpfile"
 else
     # Otherwise don't pipe through an additional command
     openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID $attributes \
-     | awk '{print $1}'> "$tmpfile"
+     | { awk '{print $1}' || true; } > "$tmpfile"
 fi
 
 # Count the number of objects to process
@@ -89,7 +89,7 @@ echo "Using $threads parallel processes..."
 # Export variables and send to parallel for processing
 export -f _cleanup
 export os_cloud cutoff age object
-# parallel --progress --retries 3 -j "$threads" _cleanup < "$tmpfile"
+# Add --progress flag to the command below for additional debug output
 parallel --retries 3 -j "$threads" _cleanup < "$tmpfile"
 
 rm "$tmpfile"
index 8549737..b5c0af5 100755 (executable)
@@ -55,7 +55,8 @@ _cleanup()
 }
 
 # Output the initial list of port UUIDs to a temporary file
-openstack --os-cloud "$os_cloud" port list -f value -c ID -c status | grep -e DOWN | awk '{print $1}'> "$tmpfile"
+openstack --os-cloud "$os_cloud" port list -f value -c ID -c status \
+    | { grep -e DOWN || true; } | { awk '{print $1}' || true; } > "$tmpfile"
 
 # Count the number to process
 total=$(wc -l "$tmpfile" | awk '{print $1}')