Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-171: Check for AMI existence. In case it was delete or exception log to DB #172

Merged
merged 1 commit into from
Jun 26, 2023
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
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