Skip to content

Commit a848ae9

Browse files
authored
Fix workflow:wait timeout to use warnings instead of errors (#2724)
1 parent c365e32 commit a848ae9

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/Commands/Workflow/WaitCommand.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,20 @@ protected function waitForWorkflow(
111111
do {
112112
$current_time = time();
113113
if ($maxNotFoundAttempts && $not_found_attempts === $maxNotFoundAttempts) {
114-
throw new TerminusException(
114+
$this->log()->warning(
115115
"Attempted '{max}' times, giving up waiting for workflow to be found",
116116
['max' => $maxNotFoundAttempts]
117117
);
118+
return;
118119
}
119120

120-
// Check if the timeout has been reached and throw an exception if so.
121+
// Check if the timeout has been reached and log warning if so.
121122
if ($end_time > 0 && $current_time >= $end_time) {
122-
throw new TerminusException(
123-
'Workflow timed out after {timeout} seconds.',
123+
$this->log()->warning(
124+
'Waited \'{timeout}\' seconds, giving up waiting for workflow to finish',
124125
['timeout' => $maxWaitInSeconds]
125126
);
127+
return;
126128
}
127129
$site = $this->getSiteById($site->id);
128130
$workflows->reset();
@@ -171,10 +173,11 @@ protected function waitForWorkflow(
171173
}
172174
do {
173175
if ($end_time > 0 && $current_time >= $end_time) {
174-
throw new TerminusException(
175-
'Workflow timed out after {timeout} seconds.',
176+
$this->log()->warning(
177+
'Waited \'{timeout}\' seconds, giving up waiting for workflow to finish',
176178
['timeout' => $maxWaitInSeconds]
177179
);
180+
return;
178181
}
179182
$workflow->fetch();
180183
usleep($retry_interval * 1000);
@@ -226,10 +229,11 @@ protected function waitForCommit(
226229

227230
// Check timeout
228231
if ($end_time > 0 && $current_time >= $end_time) {
229-
throw new TerminusException(
230-
'Workflow with commit {commit} timed out after {timeout} seconds.',
232+
$this->log()->warning(
233+
'Waited \'{timeout}\' seconds, giving up waiting for workflow with commit {commit} to finish',
231234
['commit' => $target_commit, 'timeout' => $maxWaitInSeconds]
232235
);
236+
return;
233237
}
234238

235239
// Fetch workflow logs using the logs/workflows endpoint
@@ -281,10 +285,11 @@ protected function waitForCommit(
281285

282286
$retry_count++;
283287
if ($retry_count >= $max_retries) {
284-
throw new TerminusException(
288+
$this->log()->warning(
285289
'Workflow with commit {commit} not found after {retries} attempts.',
286290
['commit' => $target_commit, 'retries' => $max_retries]
287291
);
292+
return;
288293
}
289294

290295
$this->log()->debug('Workflow not found, retrying... ({retry}/{max})', [
@@ -305,10 +310,11 @@ protected function waitForCommit(
305310
do {
306311
$current_time = time();
307312
if ($end_time > 0 && $current_time >= $end_time) {
308-
throw new TerminusException(
309-
'Workflow timed out after {timeout} seconds.',
313+
$this->log()->warning(
314+
'Waited \'{timeout}\' seconds, giving up waiting for workflow to finish',
310315
['timeout' => $maxWaitInSeconds]
311316
);
317+
return;
312318
}
313319

314320
// Re-fetch workflow logs to get updated status

0 commit comments

Comments
 (0)