Fix bugs
This commit is contained in:
parent
ab68bb4ea1
commit
8f363eae7a
|
@ -2561,17 +2561,6 @@ $collections = [
|
|||
'array' => false,
|
||||
'filters' => ['datetime'],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('endTime'),
|
||||
'type' => Database::VAR_DATETIME,
|
||||
'format' => '',
|
||||
'size' => 0,
|
||||
'signed' => false,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => ['datetime'],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('duration'),
|
||||
'type' => Database::VAR_INTEGER,
|
||||
|
|
|
@ -1197,7 +1197,7 @@ App::post('/v1/functions/:functionId/executions')
|
|||
variables: $vars,
|
||||
timeout: $function->getAttribute('timeout', 0),
|
||||
image: $runtime['image'],
|
||||
source: $build->getAttribute('outputPath', ''),
|
||||
source: $build->getAttribute('path', ''),
|
||||
entrypoint: $deployment->getAttribute('entrypoint', ''),
|
||||
);
|
||||
|
||||
|
|
|
@ -99,13 +99,13 @@ class BuildsV1 extends Worker
|
|||
'startTime' => $startTime,
|
||||
'deploymentId' => $deployment->getId(),
|
||||
'status' => 'processing',
|
||||
'outputPath' => '',
|
||||
'path' => '',
|
||||
'size' => 0,
|
||||
'runtime' => $function->getAttribute('runtime'),
|
||||
'source' => $deployment->getAttribute('path'),
|
||||
'sourceType' => $device,
|
||||
'stdout' => '',
|
||||
'stderr' => '',
|
||||
'endTime' => null,
|
||||
'duration' => 0
|
||||
]));
|
||||
$deployment->setAttribute('buildId', $buildId);
|
||||
|
@ -186,11 +186,8 @@ class BuildsV1 extends Worker
|
|||
]
|
||||
);
|
||||
|
||||
$endTime = new \DateTime();
|
||||
$endTime->setTimestamp($response['endTimeUnix']);
|
||||
|
||||
/** Update the build document */
|
||||
$build->setAttribute('endTime', DateTime::format($endTime));
|
||||
$build->setAttribute('startTime', DateTime::format((new \DateTime())->setTimestamp($response['startTime'])));
|
||||
$build->setAttribute('duration', \intval($response['duration']));
|
||||
$build->setAttribute('status', $response['status']);
|
||||
$build->setAttribute('path', $response['path']);
|
||||
|
@ -225,12 +222,13 @@ class BuildsV1 extends Worker
|
|||
} catch (\Throwable $th) {
|
||||
$endTime = DateTime::now();
|
||||
$interval = (new \DateTime($endTime))->diff(new \DateTime($startTime));
|
||||
$build->setAttribute('endTime', $endTime);
|
||||
|
||||
$build->setAttribute('duration', $interval->format('%s') + 0);
|
||||
$build->setAttribute('status', 'failed');
|
||||
$build->setAttribute('stderr', $th->getMessage());
|
||||
Console::error($th->getMessage());
|
||||
} finally {
|
||||
\var_dump($build);
|
||||
$build = $dbForProject->updateDocument('builds', $buildId, $build);
|
||||
|
||||
/**
|
||||
|
|
|
@ -486,10 +486,10 @@ class DeletesV1 extends Worker
|
|||
$this->deleteByGroup('builds', [
|
||||
Query::equal('deploymentId', [$deploymentId])
|
||||
], $dbForProject, function (Document $document) use ($storageBuilds, $deploymentId) {
|
||||
if ($storageBuilds->delete($document->getAttribute('outputPath', ''), true)) {
|
||||
Console::success('Deleted build files: ' . $document->getAttribute('outputPath', ''));
|
||||
if ($storageBuilds->delete($document->getAttribute('path', ''), true)) {
|
||||
Console::success('Deleted build files: ' . $document->getAttribute('path', ''));
|
||||
} else {
|
||||
Console::error('Failed to delete build files: ' . $document->getAttribute('outputPath', ''));
|
||||
Console::error('Failed to delete build files: ' . $document->getAttribute('path', ''));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -535,10 +535,10 @@ class DeletesV1 extends Worker
|
|||
$this->deleteByGroup('builds', [
|
||||
Query::equal('deploymentId', [$deploymentId])
|
||||
], $dbForProject, function (Document $document) use ($storageBuilds) {
|
||||
if ($storageBuilds->delete($document->getAttribute('outputPath', ''), true)) {
|
||||
Console::success('Deleted build files: ' . $document->getAttribute('outputPath', ''));
|
||||
if ($storageBuilds->delete($document->getAttribute('path', ''), true)) {
|
||||
Console::success('Deleted build files: ' . $document->getAttribute('path', ''));
|
||||
} else {
|
||||
Console::error('Failed to delete build files: ' . $document->getAttribute('outputPath', ''));
|
||||
Console::error('Failed to delete build files: ' . $document->getAttribute('path', ''));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ Server::setResource('execute', function () {
|
|||
variables: $vars,
|
||||
timeout: $function->getAttribute('timeout', 0),
|
||||
image: $runtime['image'],
|
||||
source: $build->getAttribute('outputPath', ''),
|
||||
source: $build->getAttribute('path', ''),
|
||||
entrypoint: $deployment->getAttribute('entrypoint', ''),
|
||||
);
|
||||
|
||||
|
|
|
@ -66,6 +66,16 @@ class V17 extends Migration
|
|||
} catch (\Throwable $th) {
|
||||
Console::warning("'size' from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
|
||||
try {
|
||||
/**
|
||||
* Delete 'endTime' attribute (use startTime+duration if needed)
|
||||
*/
|
||||
$this->projectDB->deleteAttribute($id, 'startTime');
|
||||
$this->createAttributeFromCollection($this->projectDB, $id, 'startTime');
|
||||
} catch (\Throwable $th) {
|
||||
Console::warning("'startTime' from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue