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