From 7f9d6ae6769c21cc18a74c0b226df9923dc3fe40 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 15 May 2022 06:25:18 +0000 Subject: [PATCH 1/4] executor version in environment variable and using new runtimes --- Dockerfile | 1 + app/config/runtimes.php | 2 +- app/config/variables.php | 10 +++++++++- app/executor.php | 2 +- composer.json | 2 +- composer.lock | 14 ++++++++------ 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7f5df76148..d1d95506a2 100755 --- a/Dockerfile +++ b/Dockerfile @@ -187,6 +187,7 @@ ENV _APP_SERVER=swoole \ _APP_EXECUTOR_SECRET=a-random-secret \ _APP_EXECUTOR_HOST=http://appwrite-executor/v1 \ _APP_EXECUTOR_RUNTIME_NETWORK=appwrite_runtimes \ + _APP_EXECUTOR_VERSION=v1 \ _APP_SETUP=self-hosted \ _APP_VERSION=$VERSION \ _APP_USAGE_STATS=enabled \ diff --git a/app/config/runtimes.php b/app/config/runtimes.php index 294c346e29..9bdb4d1dd3 100644 --- a/app/config/runtimes.php +++ b/app/config/runtimes.php @@ -6,7 +6,7 @@ use Appwrite\Runtimes\Runtimes; /** * List of Appwrite Cloud Functions supported runtimes */ -$runtimes = new Runtimes(); +$runtimes = new Runtimes(App::getEnv('_APP_EXECUTOR_VERSION')); $allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES')); diff --git a/app/config/variables.php b/app/config/variables.php index 5449c9ba93..5f79ad5399 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -1,7 +1,6 @@ 'General', @@ -615,6 +614,15 @@ return [ 'question' => '', 'filter' => '' ], + [ + 'name' => '_APP_EXECUTOR_VERSION', + 'description' => 'Executor version', + 'introduction' => '0.14.0', + 'default' => 'v1', + 'required' => false, + 'question' => '', + 'filter' => '' + ], [ 'name' => '_APP_FUNCTIONS_ENVS', 'description' => 'Deprecated with 0.8.0, use \'_APP_FUNCTIONS_RUNTIMES\' instead!', diff --git a/app/executor.php b/app/executor.php index f37a7c4fbd..78c19859fb 100644 --- a/app/executor.php +++ b/app/executor.php @@ -584,7 +584,7 @@ $http->on('start', function ($http) { /** * Warmup: make sure images are ready to run fast 🚀 */ - $runtimes = new Runtimes(); + $runtimes = new Runtimes(App::getEnv('_APP_EXECUTOR_VERSION')); $allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES')); $runtimes = $runtimes->getAll(true, $allowList); foreach ($runtimes as $runtime) { diff --git a/composer.json b/composer.json index 71a810ac77..f576925303 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "ext-zlib": "*", "ext-sockets": "*", "appwrite/php-clamav": "1.1.*", - "appwrite/php-runtimes": "0.7.*", + "appwrite/php-runtimes": "dev-feat-runtime-versioning", "utopia-php/framework": "0.19.*", "utopia-php/logger": "0.3.*", "utopia-php/abuse": "0.7.*", diff --git a/composer.lock b/composer.lock index 7ca6be00d3..7c3e9a27a9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "23a43ddfd26689ff154463410f7da3a4", + "content-hash": "b4d24566e38e481c9b5612033101324f", "packages": [ { "name": "adhocore/jwt", @@ -115,11 +115,11 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.7.4", + "version": "dev-feat-runtime-versioning", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "8e0972ecce6ad96f3701edab8d2c9a8af7074093" + "reference": "3c47c09c0781434f5aba726f726c695f144917b1" }, "require": { "php": ">=8.0", @@ -154,7 +154,7 @@ "php", "runtimes" ], - "time": "2022-02-26T11:38:09+00:00" + "time": "2022-05-15T03:00:16+00:00" }, { "name": "chillerlan/php-qrcode", @@ -6554,7 +6554,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "appwrite/php-runtimes": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -6576,5 +6578,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } From 52a03b4a3213543f75922828375a14314e3bae4e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 15 May 2022 13:16:37 +0545 Subject: [PATCH 2/4] Update app/config/runtimes.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matej Bačo --- app/config/runtimes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/runtimes.php b/app/config/runtimes.php index 9bdb4d1dd3..83eea55e4b 100644 --- a/app/config/runtimes.php +++ b/app/config/runtimes.php @@ -6,7 +6,7 @@ use Appwrite\Runtimes\Runtimes; /** * List of Appwrite Cloud Functions supported runtimes */ -$runtimes = new Runtimes(App::getEnv('_APP_EXECUTOR_VERSION')); +$runtimes = new Runtimes(App::getEnv('_APP_EXECUTOR_VERSION', 'v1')); $allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES')); From b466ad7fa6a3aca8e7c557d70121fd7c1f481dce Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 15 May 2022 13:22:21 +0545 Subject: [PATCH 3/4] Update app/executor.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matej Bačo --- app/executor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/executor.php b/app/executor.php index 78c19859fb..a594732f01 100644 --- a/app/executor.php +++ b/app/executor.php @@ -584,7 +584,7 @@ $http->on('start', function ($http) { /** * Warmup: make sure images are ready to run fast 🚀 */ - $runtimes = new Runtimes(App::getEnv('_APP_EXECUTOR_VERSION')); + $runtimes = new Runtimes(App::getEnv('_APP_EXECUTOR_VERSION', 'v1')); $allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES')); $runtimes = $runtimes->getAll(true, $allowList); foreach ($runtimes as $runtime) { From 046c75465cf2334c196b20ee2e39e37368f1c817 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 16 May 2022 15:05:58 +0200 Subject: [PATCH 4/4] fix: new runtimes --- Dockerfile | 1 - app/config/runtimes.php | 2 +- app/config/variables.php | 9 ------ app/executor.php | 4 +-- app/tasks/maintenance.php | 2 +- composer.json | 2 +- composer.lock | 28 +++++++++---------- .../Functions/FunctionsCustomServerTest.php | 5 ++-- 8 files changed, 21 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index d1d95506a2..7f5df76148 100755 --- a/Dockerfile +++ b/Dockerfile @@ -187,7 +187,6 @@ ENV _APP_SERVER=swoole \ _APP_EXECUTOR_SECRET=a-random-secret \ _APP_EXECUTOR_HOST=http://appwrite-executor/v1 \ _APP_EXECUTOR_RUNTIME_NETWORK=appwrite_runtimes \ - _APP_EXECUTOR_VERSION=v1 \ _APP_SETUP=self-hosted \ _APP_VERSION=$VERSION \ _APP_USAGE_STATS=enabled \ diff --git a/app/config/runtimes.php b/app/config/runtimes.php index 83eea55e4b..9002016aa0 100644 --- a/app/config/runtimes.php +++ b/app/config/runtimes.php @@ -6,7 +6,7 @@ use Appwrite\Runtimes\Runtimes; /** * List of Appwrite Cloud Functions supported runtimes */ -$runtimes = new Runtimes(App::getEnv('_APP_EXECUTOR_VERSION', 'v1')); +$runtimes = new Runtimes('v1'); $allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES')); diff --git a/app/config/variables.php b/app/config/variables.php index 5f79ad5399..49f2d7cfee 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -614,15 +614,6 @@ return [ 'question' => '', 'filter' => '' ], - [ - 'name' => '_APP_EXECUTOR_VERSION', - 'description' => 'Executor version', - 'introduction' => '0.14.0', - 'default' => 'v1', - 'required' => false, - 'question' => '', - 'filter' => '' - ], [ 'name' => '_APP_FUNCTIONS_ENVS', 'description' => 'Deprecated with 0.8.0, use \'_APP_FUNCTIONS_RUNTIMES\' instead!', diff --git a/app/executor.php b/app/executor.php index a594732f01..2e957c624c 100644 --- a/app/executor.php +++ b/app/executor.php @@ -580,11 +580,11 @@ App::init(function ($request, $response) { $http->on('start', function ($http) { global $orchestrationPool; global $activeRuntimes; - + /** * Warmup: make sure images are ready to run fast 🚀 */ - $runtimes = new Runtimes(App::getEnv('_APP_EXECUTOR_VERSION', 'v1')); + $runtimes = new Runtimes('v1'); $allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES')); $runtimes = $runtimes->getAll(true, $allowList); foreach ($runtimes as $runtime) { diff --git a/app/tasks/maintenance.php b/app/tasks/maintenance.php index 6ba744fde0..6bc06584e6 100644 --- a/app/tasks/maintenance.php +++ b/app/tasks/maintenance.php @@ -28,7 +28,7 @@ function getConsoleDB(): Database $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); $database->setNamespace('_console'); // Main DB - if (!$database->exists($database->getDefaultDatabase(), '_metadata')) { + if (!$database->exists($database->getDefaultDatabase(), 'certificates')) { throw new \Exception('Console project not ready'); } diff --git a/composer.json b/composer.json index f576925303..320cfdcfda 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "ext-zlib": "*", "ext-sockets": "*", "appwrite/php-clamav": "1.1.*", - "appwrite/php-runtimes": "dev-feat-runtime-versioning", + "appwrite/php-runtimes": "0.9.*", "utopia-php/framework": "0.19.*", "utopia-php/logger": "0.3.*", "utopia-php/abuse": "0.7.*", diff --git a/composer.lock b/composer.lock index 7c3e9a27a9..6094604345 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b4d24566e38e481c9b5612033101324f", + "content-hash": "9aecfa40a8ee2573bcbcac04edc46b88", "packages": [ { "name": "adhocore/jwt", @@ -115,11 +115,11 @@ }, { "name": "appwrite/php-runtimes", - "version": "dev-feat-runtime-versioning", + "version": "0.9.0", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "3c47c09c0781434f5aba726f726c695f144917b1" + "reference": "e8aa94aa42f45711e11cb1da401b442ecc2c32a4" }, "require": { "php": ">=8.0", @@ -154,7 +154,7 @@ "php", "runtimes" ], - "time": "2022-05-15T03:00:16+00:00" + "time": "2022-05-16T10:54:14+00:00" }, { "name": "chillerlan/php-qrcode", @@ -6320,16 +6320,16 @@ }, { "name": "twig/twig", - "version": "v3.3.10", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "8442df056c51b706793adf80a9fd363406dd3674" + "reference": "ed19f4bf9d19c4ef920b5d8243910bd32e85b9ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/8442df056c51b706793adf80a9fd363406dd3674", - "reference": "8442df056c51b706793adf80a9fd363406dd3674", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/ed19f4bf9d19c4ef920b5d8243910bd32e85b9ba", + "reference": "ed19f4bf9d19c4ef920b5d8243910bd32e85b9ba", "shasum": "" }, "require": { @@ -6344,7 +6344,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -6380,7 +6380,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.3.10" + "source": "https://github.com/twigphp/Twig/tree/v3.4.0" }, "funding": [ { @@ -6392,7 +6392,7 @@ "type": "tidelift" } ], - "time": "2022-04-06T06:47:41+00:00" + "time": "2022-05-15T06:25:28+00:00" }, { "name": "vimeo/psalm", @@ -6554,9 +6554,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "appwrite/php-runtimes": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -6578,5 +6576,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.1.0" } diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 6ca06fa120..307a634393 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -764,11 +764,12 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals($executions['body']['executions'][0]['status'], 'failed'); $this->assertEquals($executions['body']['executions'][0]['statusCode'], 500); $this->assertGreaterThan(2, $executions['body']['executions'][0]['time']); - $this->assertLessThan(6, $executions['body']['executions'][0]['time']); + $this->assertLessThan(7, $executions['body']['executions'][0]['time']); + $this->assertGreaterThan(5, $executions['body']['executions'][0]['time']); $this->assertEquals($executions['body']['executions'][0]['response'], ''); $this->assertEquals($executions['body']['executions'][0]['stderr'], 'An internal curl error has occurred within the executor! Error Msg: Operation timed out'); - // Cleanup : Delete function + // Cleanup : Delete function $response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'],