Skip to content

Commit 27a47e1

Browse files
D-40783 Added maxTransientRetries input
1 parent 9e9c692 commit 27a47e1

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ During execution, this action creates a temporary directory named **`tmp-dai`**
5858
| `username` | Username for Digital.ai Deploy authentication. | Yes | N/A |
5959
| `password` | Password for Digital.ai Deploy authentication. | Yes | N/A |
6060
| `action` | Specifies the operation(s). One of: `create`, `publish`, `deploy`, `create_publish`, `publish_deploy`, `create_publish_deploy` | No | `create_publish_deploy` |
61+
| `maxTransientRetries` | The maximum number of retries when encountering transient errors. | No | 5 |
6162

6263
---
6364

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ inputs:
4343
rollback:
4444
description: 'Invoke a rollback in case of deployment failure'
4545
required: false
46+
maxTransientRetries:
47+
description: 'The maximum number of retries when encountering transient errors'
48+
required: false
4649

4750
outputs:
4851
deploymentPackageId:

dist/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64945,6 +64945,8 @@ class DeployManager {
6494564945

6494664946
static serverConfig;
6494764947

64948+
static maxTransientRetries = 5; // Default to 5 retries if not set
64949+
6494864950
// General API request method
6494964951
// deploy-manager.js
6495064952

@@ -65237,7 +65239,6 @@ class DeployManager {
6523765239
// Wait for task to complete
6523865240
static async waitForTask(taskId) {
6523965241
const runningStates = ["QUEUED", "EXECUTING", "ABORTING", "STOPPING", "FAILING", "PENDING"];
65240-
const maxTransientRetries = 5;
6524165242
let transientAttempts = 0;
6524265243
let task;
6524365244
while (true) {
@@ -65252,9 +65253,9 @@ class DeployManager {
6525265253
} catch (error) {
6525365254
// Handle the specific 500 “cannot create children…” error as transient
6525465255
const msg = error.message || "";
65255-
if (msg.includes("500") && msg.includes("cannot create children while terminating or terminated") && transientAttempts < maxTransientRetries) {
65256+
if (msg.includes("500") && msg.includes("cannot create children while terminating or terminated") && transientAttempts < this.maxTransientRetries) {
6525665257
transientAttempts++;
65257-
console.log(`Transient error checking task status (attempt ${transientAttempts}/${maxTransientRetries}): ${msg} Retrying in ${transientAttempts * 5}s…`);
65258+
console.log(`Transient error checking task status (attempt ${transientAttempts}/${this.maxTransientRetries}): ${msg} Retrying in ${transientAttempts * 5}s…`);
6525865259
await this.sleepFor(transientAttempts * 5);
6525965260
continue;
6526065261
}
@@ -65377,6 +65378,9 @@ async function run() {
6537765378
const deploymentPackageIdInput = core.getInput('deploymentPackageId'); // Renamed to avoid conflict with local variable
6537865379
const environmentId = core.getInput('environmentId');
6537965380
const rollback = core.getInput('rollback') || 'false';
65381+
const maxTransientRetries = parseInt(core.getInput('maxTransientRetries'), 10) || 5; // Default to 5 retries if not set
65382+
65383+
DeployManager.maxTransientRetries = maxTransientRetries; // Set the max transient retries for DeployManager
6538065384

6538165385
function logNonEmptyInputs() {
6538265386
const inputs = {
@@ -65388,7 +65392,8 @@ async function run() {
6538865392
darPackagePath: darPackagePathInput,
6538965393
deploymentPackageId: deploymentPackageIdInput,
6539065394
environmentId,
65391-
rollback
65395+
rollback,
65396+
maxTransientRetries
6539265397
};
6539365398

6539465399
core.info('Provided action inputs:');

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/deploy-manager.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class DeployManager {
1010

1111
static serverConfig;
1212

13+
static maxTransientRetries = 5; // Default to 5 retries if not set
14+
1315
// General API request method
1416
// deploy-manager.js
1517

@@ -302,7 +304,6 @@ class DeployManager {
302304
// Wait for task to complete
303305
static async waitForTask(taskId) {
304306
const runningStates = ["QUEUED", "EXECUTING", "ABORTING", "STOPPING", "FAILING", "PENDING"];
305-
const maxTransientRetries = 5;
306307
let transientAttempts = 0;
307308
let task;
308309
while (true) {
@@ -317,9 +318,9 @@ class DeployManager {
317318
} catch (error) {
318319
// Handle the specific 500 “cannot create children…” error as transient
319320
const msg = error.message || "";
320-
if (msg.includes("500") && msg.includes("cannot create children while terminating or terminated") && transientAttempts < maxTransientRetries) {
321+
if (msg.includes("500") && msg.includes("cannot create children while terminating or terminated") && transientAttempts < this.maxTransientRetries) {
321322
transientAttempts++;
322-
console.log(`Transient error checking task status (attempt ${transientAttempts}/${maxTransientRetries}): ${msg} Retrying in ${transientAttempts * 5}s…`);
323+
console.log(`Transient error checking task status (attempt ${transientAttempts}/${this.maxTransientRetries}): ${msg} Retrying in ${transientAttempts * 5}s…`);
323324
await this.sleepFor(transientAttempts * 5);
324325
continue;
325326
}

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ async function run() {
6767
const deploymentPackageIdInput = core.getInput('deploymentPackageId'); // Renamed to avoid conflict with local variable
6868
const environmentId = core.getInput('environmentId');
6969
const rollback = core.getInput('rollback') || 'false';
70+
const maxTransientRetries = parseInt(core.getInput('maxTransientRetries'), 10) || 5; // Default to 5 retries if not set
71+
72+
DeployManager.maxTransientRetries = maxTransientRetries; // Set the max transient retries for DeployManager
7073

7174
function logNonEmptyInputs() {
7275
const inputs = {
@@ -78,7 +81,8 @@ async function run() {
7881
darPackagePath: darPackagePathInput,
7982
deploymentPackageId: deploymentPackageIdInput,
8083
environmentId,
81-
rollback
84+
rollback,
85+
maxTransientRetries
8286
};
8387

8488
core.info('Provided action inputs:');

0 commit comments

Comments
 (0)