Compare commits

..

No commits in common. "c12e521af4b9b38efeac2b7cebe7049e5438d132" and "54cbcef6cbf331df578e388788d76a759cf1eb73" have entirely different histories.

4 changed files with 34 additions and 97 deletions

View File

@ -1,9 +1,4 @@
# Changelog # Changelog
## [0.24.4] - 2025-09-21
### Fixed
- Se ha arreglado un error en el servicio de clonado de imagen cuando los equipos no estan conectados.
---
## [0.24.3] - 2025-09-16 ## [0.24.3] - 2025-09-16
### Fixed ### Fixed
- Se ha corregido un error a la hora de borrar un repositorio el cual tuviera imagenes. - Se ha corregido un error a la hora de borrar un repositorio el cual tuviera imagenes.

View File

@ -50,4 +50,10 @@ when@prod:
level: info level: info
formatter: App\Formatter\CustomLineFormatter formatter: App\Formatter\CustomLineFormatter
channels: ["!event"] channels: ["!event"]
deprecation:
type: stream
channels: [deprecation]
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: error
formatter: monolog.formatter.json

View File

@ -6,7 +6,6 @@ namespace App\Controller;
use ApiPlatform\Validator\ValidatorInterface; use ApiPlatform\Validator\ValidatorInterface;
use App\Dto\Input\DeployImageInput; use App\Dto\Input\DeployImageInput;
use App\Dto\Output\ClientOutput;
use App\Entity\Trace; use App\Entity\Trace;
use App\Model\ImageStatus; use App\Model\ImageStatus;
use App\Entity\ImageImageRepository; use App\Entity\ImageImageRepository;
@ -14,9 +13,7 @@ use App\Model\CommandTypes;
use App\Model\DeployMethodTypes; use App\Model\DeployMethodTypes;
use App\Model\TraceStatus; use App\Model\TraceStatus;
use App\Service\Trace\CreateService; use App\Service\Trace\CreateService;
use App\Repository\ClientRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -33,8 +30,6 @@ class DeployImageAction extends AbstractController
protected readonly HttpClientInterface $httpClient, protected readonly HttpClientInterface $httpClient,
protected readonly CreateService $createService, protected readonly CreateService $createService,
protected readonly ValidatorInterface $validator, protected readonly ValidatorInterface $validator,
protected readonly ClientRepository $clientRepository,
protected readonly LoggerInterface $logger,
public readonly \App\Controller\OgAgent\DeployImageAction $deployImageOgAgentAction, public readonly \App\Controller\OgAgent\DeployImageAction $deployImageOgAgentAction,
public readonly \App\Controller\OgRepository\Image\DeployImageAction $deployImageOgRepositoryAction, public readonly \App\Controller\OgRepository\Image\DeployImageAction $deployImageOgRepositoryAction,
) { ) {
@ -52,6 +47,7 @@ class DeployImageAction extends AbstractController
} }
$this->validator->validate($input); $this->validator->validate($input);
$clientJobs = []; $clientJobs = [];
if ($input->type === 'monolithic') { if ($input->type === 'monolithic') {
@ -61,7 +57,6 @@ class DeployImageAction extends AbstractController
return new JsonResponse(data: $clientJobs, status: Response::HTTP_OK); return new JsonResponse(data: $clientJobs, status: Response::HTTP_OK);
} }
private function handleMonolithicDeployment(DeployImageInput $input, ImageImageRepository $image, ?Trace $trace = null): array private function handleMonolithicDeployment(DeployImageInput $input, ImageImageRepository $image, ?Trace $trace = null): array
{ {
$clientJobs = []; $clientJobs = [];
@ -90,25 +85,11 @@ class DeployImageAction extends AbstractController
$clientJobs = []; $clientJobs = [];
foreach ($input->clients as $client) { foreach ($input->clients as $client) {
try { $inputData = $this->createInputData($input, $image, $client->getEntity());
$inputData = $this->createInputData($input, $image, $client->getEntity()); $jobId = $this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::UNICAST, $trace);
$jobId = $this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::UNICAST, $trace);
if ($jobId) {
if ($jobId) { $clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
$clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
}
} catch (\Exception $e) {
$this->logger->warning('Error deploying to client (unicast)', [
'client_uuid' => $client->getEntity()->getUuid(),
'error' => $e->getMessage()
]);
if ($input->queue) {
$inputData = $this->createInputData($input, $image, $client->getEntity());
$this->createService->__invoke($client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::PENDING, null, $inputData);
}
continue;
} }
} }
@ -120,42 +101,19 @@ class DeployImageAction extends AbstractController
$clientJobs = []; $clientJobs = [];
foreach ($input->clients as $client) { foreach ($input->clients as $client) {
$inputData = $this->createMulticastInputData($input, $image, $client->getEntity());
try { try {
$inputData = $this->createMulticastInputData($input, $image, $client->getEntity()); $this->deployImageOgRepositoryAction->__invoke($input, $image, $client->getEntity());
try {
$this->deployImageOgRepositoryAction->__invoke($input, $image, $client->getEntity());
} catch (\Exception $e) {
$this->logger->warning('Error with OgRepository for client (multicast)', [
'client_uuid' => $client->getEntity()->getUuid(),
'error' => $e->getMessage()
]);
if ($input->queue) {
$this->createService->__invoke($client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::PENDING, null, $inputData);
}
continue;
}
$jobId = $this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::MULTICAST, $trace);
if ($jobId) {
$clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
}
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->warning('Error deploying to client (multicast)', [
'client_uuid' => $client->getEntity()->getUuid(),
'error' => $e->getMessage()
]);
if ($input->queue) {
$inputData = $this->createMulticastInputData($input, $image, $client->getEntity());
$this->createService->__invoke($client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::PENDING, null, $inputData);
}
continue; continue;
} }
$jobId = $this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::MULTICAST, $trace);
if ($jobId) {
$clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
}
} }
return $clientJobs; return $clientJobs;
@ -166,45 +124,23 @@ class DeployImageAction extends AbstractController
$clientJobs = []; $clientJobs = [];
foreach ($input->clients as $client) { foreach ($input->clients as $client) {
$inputData = $this->createTorrentInputData($input, $image, $client->getEntity());
try { try {
$inputData = $this->createTorrentInputData($input, $image, $client->getEntity()); $response = $this->deployImageOgRepositoryAction->__invoke($input, $image, $client->getEntity(), $this->httpClient);
try { if (is_array($response) && isset($response['code']) && $response['code'] === 500) {
$response = $this->deployImageOgRepositoryAction->__invoke($input, $image, $client->getEntity(), $this->httpClient); throw new \Exception('Error del servidor OgRepository: ' . ($response['error'] ?? 'Error desconocido') . ' - ' . ($response['details'] ?? ''));
if (is_array($response) && isset($response['code']) && $response['code'] === 500) {
throw new \Exception('Error del servidor OgRepository: ' . ($response['error'] ?? 'Error desconocido') . ' - ' . ($response['details'] ?? ''));
}
} catch (\Exception $e) {
$this->logger->warning('Error with OgRepository for client (torrent)', [
'client_uuid' => $client->getEntity()->getUuid(),
'error' => $e->getMessage()
]);
if ($input->queue) {
$this->createService->__invoke($client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::PENDING, null, $inputData);
}
continue;
} }
$jobId = $this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::TORRENT, $trace);
if ($jobId) {
$clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
}
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->warning('Error deploying to client (torrent)', [ throw $e;
'client_uuid' => $client->getEntity()->getUuid(), }
'error' => $e->getMessage()
]); $jobId = $this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::TORRENT, $trace);
if ($input->queue) { if ($jobId) {
$inputData = $this->createTorrentInputData($input, $image, $client->getEntity()); $clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
$this->createService->__invoke($client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::PENDING, null, $inputData);
}
continue;
} }
} }

View File

@ -22,6 +22,6 @@ class CustomLineFormatter extends LineFormatter
'datetime' => $record['datetime']->format('Y-m-d H:i:s'), 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
]; ];
return json_encode($output, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); return json_encode($output, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . PHP_EOL;
} }
} }