mirror of
https://github.com/docker/login-action.git
synced 2025-02-22 10:20:25 +00:00
fix retries mechanism
Signed-off-by: Fedor Dikarev <fedor.dikarev@gmail.com>
This commit is contained in:
parent
30ba015e5a
commit
cc953186b8
1 changed files with 3 additions and 3 deletions
|
@ -14,11 +14,11 @@ export async function login(registry: string, username: string, password: string
|
||||||
}
|
}
|
||||||
succeeded = true;
|
succeeded = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (attempt < max_attempts && isRetriableError(error, http_errors_to_retry)) {
|
if (attempt < max_attempts && isRetriableError(error.message, http_errors_to_retry)) {
|
||||||
core.info(`Attempt ${attempt} out of ${max_attempts} failed, retrying after ${retry_timeout} seconds`);
|
core.info(`Attempt ${attempt} out of ${max_attempts} failed, retrying after ${retry_timeout} seconds`);
|
||||||
await new Promise(r => setTimeout(r, retry_timeout * 1000));
|
await new Promise(r => setTimeout(r, retry_timeout * 1000));
|
||||||
} else {
|
} else {
|
||||||
throw new Error(error);
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ export async function logout(registry: string): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isRetriableError(error_message: string, http_errors_to_retry: string[]): boolean {
|
function isRetriableError(error_message: string, http_errors_to_retry: string[]): boolean {
|
||||||
for (const err_code in http_errors_to_retry) {
|
for (const err_code of http_errors_to_retry) {
|
||||||
if (error_message.includes('failed with status: ' + err_code)) {
|
if (error_message.includes('failed with status: ' + err_code)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue