Fix(agent-api): prevent duplicate traces due to webhook race condition for START_SCRIPT
parent
55ec37d024
commit
e2d1483134
|
|
@ -1,7 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## [1.9.1] - 2026-07-17
|
||||
## [1.9.2] - 2026-07-23
|
||||
|
||||
### Fixed
|
||||
- Webhook (`StatusController` y `RunScriptAction`): Solucionado un problema de condición de carrera al ejecutar scripts de forma no administrativa que creaba trazas duplicadas (una con estado Enviado y otra exitosa). El webhook `START_SCRIPT` ahora avanza correctamente el estado de la traza a `IN_PROGRESS` evitando conflictos con el proceso síncrono.
|
||||
|
||||
## [1.9.1] - 2026-07-17
|
||||
### Added
|
||||
- Webhook (`StatusController`): Procesa la configuración de discos, particiones y caché en la respuesta del payload de la tarea `EjecutarScript`, guardándola automáticamente en base de datos.
|
||||
- Perfil de usuario: Añadido campo de preferencia de idioma (`language`).
|
||||
|
|
|
|||
|
|
@ -161,11 +161,23 @@ class RunScriptAction extends AbstractOgAgentController
|
|||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
if ($existingTrace) {
|
||||
$this->updateExistingTrace($existingTrace, $jobId, $inputData, $client);
|
||||
// Check if START_SCRIPT webhook already created a trace for this job
|
||||
$webhookTrace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $jobId]);
|
||||
|
||||
if ($webhookTrace) {
|
||||
$webhookTrace->setInput($inputData);
|
||||
$this->entityManager->persist($webhookTrace);
|
||||
if ($existingTrace && $existingTrace->getId() !== $webhookTrace->getId()) {
|
||||
$this->entityManager->remove($existingTrace);
|
||||
}
|
||||
$this->entityManager->flush();
|
||||
} else {
|
||||
$status = ($this->isLinuxOrWindows($client) || $this->isLinuxOrWindowsSession($client)) ? TraceStatus::SENT : TraceStatus::IN_PROGRESS;
|
||||
$this->createService->__invoke($client, CommandTypes::RUN_SCRIPT, $status, $jobId, $inputData);
|
||||
if ($existingTrace) {
|
||||
$this->updateExistingTrace($existingTrace, $jobId, $inputData, $client);
|
||||
} else {
|
||||
$status = ($this->isLinuxOrWindows($client) || $this->isLinuxOrWindowsSession($client)) ? TraceStatus::SENT : TraceStatus::IN_PROGRESS;
|
||||
$this->createService->__invoke($client, CommandTypes::RUN_SCRIPT, $status, $jobId, $inputData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,6 +149,12 @@ class StatusController extends AbstractController
|
|||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
} else {
|
||||
if ($trace->getStatus() !== TraceStatus::SUCCESS && $trace->getStatus() !== TraceStatus::ERROR) {
|
||||
$trace->setStatus(TraceStatus::IN_PROGRESS);
|
||||
$this->entityManager->persist($trace);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue