Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Dec 31, 2024
1 parent 3278960 commit 0a772b3
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
if (!empty($rawParams['snap-id'])) {
$snapId = $rawParams['snap-id'];
}
// If the action is removeEnv, the environment has been removed, so it
// If the action is removeEnv, the environment has been removed, so it
if ($rawParams['action'] != 'removeEnv') {
if (!empty($rawParams['env-id'])) {
$envId = $rawParams['env-id'];
Expand Down
2 changes: 1 addition & 1 deletion www/controllers/Task/Log/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function completed(string $message = '') : void
/**
* Set the latest step as error
*/
public function error(string $message) : void
public function error(string $message = '') : void
{
/**
* Get latest step Id from database
Expand Down
28 changes: 28 additions & 0 deletions www/controllers/Task/Log/SubStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,34 @@ public function warning(string $message) : void
}
}

/**
* Set the latest sub-step as error
*/
public function error(string $message) : void
{
/**
* Get latest step Id
*/
$stepId = $this->stepController->getLatestStepId($this->taskId);

/**
* Get latest sub-step Id
*/
$substepId = $this->getLatestSubStepId($stepId);

/**
* Add error message to output
*/
$this->output($message, 'error');

/**
* If there was substeps, mark latest substep as error in database
*/
if (!empty($substepId)) {
$this->model->status($substepId, 'error');
}
}

/**
* Set the latest sub-step as stopped
*/
Expand Down
10 changes: 6 additions & 4 deletions www/controllers/Task/Repo/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ private function mirror()
$this->task->setStatus('done');
$this->task->updateStatus($this->task->getId(), 'done');
} catch (Exception $e) {
// Set step error message
$this->taskLogStepController->error($e->getMessage());
// Set sub step error message and mark step as error
$this->taskLogSubStepController->error($e->getMessage());
$this->taskLogStepController->error();

// Set task status to error
$this->task->setStatus('error');
Expand Down Expand Up @@ -373,8 +374,9 @@ private function local()
$this->task->setStatus('done');
$this->task->updateStatus($this->task->getId(), 'done');
} catch (Exception $e) {
// Set step error message
$this->taskLogStepController->error($e->getMessage());
// Set sub step error message and mark step as error
$this->taskLogSubStepController->error($e->getMessage());
$this->taskLogStepController->error();

// Set task status to error
$this->task->setStatus('error');
Expand Down
5 changes: 3 additions & 2 deletions www/controllers/Task/Repo/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ public function execute()
$this->task->setStatus('done');
$this->task->updateStatus($this->task->getId(), 'done');
} catch (Exception $e) {
// Set step error message
$this->taskLogStepController->error($e->getMessage());
// Set sub step error message and mark step as error
$this->taskLogSubStepController->error($e->getMessage());
$this->taskLogStepController->error();

// Set task status to error
$this->task->setStatus('error');
Expand Down
5 changes: 3 additions & 2 deletions www/controllers/Task/Repo/Duplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,9 @@ public function execute()
$this->task->setStatus('done');
$this->task->updateStatus($this->task->getId(), 'done');
} catch (Exception $e) {
// Set step error message
$this->taskLogStepController->error($e->getMessage());
// Set sub step error message and mark step as error
$this->taskLogSubStepController->error($e->getMessage());
$this->taskLogStepController->error();

// Set task status to error
$this->task->setStatus('error');
Expand Down
5 changes: 3 additions & 2 deletions www/controllers/Task/Repo/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,9 @@ public function execute()
$this->task->setStatus('done');
$this->task->updateStatus($this->task->getId(), 'done');
} catch (Exception $e) {
// Set step error message
$this->taskLogStepController->error($e->getMessage());
// Set sub step error message and mark step as error
$this->taskLogSubStepController->error($e->getMessage());
$this->taskLogStepController->error();

// Set task status to error
$this->task->setStatus('error');
Expand Down
5 changes: 3 additions & 2 deletions www/controllers/Task/Repo/Rebuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ public function execute()
$this->task->setStatus('done');
$this->task->updateStatus($this->task->getId(), 'done');
} catch (Exception $e) {
// Set snapshot metadata rebuild state in database
$this->repo->snapSetRebuild($this->repo->getSnapId(), 'failed');
// Set sub step error message and mark step as error
$this->taskLogSubStepController->error($e->getMessage());
$this->taskLogStepController->error();

// Set step error message
$this->taskLogStepController->error($e->getMessage());
Expand Down
5 changes: 3 additions & 2 deletions www/controllers/Task/Repo/RemoveEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ public function execute()
$this->task->setStatus('done');
$this->task->updateStatus($this->task->getId(), 'done');
} catch (Exception $e) {
// Set step error message
$this->taskLogStepController->error($e->getMessage());
// Set sub step error message and mark step as error
$this->taskLogSubStepController->error($e->getMessage());
$this->taskLogStepController->error();

// Set task status to error
$this->task->setStatus('error');
Expand Down
5 changes: 3 additions & 2 deletions www/controllers/Task/Repo/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ public function execute()
$this->task->setStatus('done');
$this->task->updateStatus($this->task->getId(), 'done');
} catch (Exception $e) {
// Set step error message
$this->taskLogStepController->error($e->getMessage());
// Set sub step error message and mark step as error
$this->taskLogSubStepController->error($e->getMessage());
$this->taskLogStepController->error();

// Set task status to error
$this->task->setStatus('error');
Expand Down

0 comments on commit 0a772b3

Please sign in to comment.