From d275fa0111e68a7ed2a16036070b5ebc91c5fd17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 8 Nov 2022 12:34:14 +0000 Subject: [PATCH] Fix tests --- .env | 16 ++++++------ app/controllers/api/functions.php | 1 - app/workers/builds.php | 1 - app/workers/functions.php | 1 - docker-compose.yml | 41 ++++++++++++++++--------------- src/Executor/Executor.php | 14 ++++++----- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/.env b/.env index 76d6f33c39..ad82b0b336 100644 --- a/.env +++ b/.env @@ -74,17 +74,17 @@ _APP_USAGE_STATS=enabled _APP_LOGGING_PROVIDER= _APP_LOGGING_CONFIG= _APP_EXECUTOR_SECRET=your-secret-key -_APP_EXECUTOR_HOST=http://proxy1/v1 -_APP_FUNCTIONS_RUNTIMES=php-8.0 +_APP_EXECUTOR_HOST=http://exc1/v1 +_APP_FUNCTIONS_RUNTIMES= OPR_EXECUTOR_CONNECTION_STORAGE=file://localhost -OPR_EXECUTOR_INACTIVE_TRESHOLD=60 +OPR_EXECUTOR_INACTIVE_TRESHOLD=600 OPR_EXECUTOR_NETWORK=openruntimes-runtimes OPR_EXECUTOR_DOCKER_HUB_USERNAME= OPR_EXECUTOR_DOCKER_HUB_PASSWORD= -OPR_PROXY_ALGORITHM=round-robin -OPR_PROXY_EXECUTORS=exc1 -OPR_PROXY_HEALTHCHECK=enabled -OPR_PROXY_HEALTHCHECK_INTERVAL=5000 -OPR_PROXY_EXECUTOR_SECRET=executor-secret-key \ No newline at end of file +# OPR_PROXY_ALGORITHM=round-robin +# OPR_PROXY_EXECUTORS=exc1 +# OPR_PROXY_HEALTHCHECK=enabled +# OPR_PROXY_HEALTHCHECK_INTERVAL=5000 +# OPR_PROXY_EXECUTOR_SECRET=your-secret-key \ No newline at end of file diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index ab7c96e450..07d593617a 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1153,7 +1153,6 @@ App::post('/v1/functions/:functionId/executions') payload: $data, variables: $vars, timeout: $function->getAttribute('timeout', 0), - image: $runtime['image'], source: $build->getAttribute('outputPath', ''), entrypoint: $deployment->getAttribute('entrypoint', ''), diff --git a/app/workers/builds.php b/app/workers/builds.php index af8e0e2717..ca7ed3550b 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -159,7 +159,6 @@ class BuildsV1 extends Worker source: $source, image: $runtime['image'], remove: true, - entrypoint: $deployment->getAttribute('entrypoint'), workdir: '/usr/code', destination: APP_STORAGE_BUILDS . "/app-{$project->getId()}", diff --git a/app/workers/functions.php b/app/workers/functions.php index c8da46a673..5e10eb5b48 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -292,7 +292,6 @@ class FunctionsV1 extends Worker payload: $vars['APPWRITE_FUNCTION_DATA'] ?? '', variables: $vars, timeout: $function->getAttribute('timeout', 0), - image: $runtime['image'], source: $build->getAttribute('outputPath', ''), entrypoint: $deployment->getAttribute('entrypoint', ''), diff --git a/docker-compose.yml b/docker-compose.yml index 757f142c4c..4d69eef059 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -633,8 +633,9 @@ services: stop_signal: SIGINT image: openruntimes/executor:0.1.0 networks: + - appwrite # Remove this when using OPR Proxy + # - openruntimes-executors - openruntimes-runtimes - - openruntimes-executors ports: - 9900:80 volumes: @@ -650,28 +651,28 @@ services: - OPR_EXECUTOR_DOCKER_HUB_PASSWORD - OPR_EXECUTOR_ENV=$_APP_ENV - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES - - OPR_EXECUTOR_SECRET=$OPR_PROXY_EXECUTOR_SECRET + - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET # If using OPR proxy, use OPR_PROXY_EXECUTOR_SECRET instead - OPR_EXECUTOR_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER - OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG - openruntimes-proxy: - container_name: openruntimes-proxy - hostname: proxy1 - <<: *x-logging - image: openruntimes/proxy:0.3.0 - networks: - - appwrite - - openruntimes-executors - environment: - - OPR_PROXY_ALGORITHM - - OPR_PROXY_EXECUTORS - - OPR_PROXY_HEALTHCHECK - - OPR_PROXY_HEALTHCHECK_INTERVAL - - OPR_PROXY_EXECUTOR_SECRET - - OPR_PROXY_ENV=$_APP_ENV - - OPR_PROXY_SECRET=$_APP_EXECUTOR_SECRET - - OPR_PROXY_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER - - OPR_PROXY_LOGGING_CONFIG=$_APP_LOGGING_CONFIG + # openruntimes-proxy: + # container_name: openruntimes-proxy + # hostname: proxy1 + # <<: *x-logging + # image: openruntimes/proxy:0.3.0 + # networks: + # - appwrite + # - openruntimes-executors + # environment: + # - OPR_PROXY_ALGORITHM + # - OPR_PROXY_EXECUTORS + # - OPR_PROXY_HEALTHCHECK + # - OPR_PROXY_HEALTHCHECK_INTERVAL + # - OPR_PROXY_EXECUTOR_SECRET + # - OPR_PROXY_ENV=$_APP_ENV + # - OPR_PROXY_SECRET=$_APP_EXECUTOR_SECRET + # - OPR_PROXY_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER + # - OPR_PROXY_LOGGING_CONFIG=$_APP_LOGGING_CONFIG mariadb: image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index b3eba44a9f..ff79350553 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -26,6 +26,10 @@ class Executor 'content-type' => '', ]; + protected int $cpus = 2; + + protected int $memory = 512; + public function __construct(string $endpoint) { if (!filter_var($endpoint, FILTER_VALIDATE_URL)) { @@ -77,9 +81,8 @@ class Executor 'variables' => $variables, 'remove' => $remove, 'commands' => $commands, - 'timeout' => 600, - 'cpus' => 1, - 'memory' => 128, + 'cpus' => $this->cpus, + 'memory' => $this->memory, ]; $timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900); @@ -114,7 +117,6 @@ class Executor string $payload, array $variables, int $timeout, - string $image, string $source, string $entrypoint, @@ -134,8 +136,8 @@ class Executor 'image' => $image, 'source' => $source, 'entrypoint' => $entrypoint, - 'cpus' => 1, - 'memory' => 128, + 'cpus' => $this->cpus, + 'memory' => $this->memory, ]; $timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);