Skip to content

Commit

Permalink
Merge pull request #27 from open-runtimes/fix-logging-label
Browse files Browse the repository at this point in the history
Feat: Improve logging label
  • Loading branch information
christyjacob4 authored Aug 8, 2023
2 parents 5ff44c2 + 54c9b22 commit 6bfcaad
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,15 @@ function removeAllRuntimes(Table $activeRuntimes, Pool $orchestrationPool): void
->inject('orchestration')
->inject('activeRuntimes')
->inject('response')
->action(function (string $runtimeId, string $image, string $entrypoint, string $source, string $destination, array $variables, array $commands, int $timeout, string $workdir, bool $remove, int $cpus, int $memory, Orchestration $orchestration, Table $activeRuntimes, Response $response) {
->inject('log')
->action(function (string $runtimeId, string $image, string $entrypoint, string $source, string $destination, array $variables, array $commands, int $timeout, string $workdir, bool $remove, int $cpus, int $memory, Orchestration $orchestration, Table $activeRuntimes, Response $response, Log $log) {
$activeRuntimeId = $runtimeId; // Used with Swoole table (key)
$runtimeId = System::getHostname() . '-' . $runtimeId; // Used in Docker (name)

$runtimeHostname = \uniqid();

$log->addTag('runtimeId', $activeRuntimeId);

if ($activeRuntimes->exists($activeRuntimeId)) {
if ($activeRuntimes->get($activeRuntimeId)['status'] == 'pending') {
throw new \Exception('A runtime with the same ID is already being created. Attempt a execution soon.', 500);
Expand Down Expand Up @@ -506,7 +509,7 @@ function removeAllRuntimes(Table $activeRuntimes, Pool $orchestrationPool): void
->action(function (string $runtimeId, Table $activeRuntimes, Response $response, Log $log) {
$activeRuntimeId = $runtimeId; // Used with Swoole table (key)

$log->addExtra('runtimeId', $activeRuntimeId);
$log->addTag('runtimeId', $activeRuntimeId);

if (!$activeRuntimes->exists($activeRuntimeId)) {
throw new Exception('Runtime not found', 404);
Expand All @@ -530,7 +533,7 @@ function removeAllRuntimes(Table $activeRuntimes, Pool $orchestrationPool): void
$activeRuntimeId = $runtimeId; // Used with Swoole table (key)
$runtimeId = System::getHostname() . '-' . $runtimeId; // Used in Docker (name)

$log->addExtra('runtimeId', $activeRuntimeId);
$log->addTag('runtimeId', $activeRuntimeId);

if (!$activeRuntimes->exists($activeRuntimeId)) {
throw new Exception('Runtime not found', 404);
Expand Down Expand Up @@ -565,7 +568,7 @@ function (string $runtimeId, string $payload, array $variables, int $timeout, st
$activeRuntimeId = $runtimeId; // Used with Swoole table (key)
$runtimeId = System::getHostname() . '-' . $runtimeId; // Used in Docker (name)

$log->addExtra('runtimeId', $activeRuntimeId);
$log->addTag('runtimeId', $activeRuntimeId);

$variables = \array_merge($variables, [
'INERNAL_EXECUTOR_HOSTNAME' => System::getHostname()
Expand Down

0 comments on commit 6bfcaad

Please sign in to comment.