Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions app/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,7 @@ function (string $runtimeId, string $payload, array $variables, int $timeout, st

// No error
if ($errNo === 0) {
// TODO: @Meldiron This shoudl retry as well
if ($statusCode >= 400) {
if ($statusCode >= 400 && $i === 4) {
$body = \json_decode($error, true);
throw new Exception('An internal curl error has occurred while starting runtime! Error Msg: ' . ($body['message'] ?? $error), 500);
}
Expand Down Expand Up @@ -767,21 +766,27 @@ function (string $runtimeId, string $payload, array $variables, int $timeout, st

batch([
function () use (&$output) {
$output['hostUsage'] = System::getCPUUsage(5);
$output['usage'] = System::getCPUUsage(5);
},
function () use (&$output, $orchestration) {
$functionsUsage = [];
$runtimes = [];

$containerUsages = $orchestration->getStats(
filters: [ 'label' => 'openruntimes-executor=' . System::getHostname() ],
cycles: 3
);

foreach ($containerUsages as $containerUsage) {
$functionsUsage[$containerUsage['name']] = $containerUsage['cpu'] * 100;
$hostnameArr = \explode('-', $containerUsage['name']);
\array_shift($hostnameArr);
$hostname = \implode('-', $hostnameArr);
$runtimes[$hostname] = [
'status' => 'pass',
'usage' => $containerUsage['cpu'] * 100
];
}

$output['functionsUsage'] = $functionsUsage;
$output['runtimes'] = $runtimes;
}
]);

Expand Down
1 change: 1 addition & 0 deletions tests/ExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Utopia\CLI\Console;

// TODO: @Meldiron Write more tests (validators mainly)
// TODO: @Meldiron Health API tests

final class ExecutorTest extends TestCase
{
Expand Down