Added logger into repo connection
testing/ogcore-api/pipeline/head This commit looks good
Details
testing/ogcore-api/pipeline/head This commit looks good
Details
parent
627bf75468
commit
cd94a3065e
|
@ -52,6 +52,7 @@ abstract class AbstractOgRepositoryController extends AbstractController
|
|||
} catch (ClientExceptionInterface | ServerExceptionInterface $e) {
|
||||
$response = $e->getResponse();
|
||||
$content = json_decode($response->getContent(false), true);
|
||||
$this->logger->error($content);
|
||||
throw new HttpException($response->getStatusCode(), $content['error'] ?? 'An error occurred');
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, $e->getMessage());
|
||||
|
|
|
@ -40,6 +40,8 @@ class CreateAuxFilesAction extends AbstractOgRepositoryController
|
|||
]
|
||||
];
|
||||
|
||||
$this->logger->info('Creating aux files', ['image' => $data->getName()]);
|
||||
|
||||
$content = $this->createRequest('POST', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/images/torrentsum', $params);
|
||||
|
||||
$inputData = [
|
||||
|
@ -49,6 +51,8 @@ class CreateAuxFilesAction extends AbstractOgRepositoryController
|
|||
|
||||
$this->createService->__invoke($data->getClient(), CommandTypes::CREATE_IMAGE_AUX_FILE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
|
||||
|
||||
$this->logger->info('Aux files created successfully', ['image' => $data->getName()]);
|
||||
|
||||
$data->setStatus(ImageStatus::IN_PROGRESS);
|
||||
$this->entityManager->persist($data);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -54,10 +54,13 @@ class ExportAction extends AbstractOgRepositoryController
|
|||
$inputData = [
|
||||
'imageName' => $image->getName(),
|
||||
'imageUuid' => $image->getUuid(),
|
||||
'repositoryUuid' => $repository->getUuid(),
|
||||
];
|
||||
|
||||
$this->createService->__invoke($image->getClient(), CommandTypes::EXPORT_IMAGE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
|
||||
|
||||
$this->logger->info('Image exported successfully', ['image' => $image->getName()]);
|
||||
|
||||
$image->setStatus(ImageStatus::TRANSFERING);
|
||||
$this->entityManager->persist($image);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -47,15 +47,20 @@ class ImportAction extends AbstractOgRepositoryController
|
|||
]
|
||||
];
|
||||
|
||||
$this->logger->info('Importing image', ['image' => $image->getName(), 'repository' => $repository->getIp()]);
|
||||
|
||||
$content = $this->createRequest('POST', 'http://'.$image->getRepository()->getIp().':8006/ogrepository/v1/repo/images', $params);
|
||||
|
||||
$inputData = [
|
||||
'imageName' => $image->getName(),
|
||||
'imageUuid' => $image->getUuid(),
|
||||
'repositoryUuid' => $repository->getUuid(),
|
||||
];
|
||||
|
||||
$this->createService->__invoke($image->getClient(), CommandTypes::IMPORT_IMAGE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
|
||||
|
||||
$this->logger->info('Image imported successfully', ['image' => $image->getName()]);
|
||||
|
||||
$image->setStatus(ImageStatus::TRANSFERING);
|
||||
$this->entityManager->persist($image);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -39,9 +39,12 @@ class RecoverAction extends AbstractOgRepositoryController
|
|||
]
|
||||
];
|
||||
|
||||
$this->logger->info('Recovering image', ['image' => $data->getName()]);
|
||||
|
||||
$content = $this->createRequest('POST', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/trash/images', $params);
|
||||
|
||||
$this->logger->info('Image recovered successfully', ['image' => $data->getName()]);
|
||||
|
||||
$data->setStatus(ImageStatus::SUCCESS);
|
||||
$this->entityManager->persist($data);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Controller\OgRepository\Webhook;
|
||||
|
||||
use App\Entity\Image;
|
||||
use App\Entity\ImageRepository;
|
||||
use App\Entity\Trace;
|
||||
use App\Model\ImageStatus;
|
||||
use App\Model\TraceStatus;
|
||||
|
@ -83,9 +84,11 @@ class ResponseController extends AbstractController
|
|||
$trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]);
|
||||
|
||||
$imageUuid = $trace->getInput()['imageUuid'];
|
||||
|
||||
$image = $this->entityManager->getRepository(Image::class)->findOneBy(['uuid' => $imageUuid]);
|
||||
|
||||
$repositoryUuid = $trace->getInput()['repositoryUuid'];
|
||||
$repository = $this->entityManager->getRepository(ImageRepository::class)->findOneBy(['uuid' => $repositoryUuid]);
|
||||
|
||||
if ($image === null) {
|
||||
$trace->setStatus(TraceStatus::FAILED);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
|
@ -99,6 +102,7 @@ class ResponseController extends AbstractController
|
|||
|
||||
$this->logger->info('Image exported', ['image' => $image->getName()]);
|
||||
|
||||
$image->setRepository($repository);
|
||||
$image->setStatus(ImageStatus::SUCCESS);
|
||||
$this->entityManager->persist($image);
|
||||
|
||||
|
@ -115,9 +119,11 @@ class ResponseController extends AbstractController
|
|||
$trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]);
|
||||
|
||||
$imageUuid = $trace->getInput()['imageUuid'];
|
||||
|
||||
$image = $this->entityManager->getRepository(Image::class)->findOneBy(['uuid' => $imageUuid]);
|
||||
|
||||
$repositoryUuid = $trace->getInput()['repositoryUuid'];
|
||||
$repository = $this->entityManager->getRepository(ImageRepository::class)->findOneBy(['uuid' => $repositoryUuid]);
|
||||
|
||||
if ($image === null) {
|
||||
$trace->setStatus(TraceStatus::FAILED);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
|
@ -131,10 +137,10 @@ class ResponseController extends AbstractController
|
|||
|
||||
$this->logger->info('Image imported', ['image' => $image->getName()]);
|
||||
|
||||
$image->setRepository($repository);
|
||||
$image->setStatus(ImageStatus::SUCCESS);
|
||||
$this->entityManager->persist($image);
|
||||
|
||||
|
||||
$trace->setStatus(TraceStatus::SUCCESS);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
|
||||
|
|
Loading…
Reference in New Issue