From 44ddbd526f231f4fcb2db5cd6215793e8d4de06c Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Tue, 9 Sep 2025 19:20:21 +0200 Subject: [PATCH 1/2] refs #2768. Partition bug fixed --- config/api_platform/CommandTaskScript.yaml | 3 +++ config/api_platform/Trace.yaml | 2 +- src/Command/ExecutePendingTracesCommand.php | 21 +++++++++++++++------ src/Controller/OgAgent/KillJobAction.php | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/config/api_platform/CommandTaskScript.yaml b/config/api_platform/CommandTaskScript.yaml index cadc386..e14c69c 100644 --- a/config/api_platform/CommandTaskScript.yaml +++ b/config/api_platform/CommandTaskScript.yaml @@ -24,6 +24,9 @@ resources: ApiPlatform\Metadata\Post: ~ ApiPlatform\Metadata\Delete: ~ + order: + executionOrder: ASC + properties: App\Entity\CommandTaskScript: id: diff --git a/config/api_platform/Trace.yaml b/config/api_platform/Trace.yaml index 84f72b5..218c9e4 100644 --- a/config/api_platform/Trace.yaml +++ b/config/api_platform/Trace.yaml @@ -51,7 +51,7 @@ resources: uriTemplate: /traces/{uuid}/mark-as-success order: - createdAt: DESC + id: DESC properties: App\Entity\Trace: diff --git a/src/Command/ExecutePendingTracesCommand.php b/src/Command/ExecutePendingTracesCommand.php index 36665be..de96a1d 100644 --- a/src/Command/ExecutePendingTracesCommand.php +++ b/src/Command/ExecutePendingTracesCommand.php @@ -17,6 +17,7 @@ use App\Dto\Input\BootClientsInput; use App\Dto\Output\ClientOutput; use App\Dto\Output\PartitionOutput; use App\Entity\Client; +use App\Model\ClientStatus; use App\Entity\Image; use App\Entity\ImageImageRepository; use App\Entity\Partition; @@ -125,6 +126,10 @@ class ExecutePendingTracesCommand extends Command throw new \Exception("No client associated with trace"); } + if ($client->getStatus() === ClientStatus::BUSY) { + throw new \Exception("Client is busy"); + } + $trace->setExecutedAt(new \DateTime()); $this->entityManager->persist($trace); $this->entityManager->flush(); @@ -277,7 +282,7 @@ class ExecutePendingTracesCommand extends Command existingTrace: $trace ); - if ($response->getStatusCode() === 200) { + if (json_decode($response->getContent(), true)['status'] === 200) { $trace->setStatus(TraceStatus::IN_PROGRESS); $trace->setFinishedAt(new \DateTime()); $this->entityManager->persist($trace); @@ -359,7 +364,7 @@ class ExecutePendingTracesCommand extends Command $partitionInputObj->diskNumber = $item['diskNumber']; $partitionInputObj->partitionNumber = (int)$item['partitionNumber']; $partitionInputObj->partitionCode = $item['partitionCode'] ?? 'LINUX'; - $partitionInputObj->size = (float)($item['size'] / 1024); + $partitionInputObj->size = $item['size']; $partitionInputObj->filesystem = $item['filesystem'] ?? 'EXT4'; $partitionInputObj->format = ($item['format'] ?? '0') === '1'; $partitions[] = $partitionInputObj; @@ -376,7 +381,7 @@ class ExecutePendingTracesCommand extends Command try { $response = $this->partitionAssistantAction->__invoke($partitionInput, $trace); - if ($response->getStatusCode() === 200) { + if (json_decode($response->getContent(), true)['status'] === 200) { $trace->setStatus(TraceStatus::SUCCESS); $trace->setFinishedAt(new \DateTime()); $this->entityManager->persist($trace); @@ -412,7 +417,7 @@ class ExecutePendingTracesCommand extends Command try { $response = $this->runScriptAction->__invoke($commandExecuteInput, $trace); - if ($response->getStatusCode() === 200) { + if (json_decode($response->getContent(), true)['status'] === 200) { $trace->setStatus(TraceStatus::SUCCESS); $trace->setFinishedAt(new \DateTime()); $this->entityManager->persist($trace); @@ -422,7 +427,11 @@ class ExecutePendingTracesCommand extends Command return false; } catch (\Exception $e) { - + $this->logger->error('Error executing run script', [ + 'input' => $commandExecuteInput, + 'client' => $client->getUuid(), + 'error' => $e->getMessage() + ]); return false; } } @@ -447,7 +456,7 @@ class ExecutePendingTracesCommand extends Command try { $response = $this->rebootAction->__invoke($multipleClientsInput); - if ($response->getStatusCode() === 200) { + if (json_decode($response->getContent(), true)['status'] === 200) { $trace->setStatus(TraceStatus::SUCCESS); $trace->setFinishedAt(new \DateTime()); $this->entityManager->persist($trace); diff --git a/src/Controller/OgAgent/KillJobAction.php b/src/Controller/OgAgent/KillJobAction.php index 2877cce..c218c47 100644 --- a/src/Controller/OgAgent/KillJobAction.php +++ b/src/Controller/OgAgent/KillJobAction.php @@ -64,7 +64,7 @@ class KillJobAction extends AbstractOgAgentController 'command' => $trace->getCommand(), ]; - $this->createService->__invoke($client, CommandTypes::KILL_JOB, TraceStatus::CANCELLED, $input->jobId, $inputData); + //$this->createService->__invoke($client, CommandTypes::KILL_JOB, TraceStatus::CANCELLED, $input->jobId, $inputData); return new JsonResponse(data: $trace, status: Response::HTTP_OK); } From 1d6c0a86961c9ab5d307724febeac7ff5d720ff5 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Tue, 9 Sep 2025 19:21:12 +0200 Subject: [PATCH 2/2] updated changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 418b6f2..cc7a055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +## [0.24.1] - 2025-09-09 +### Fixed +- Se ha corregido un error en la funcionalidad de Tareas programadas + +--- ## [0.24.0] - 2025-09-09 ### Added - Se ha aƱadido la funcionalidad/servicio para poder eliminar un repositorio GIT