Skip to content

Commit

Permalink
Merge pull request #172 from esmero/ISSUE-171
Browse files Browse the repository at this point in the history
ISSUE-171: Check for AMI existence. In case it was delete or exception log to DB
  • Loading branch information
DiegoPino authored Jun 26, 2023
2 parents 486cec3 + 70c71b0 commit d416edb
Showing 1 changed file with 42 additions and 21 deletions.
63 changes: 42 additions & 21 deletions src/Plugin/QueueWorker/IngestADOQueueWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -1120,37 +1120,58 @@ private function setStatus(string $status, \stdClass $data) {

$ami_set = $this->entityTypeManager->getStorage('ami_set_entity')
->load($set_id);
if ($ami_set->getStatus() != $status && $status!= amiSetEntity::STATUS_PROCESSING && !$finished) {
$ami_set->setStatus(
$status
);
$ami_set->save();
// Means the AMI set is gone.
if (!$ami_set) {
$message = $this->t('The original AMI Set ID @setid does not longer exist. Last known status was: @status ',[
'@setid' => $data->info['set_id'],
'@status' => $status ?? 'Unknown',
]);
$this->loggerFactory->get('ami')->warning($message ,[
'setid' => $data->info['set_id'] ?? NULL,
'time_submitted' => $data->info['time_submitted'] ?? '',
]);
}
elseif ($finished) {
if ($processed_set_status['errored'] == 0) {
$ami_set->setStatus(
amiSetEntity::STATUS_PROCESSED
);
}
elseif ($processed_set_status['errored'] == $processed_set_status['total']) {
else {
if ($ami_set->getStatus() != $status
&& $status != amiSetEntity::STATUS_PROCESSING
&& !$finished
) {
$ami_set->setStatus(
amiSetEntity::STATUS_FAILED
$status
);
$ami_set->save();
}
else {
$ami_set->setStatus(
amiSetEntity::STATUS_PROCESSED_WITH_ERRORS
);
elseif ($finished) {
if ($processed_set_status['errored'] == 0) {
$ami_set->setStatus(
amiSetEntity::STATUS_PROCESSED
);
}
elseif ($processed_set_status['errored']
== $processed_set_status['total']
) {
$ami_set->setStatus(
amiSetEntity::STATUS_FAILED
);
}
else {
$ami_set->setStatus(
amiSetEntity::STATUS_PROCESSED_WITH_ERRORS
);
}
$ami_set->save();
}
$ami_set->save();
}
}
}
catch (\Exception $exception) {
$message = $this->t('The original AMI Set ID @setid does not longer exist.',[
'@setid' => $data->info['set_id']
$message = $this->t('The original AMI Set ID @setid does not longer exist or some other uncaught error happened while setting the status: @e.',[
'@setid' => $data->info['set_id'],
'@e' => $exception->getMessage(),
]);
$this->loggerFactory->get('ami_file')->warning($message ,[
// Makes no sense to log to the AMI file logger anymore?
// Send to the global ami logger (DB)
$this->loggerFactory->get('ami')->warning($message ,[
'setid' => $data->info['set_id'] ?? NULL,
'time_submitted' => $data->info['time_submitted'] ?? '',
]);
Expand Down

0 comments on commit d416edb

Please sign in to comment.