Fix status webhook freezing and add TraceService finishedAt tracking
testing/ogcore-api/pipeline/pr-main Build queued... Details
ogcore-debian-package/pipeline/head This commit looks good Details
testing/ogcore-api/pipeline/head There was a failure building this commit Details

pull/128/head
Juan Manuel Bardallo 2026-09-03 14:03:16 +02:00
parent 3ab24ee3ef
commit 3aa0861b84
3 changed files with 46 additions and 29 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## [1.9.5] - 2026-09-03
### Fixed
- **Webhook (`StatusController`)**: Añadido mecanismo de protección para ignorar latidos (heartbeats) si el cliente está en los estados de transición `INITIALIZING` o `TURNING_OFF`. Esto evita el conocido error donde un latido residual marcaba permanentemente al cliente como `BUSY` (Rojo) en el momento del apagado o reinicio.
- **Trazas (`CreateService`)**: Corregido el cierre de trazas para que rellene automáticamente la "Hora de fin" (`finishedAt`) al procesar tareas inmediatas que entran con estado `SUCCESS` o `FAILED`.
## [1.9.4] - 2026-07-31
### Added

View File

@ -84,39 +84,47 @@ class StatusController extends AbstractController
if (isset($data['busy'])) {
$previousStatus = $client->getStatus();
if ($data['busy'] === true) {
$client->setStatus(ClientStatus::BUSY);
$this->logger->info('Heartbeat: client marked as busy', [
'ip' => $data['iph'], 'previous_status' => $previousStatus, 'st' => $data['st'] ?? null,
$protectedStatuses = [ClientStatus::INITIALIZING, ClientStatus::TURNING_OFF];
if (in_array($previousStatus, $protectedStatuses)) {
$this->logger->info('Heartbeat ignored because client is in a protected transitional state', [
'ip' => $data['iph'], 'current_status' => $previousStatus, 'busy' => $data['busy'], 'st' => $data['st'] ?? null,
]);
} elseif ($data['busy'] === false) {
$idleStatusMap = [
'OGL' => ClientStatus::OG_LIVE,
'LNX' => ClientStatus::LINUX,
'WIN' => ClientStatus::WINDOWS,
'OSX' => ClientStatus::MACOS,
];
if (isset($data['loggedin']) && $data['loggedin'] === true) {
} else {
if ($data['busy'] === true) {
$client->setStatus(ClientStatus::BUSY);
$this->logger->info('Heartbeat: client marked as busy', [
'ip' => $data['iph'], 'previous_status' => $previousStatus, 'st' => $data['st'] ?? null,
]);
} elseif ($data['busy'] === false) {
$idleStatusMap = [
'OGL' => ClientStatus::OG_LIVE,
'LNX' => ClientStatus::LINUX_SESSION,
'WIN' => ClientStatus::WINDOWS_SESSION,
'OSX' => ClientStatus::MACOS_SESSION,
'LNX' => ClientStatus::LINUX,
'WIN' => ClientStatus::WINDOWS,
'OSX' => ClientStatus::MACOS,
];
}
$newStatus = $idleStatusMap[$data['st'] ?? ''] ?? ClientStatus::OG_LIVE;
if ($previousStatus !== $newStatus) {
$client->setStatus($newStatus);
$this->logger->info('Heartbeat: client status updated based on ping OS', [
'ip' => $data['iph'], 'previous_status' => $previousStatus, 'new_status' => $newStatus, 'st' => $data['st'] ?? null,
]);
} else {
$this->logger->info('Heartbeat: no status change', [
'ip' => $data['iph'], 'current_status' => $previousStatus, 'busy' => $data['busy'], 'st' => $data['st'] ?? null,
]);
if (isset($data['loggedin']) && $data['loggedin'] === true) {
$idleStatusMap = [
'OGL' => ClientStatus::OG_LIVE,
'LNX' => ClientStatus::LINUX_SESSION,
'WIN' => ClientStatus::WINDOWS_SESSION,
'OSX' => ClientStatus::MACOS_SESSION,
];
}
$newStatus = $idleStatusMap[$data['st'] ?? ''] ?? ClientStatus::OG_LIVE;
if ($previousStatus !== $newStatus) {
$client->setStatus($newStatus);
$this->logger->info('Heartbeat: client status updated based on ping OS', [
'ip' => $data['iph'], 'previous_status' => $previousStatus, 'new_status' => $newStatus, 'st' => $data['st'] ?? null,
]);
} else {
$this->logger->info('Heartbeat: no status change', [
'ip' => $data['iph'], 'current_status' => $previousStatus, 'busy' => $data['busy'], 'st' => $data['st'] ?? null,
]);
}
}
}
}

View File

@ -23,6 +23,9 @@ readonly class CreateService
$trace->setStatus($status);
$trace->setJobId($jobId);
$trace->setExecutedAt(new \DateTime());
if ($status === \App\Model\TraceStatus::SUCCESS || $status === \App\Model\TraceStatus::FAILED) {
$trace->setFinishedAt(new \DateTime());
}
$trace->setInput($input);
$trace->setOutput($output);