feat: propogate errors in Executor
This commit is contained in:
parent
b6758c1262
commit
cef5264c48
|
@ -617,7 +617,7 @@ App::get('/v1/functions/:functionId/deployments')
|
||||||
$sum = $dbForProject->count('deployments', $queries, APP_LIMIT_COUNT);
|
$sum = $dbForProject->count('deployments', $queries, APP_LIMIT_COUNT);
|
||||||
|
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$build = $dbForProject->getDocument('builds', $result->getAttribute('buildId'));
|
$build = $dbForProject->getDocument('builds', $result->getAttribute('buildId', ''));
|
||||||
$result->setAttribute('status', $build->getAttribute('status', 'pending'));
|
$result->setAttribute('status', $build->getAttribute('status', 'pending'));
|
||||||
$result->setAttribute('buildStderr', $build->getAttribute('stderr', ''));
|
$result->setAttribute('buildStderr', $build->getAttribute('stderr', ''));
|
||||||
$result->setAttribute('buildStdout', $build->getAttribute('stdout', ''));
|
$result->setAttribute('buildStdout', $build->getAttribute('stdout', ''));
|
||||||
|
|
|
@ -136,6 +136,22 @@ class BuildsV1 extends Worker
|
||||||
$build->setAttribute('outputPath', $response['outputPath']);
|
$build->setAttribute('outputPath', $response['outputPath']);
|
||||||
$build->setAttribute('stderr', $response['stderr']);
|
$build->setAttribute('stderr', $response['stderr']);
|
||||||
$build->setAttribute('stdout', $response['stdout']);
|
$build->setAttribute('stdout', $response['stdout']);
|
||||||
|
|
||||||
|
Console::success("Build id: $buildId created");
|
||||||
|
|
||||||
|
/** Set auto deploy */
|
||||||
|
if ($deployment->getAttribute('activate') === true) {
|
||||||
|
$function->setAttribute('deployment', $deployment->getId());
|
||||||
|
$function = $dbForProject->updateDocument('functions', $functionId, $function);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Update function schedule */
|
||||||
|
$schedule = $function->getAttribute('schedule', '');
|
||||||
|
$cron = (empty($function->getAttribute('deployment')) && !empty($schedule)) ? new CronExpression($schedule) : null;
|
||||||
|
$next = (empty($function->getAttribute('deployment')) && !empty($schedule)) ? $cron->getNextRunDate()->format('U') : 0;
|
||||||
|
$function->setAttribute('scheduleNext', (int)$next);
|
||||||
|
$function = $dbForProject->updateDocument('functions', $functionId, $function);
|
||||||
|
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$endtime = \time();
|
$endtime = \time();
|
||||||
$build->setAttribute('endTime', $endtime);
|
$build->setAttribute('endTime', $endtime);
|
||||||
|
@ -143,24 +159,9 @@ class BuildsV1 extends Worker
|
||||||
$build->setAttribute('status', 'failed');
|
$build->setAttribute('status', 'failed');
|
||||||
$build->setAttribute('stderr', $th->getMessage());
|
$build->setAttribute('stderr', $th->getMessage());
|
||||||
Console::error($th->getMessage());
|
Console::error($th->getMessage());
|
||||||
|
} finally {
|
||||||
|
$build = $dbForProject->updateDocument('builds', $buildId, $build);
|
||||||
}
|
}
|
||||||
|
|
||||||
$build = $dbForProject->updateDocument('builds', $buildId, $build);
|
|
||||||
|
|
||||||
/** Set auto deploy */
|
|
||||||
if ($deployment->getAttribute('activate') === true) {
|
|
||||||
$function->setAttribute('deployment', $deployment->getId());
|
|
||||||
$function = $dbForProject->updateDocument('functions', $functionId, $function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Update function schedule */
|
|
||||||
$schedule = $function->getAttribute('schedule', '');
|
|
||||||
$cron = (empty($function->getAttribute('deployment')) && !empty($schedule)) ? new CronExpression($schedule) : null;
|
|
||||||
$next = (empty($function->getAttribute('deployment')) && !empty($schedule)) ? $cron->getNextRunDate()->format('U') : 0;
|
|
||||||
$function->setAttribute('scheduleNext', (int)$next);
|
|
||||||
$function = $dbForProject->updateDocument('functions', $functionId, $function);
|
|
||||||
|
|
||||||
Console::success("Build id: $buildId created");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shutdown(): void {}
|
public function shutdown(): void {}
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Executor
|
||||||
|
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
if ($status >= 400) {
|
if ($status >= 400) {
|
||||||
throw new \Exception($response['body'], $status);
|
throw new \Exception($response['body']['message'], $status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response['body'];
|
return $response['body'];
|
||||||
|
@ -80,7 +80,7 @@ class Executor
|
||||||
|
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
if ($status >= 400) {
|
if ($status >= 400) {
|
||||||
throw new \Exception('Error deleting deployment: ' . $deploymentId , $status);
|
throw new \Exception($response['body']['message'], $status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response['body'];
|
return $response['body'];
|
||||||
|
@ -120,7 +120,7 @@ class Executor
|
||||||
|
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
if ($status >= 400) {
|
if ($status >= 400) {
|
||||||
throw new \Exception('Error creating execution: ', $status);
|
throw new \Exception($response['body']['message'], $status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response['body'];
|
return $response['body'];
|
||||||
|
|
Loading…
Reference in a new issue