Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/Commands/Workflow/WaitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ protected function waitForWorkflow(
do {
$current_time = time();
if ($maxNotFoundAttempts && $not_found_attempts === $maxNotFoundAttempts) {
throw new TerminusException(
$this->log()->warning(
"Attempted '{max}' times, giving up waiting for workflow to be found",
['max' => $maxNotFoundAttempts]
);
return;
}

// Check if the timeout has been reached and throw an exception if so.
// Check if the timeout has been reached and log warning if so.
if ($end_time > 0 && $current_time >= $end_time) {
throw new TerminusException(
'Workflow timed out after {timeout} seconds.',
$this->log()->warning(
'Waited \'{timeout}\' seconds, giving up waiting for workflow to finish',
['timeout' => $maxWaitInSeconds]
);
return;
}
$site = $this->getSiteById($site->id);
$workflows->reset();
Expand Down Expand Up @@ -171,10 +173,11 @@ protected function waitForWorkflow(
}
do {
if ($end_time > 0 && $current_time >= $end_time) {
throw new TerminusException(
'Workflow timed out after {timeout} seconds.',
$this->log()->warning(
'Waited \'{timeout}\' seconds, giving up waiting for workflow to finish',
['timeout' => $maxWaitInSeconds]
);
return;
}
$workflow->fetch();
usleep($retry_interval * 1000);
Expand Down Expand Up @@ -226,10 +229,11 @@ protected function waitForCommit(

// Check timeout
if ($end_time > 0 && $current_time >= $end_time) {
throw new TerminusException(
'Workflow with commit {commit} timed out after {timeout} seconds.',
$this->log()->warning(
'Waited \'{timeout}\' seconds, giving up waiting for workflow with commit {commit} to finish',
['commit' => $target_commit, 'timeout' => $maxWaitInSeconds]
);
return;
}

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

$retry_count++;
if ($retry_count >= $max_retries) {
throw new TerminusException(
$this->log()->warning(
'Workflow with commit {commit} not found after {retries} attempts.',
['commit' => $target_commit, 'retries' => $max_retries]
);
return;
}

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

// Re-fetch workflow logs to get updated status
Expand Down
Loading