From c4c260f3cfef885d5f6bde3b4a1eaefabe4544c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 2 Jan 2026 16:34:05 +0100 Subject: [PATCH] Add dual read for specs --- app/controllers/general.php | 3 ++- .../Platform/Modules/Functions/Http/Executions/Create.php | 3 ++- .../Platform/Modules/Functions/Http/Functions/Update.php | 6 ++++-- src/Appwrite/Platform/Modules/Functions/Workers/Builds.php | 6 ++++-- src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php | 6 ++++-- src/Appwrite/Platform/Workers/Functions.php | 3 ++- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 5f1181ba6b..fe5c10c99f 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -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, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php index ca28774fbc..9054c41c84 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php @@ -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; diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php index f0b5420b57..643b946cca 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php @@ -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; } diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 73334b34ed..4b906f1409 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -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': diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index b14baa2de1..37e97c0fdb 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -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; } diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index 39d522ac04..d981059c3b 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -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);