@@ -1895,51 +1895,46 @@ list_files_on_storage() {
18951895}
18961896
18971897verify_all_backups_deletion () {
1898- for backup in $( kubectl get ps-backup -n " $NAMESPACE " -o jsonpath=' {.items[*].metadata.name}' ) ; do
1899- echo " Checking backup: $backup "
1900-
1901- output=$(
1898+ for backup in $( kubectl get ps-backup -n " $NAMESPACE " -o jsonpath=' {.items[*].metadata.name}' ) ; do
1899+ echo " Checking backup: $backup "
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- )
1915-
1916- read -r storage_type bucket secret_name endpoint region destination <<< " $output"
1917-
1918- prefix=" ${destination#*://*/ } "
1919- if [[ -z $destination ]]; then
1920- echo " Backup $backup is missing destination"
1921- break
1922- fi
1912+ ) "
19231913
19241914 kubectl delete ps-backup " $backup " -n " $NAMESPACE "
19251915
1926- local removed=false
1927- for i in {1..5}; do
1928- if [[ " $( count_files_on_storage " $storage_type " " $bucket " " $prefix " " $secret_name " " $region " " $endpoint " ) " == " 0" ]]; then
1929- echo " Backup removed: $backup "
1930- removed=true
1931- break
1932- fi
1933-
1934- echo " Waiting for backup removal ($i /5): $backup "
1935- sleep 5
1936- done
1937-
1938- if ! $removed ; then
1939- echo " Backup still present: $backup "
1940- exit 1
1941- fi
1942- done
1916+ prefix=" ${destination#*://*/ } "
1917+ if [[ -z $destination ]]; then
1918+ echo " Backup $backup is missing destination"
1919+ break
1920+ fi
1921+
1922+ local removed=false
1923+ for i in {1..5}; do
1924+ if [[ " $( count_files_on_storage " $storage_type " " $bucket " " $prefix " " $secret_name " " $region " " $endpoint " ) " == " 0" ]]; then
1925+ echo " Backup removed: $backup "
1926+ removed=true
1927+ break
1928+ fi
1929+ echo " Waiting for backup removal ($i /5): $backup "
1930+ sleep 5
1931+ done
1932+
1933+ if ! $removed ; then
1934+ echo " Backup still present: $backup "
1935+ exit 1
1936+ fi
1937+ done
19431938}
19441939
19451940count_backups_in_schedule () {
0 commit comments