Add dual read for specs

This commit is contained in:
Matej Bačo
2026-01-02 16:34:05 +01:00
parent 87d6c73b7b
commit c4c260f3cf
6 changed files with 18 additions and 9 deletions
+2 -1
View File
@@ -309,7 +309,8 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw
};
$runtimes = Config::getParam($version === 'v2' ? 'runtimes-v2' : 'runtimes', []);
$spec = Config::getParam('specifications')[$resource->getAttribute('runtimeSpecification', APP_COMPUTE_SPECIFICATION_DEFAULT)];
// TODO: backwards-compatibility dual-read, remove eventually.
$spec = Config::getParam('specifications')[$resource->getAttribute('runtimeSpecification', $resource->getAttribute('specification', APP_COMPUTE_SPECIFICATION_DEFAULT))];
$runtime = match ($type) {
'function' => $runtimes[$resource->getAttribute('runtime')] ?? null,
@@ -172,7 +172,8 @@ class Create extends Base
$version = $function->getAttribute('version', 'v2');
$runtimes = Config::getParam($version === 'v2' ? 'runtimes-v2' : 'runtimes', []);
$spec = Config::getParam('specifications')[$function->getAttribute('runtimeSpecification', APP_COMPUTE_SPECIFICATION_DEFAULT)];
// TODO: backwards-compatibility dual-read, remove eventually.
$spec = Config::getParam('specifications')[$function->getAttribute('runtimeSpecification', $function->getAttribute('specification', APP_COMPUTE_SPECIFICATION_DEFAULT))];
$runtime = (isset($runtimes[$function->getAttribute('runtime', '')])) ? $runtimes[$function->getAttribute('runtime', '')] : null;
@@ -246,9 +246,11 @@ class Update extends Base
// Enforce Cold Start if spec limits change.
if (!empty($function->getAttribute('deploymentId'))) {
$specsChanged = false;
if ($function->getAttribute('runtimeSpecification') !== $runtimeSpecification) {
// TODO: backwards-compatibility dual-read, remove eventually.
if ($function->getAttribute('runtimeSpecification', $function->getAttribute('specification')) !== $runtimeSpecification) {
$specsChanged = true;
} elseif ($function->getAttribute('buildSpecification') !== $buildSpecification) {
// TODO: backwards-compatibility dual-read, remove eventually.
} elseif ($function->getAttribute('buildSpecification', $function->getAttribute('specification')) !== $buildSpecification) {
$specsChanged = true;
}
@@ -255,7 +255,8 @@ class Builds extends Action
$version = $this->getVersion($resource);
$runtime = $this->getRuntime($resource, $version);
$spec = Config::getParam('specifications')[$resource->getAttribute('buildSpecification', APP_COMPUTE_SPECIFICATION_DEFAULT)];
// TODO: backwards-compatibility dual-read, remove eventually.
$spec = Config::getParam('specifications')[$resource->getAttribute('buildSpecification', $resource->getAttribute('specification', APP_COMPUTE_SPECIFICATION_DEFAULT))];
if ($resource->getCollection() === 'functions' && \is_null($runtime)) {
throw new \Exception('Runtime "' . $resource->getAttribute('runtime', '') . '" is not supported');
@@ -1358,7 +1359,8 @@ class Builds extends Action
protected function sendUsage(Document $resource, Document $deployment, Document $project, StatsUsage $queue): void
{
$spec = Config::getParam('specifications')[$resource->getAttribute('buildSpecification', APP_COMPUTE_SPECIFICATION_DEFAULT)];
// TODO: backwards-compatibility dual-read, remove eventually.
$spec = Config::getParam('specifications')[$resource->getAttribute('buildSpecification', $resource->getAttribute('specification', APP_COMPUTE_SPECIFICATION_DEFAULT))];
switch ($deployment->getAttribute('status')) {
case 'ready':
@@ -247,9 +247,11 @@ class Update extends Base
if (!empty($site->getAttribute('deploymentId'))) {
$specsChanged = false;
if ($site->getAttribute('runtimeSpecification') !== $runtimeSpecification) {
// TODO: backwards-compatibility dual-read, remove eventually.
if ($site->getAttribute('runtimeSpecification', $site->getAttribute('specification')) !== $runtimeSpecification) {
$specsChanged = true;
} elseif ($site->getAttribute('buildSpecification') !== $buildSpecification) {
// TODO: backwards-compatibility dual-read, remove eventually.
} elseif ($site->getAttribute('buildSpecification', $site->getAttribute('specification')) !== $buildSpecification) {
$specsChanged = true;
}
+2 -1
View File
@@ -368,7 +368,8 @@ class Functions extends Action
$user ??= new Document();
$functionId = $function->getId();
$deploymentId = $function->getAttribute('deploymentId', '');
$spec = Config::getParam('specifications')[$function->getAttribute('runtimeSpecification', APP_COMPUTE_SPECIFICATION_DEFAULT)];
// TODO: backwards-compatibility dual-read, remove eventually.
$spec = Config::getParam('specifications')[$function->getAttribute('runtimeSpecification', $function->getAttribute('specification', APP_COMPUTE_SPECIFICATION_DEFAULT))];
$log->addTag('deploymentId', $deploymentId);