Skip to content

Commit 8e04a5f

Browse files
committed
update s3 shared url
cleanup unused variables
1 parent f14fd25 commit 8e04a5f

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

qdrant-backup-restore/qdrant_backup_recovery.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ track_created_collection_snapshot() {
183183
_printf "[%s] found %d remote shard(s) for %s collection on peer, will create a snapshot.\n" "$peer_url" "$remote_shards_length" "$collection_name"
184184
while read -r item; do
185185
peer_id=$(jq -r '.peer_id' <<< "$item")
186-
if [[ -n "${peer_uri_pass[peer_id]+x}" ]]; then # skip already visited peers
186+
if [[ -n "${peer_uri_pass[$peer_id]+x}" ]]; then # skip already visited peers
187187
continue
188188
fi
189189
peer_url=${peer_uri_map[$peer_id]}
@@ -259,8 +259,6 @@ fetch_collection_snapshot() {
259259
return
260260
fi
261261

262-
item=$(jq -c '.result[0] // empty' <<< "$result")
263-
264262
_result=$(jq -c '.result // [] | .[]' <<< "$result")
265263
while read -r item; do
266264
local snapshot_name=""
@@ -402,10 +400,12 @@ get_s3_url() {
402400
local status=""
403401
status=$(jq -r '.status?' <<< "$result")
404402
if [ "$status" != "success" ]; then
405-
_printf "[%s] failed to fetch snapshots for collections %s, got this instead %s\n" "$host" "$collection_name" "${result//[[:space:]]/}"
403+
_printf "failed to fetch snapshots for collections %s, got this instead %s\n" "$collection_name" "${result//[[:space:]]/}"
404+
return 1
406405
fi
407406

408407
s3_presigned_url=$(jq -r '.share' <<< "$result")
408+
return 0
409409
}
410410

411411
# restores an collection snapshot from an s3 url updates the $QDRANT_SNAPSHOT_RECOVERY_HISTORY_FILE and $QDRANT_FAILED_RECOVERY_FILE
@@ -418,7 +418,12 @@ recover_collection_snapshot() {
418418

419419
_printf "[%s] started to recover %s snapshot of %s collection...\n" "$host" "$snapshot_name" "$collection_name"
420420

421-
get_s3_url "$collection_name" "$snapshot_name"
421+
if ! get_s3_url "$collection_name" "$snapshot_name"; then
422+
((fail_recovered_count=fail_recovered_count+1))
423+
_printf "[%s] failed to presign S3 URL for %s snapshot of %s collection, skipping recover request\n" "$host" "$snapshot_name" "$collection_name"
424+
printf '%s,%s,%s\n' "$host" "$snapshot_name" "presign_failed" >> $QDRANT_FAILED_RECOVERY_FILE
425+
return
426+
fi
422427

423428
result=$(_curl PUT \
424429
"$host/collections/$collection_name/snapshots/recover?wait=$QDRANT_WAIT_ON_TASK" \
@@ -665,7 +670,7 @@ get_peers_from_cluster_info() {
665670
done <<< "$peer_uri_entries"
666671

667672
if [ ${#peer_uri_map[@]} -eq 0 ]; then
668-
_printf "no registered host peers in %s... exiting" "$host"
673+
_printf "no registered host peers in %s... exiting\n" "$host"
669674
exit 1
670675
fi
671676
}

0 commit comments

Comments
 (0)