@@ -1897,40 +1897,35 @@ list_files_on_storage() {
18971897verify_all_backups_deletion () {
18981898 for backup in $( kubectl get ps-backup -n " $NAMESPACE " -o jsonpath=' {.items[*].metadata.name}' ) ; do
18991899 echo " Checking backup: $backup "
1900-
1901- output=$(
1900+ eval " $(
19021901 kubectl get ps-backup " $backup " -n " $NAMESPACE " -o json \
1903- | yq -r '
1904- .status.storage as $storage |
1905- [
1906- $storage.type,
1907- ($storage[.type].bucket // $storage[.type].container // ""),
1908- ($storage[.type].credentialsSecret // ""),
1909- ($storage[.type].endpointUrl // ""),
1910- ($storage[.type].region // ""),
1911- (.status.destination // "")
1912- ] | @tsv
1902+ | jq -r '
1903+ .status.storage.type as $t |
1904+ (if $t then .status.storage[$t] else {} end) as $s |
1905+ "storage_type=\($t // "")",
1906+ "bucket=\($s.bucket // $s.container // "")",
1907+ "secret_name=\($s.credentialsSecret // "")",
1908+ "endpoint=\($s.endpointUrl // "")",
1909+ "region=\($s.region // "")",
1910+ "destination=\(.status.destination // "")"
19131911 '
1914- )
1912+ ) "
19151913
1916- read -r storage_type bucket secret_name endpoint region destination <<< " $output "
1914+ kubectl delete ps-backup " $backup " -n " $NAMESPACE "
19171915
19181916 prefix=" ${destination#*://*/ } "
19191917 if [[ -z $destination ]]; then
19201918 echo " Backup $backup is missing destination"
19211919 break
19221920 fi
19231921
1924- kubectl delete ps-backup " $backup " -n " $NAMESPACE "
1925-
19261922 local removed=false
19271923 for i in {1..5}; do
19281924 if [[ " $( count_files_on_storage " $storage_type " " $bucket " " $prefix " " $secret_name " " $region " " $endpoint " ) " == " 0" ]]; then
19291925 echo " Backup removed: $backup "
19301926 removed=true
19311927 break
19321928 fi
1933-
19341929 echo " Waiting for backup removal ($i /5): $backup "
19351930 sleep 5
19361931 done
0 commit comments