Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: retry and uniqid #127

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Changes from 4 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
25 changes: 15 additions & 10 deletions app/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ function cleanUp(Orchestration $orchestration, Table $activeRuntimes, array $net
->action(function (string $runtimeId, string $image, string $entrypoint, string $source, string $destination, string $outputDirectory, array $variables, string $runtimeEntrypoint, string $command, int $timeout, bool $remove, float $cpus, int $memory, string $version, string $restartPolicy, array $networks, Orchestration $orchestration, Table $activeRuntimes, Response $response, Log $log) {
$runtimeName = System::getHostname() . '-' . $runtimeId;

$runtimeHostname = \uniqid();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets check for more occurances, I think I saw multiplr

Copy link
Member Author

@loks0n loks0n Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one more usage in the build path name, but I don't think it's an issue with collision / or worth increasing the scope of this PR to address immediate function errors

$runtimeHostname = \bin2hex(\random_bytes(16));
christyjacob4 marked this conversation as resolved.
Show resolved Hide resolved

$log->addTag('image', $image);
$log->addTag('version', $version);
Expand Down Expand Up @@ -1272,23 +1272,28 @@ function (string $runtimeId, ?string $payload, string $path, string $method, mix

// Execute function
$executionRequest = $version === 'v4' ? $executeV4 : $executeV2;
$executionResponse = \call_user_func($executionRequest);
do {
$executionResponse = \call_user_func($executionRequest);
} while (
christyjacob4 marked this conversation as resolved.
Show resolved Hide resolved
\in_array($executionResponse['errNo'], [CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT]) &&
(\microtime(true) - $startTime < $timeout)
);

// Error occurred
if ($executionResponse['errNo'] !== CURLE_OK) {
$log->addExtra('activeRuntime', $activeRuntimes->get($runtimeName));
$log->addExtra('error', $executionResponse['error']);
$log->addTag('hostname', $hostname);

// Error occured
if ($executionResponse['errNo'] !== 0) {
// Intended timeout error for v2 functions
if ($executionResponse['errNo'] === 110 && $version === 'v2') {
if ($version === 'v2' && $executionResponse['errNo'] === SOCKET_ETIMEDOUT) {
throw new Exception($executionResponse['error'], 400);
}

$log->addExtra('error', $executionResponse['error']);
$log->addTag('hostname', $hostname);

throw new Exception('Internal curl errors has occurred within the executor! Error Number: ' . $executionResponse['errNo'], 500);
throw new Exception('Internal curl error has occurred within the executor! Error Number: ' . $executionResponse['errNo'], 500);
}

// Successful execution

['statusCode' => $statusCode, 'body' => $body, 'logs' => $logs, 'errors' => $errors, 'headers' => $headers] = $executionResponse;

$endTime = \microtime(true);
Expand Down
Loading