Skip to content

Commit 06ab7fd

Browse files
Increase retry attempts and improve error messaging for Azure Blob Storage uploads
1 parent 2e3f6ac commit 06ab7fd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

infra/scripts/copy_kb_files.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,28 @@ unzip -o $zipUrl1 -d infra/data/"$extractedFolder1"
9898
echo "Uploading files to Azure Blob Storage"
9999
az storage blob upload-batch --account-name "$storageAccount" --destination "$fileSystem"/"$extractedFolder1" --source infra/data/"$extractedFolder1" --auth-mode login --pattern '*' --overwrite --output none
100100
if [ $? -ne 0 ]; then
101-
retries=3
101+
maxRetries=5
102+
retries=$maxRetries
102103
sleepTime=10
103-
echo "Error: Failed to upload files to Azure Blob Storage. Retrying upload...($((4 - retries)) of 3)"
104+
attempt=1
104105
while [ $retries -gt 0 ]; do
106+
echo "Error: Failed to upload files to Azure Blob Storage. Retrying upload...$attempt of $maxRetries in $sleepTime seconds"
105107
sleep $sleepTime
106108
az storage blob upload-batch --account-name "$storageAccount" --destination "$fileSystem"/"$extractedFolder1" --source infra/data/"$extractedFolder1" --auth-mode login --pattern '*' --overwrite --output none
107109
if [ $? -eq 0 ]; then
108110
echo "Files uploaded successfully to Azure Blob Storage."
109111
break
110112
else
111113
((retries--))
112-
echo "Retrying upload... ($((4 - retries)) of 3)"
114+
((attempt++))
113115
sleepTime=$((sleepTime * 2))
114-
sleep $sleepTime
115116
fi
116117
done
117-
exit 1
118+
119+
if [ $retries -eq 0 ]; then
120+
echo "Error: Failed to upload files after all retry attempts."
121+
exit 1
122+
fi
118123
else
119124
echo "Files uploaded successfully to Azure Blob Storage."
120125
fi

0 commit comments

Comments
 (0)