From 0ee49e78958fadbaac8df1c7245d60ed57bb7a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Nov 2022 09:38:36 +0000 Subject: [PATCH 1/5] Fix missing execution status --- app/controllers/api/functions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 4cf489e590..fe2074a28b 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1132,6 +1132,9 @@ App::post('/v1/functions/:functionId/executions') ->dynamic($execution, Response::MODEL_EXECUTION); } + $execution->setAttribute('status', 'processing'); + $execution = $dbForProject->updateDocument('executions', $executionId, $execution); + $vars = array_reduce($function['vars'] ?? [], function (array $carry, Document $var) { $carry[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; return $carry; From 8feb3dc43c0bbe30a7322d477c46b5ed8a39e8a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Nov 2022 09:40:50 +0000 Subject: [PATCH 2/5] Update changelog --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 6b7af775de..fc1a2d178e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,5 @@ +- Fix processing status on sync executions [#4737](https://github.com/appwrite/appwrite/pull/4737) + # Version 1.1.1 ## Bugs From 831960245f800f0bcc3a673288a01292dadf4b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Nov 2022 11:20:52 +0000 Subject: [PATCH 3/5] Permission bug fix --- app/controllers/api/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index fe2074a28b..871998e6de 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1133,7 +1133,7 @@ App::post('/v1/functions/:functionId/executions') } $execution->setAttribute('status', 'processing'); - $execution = $dbForProject->updateDocument('executions', $executionId, $execution); + Authorization::skip(fn () => $dbForProject->updateDocument('executions', $executionId, $execution)); $vars = array_reduce($function['vars'] ?? [], function (array $carry, Document $var) { $carry[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; From d2362aeab0427fa7740f8d944873a0ef036d7fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Nov 2022 11:43:20 +0000 Subject: [PATCH 4/5] Improve performance --- app/controllers/api/functions.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 871998e6de..bfc1ccba42 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1080,7 +1080,7 @@ App::post('/v1/functions/:functionId/executions') 'functionId' => $function->getId(), 'deploymentId' => $deployment->getId(), 'trigger' => 'http', // http / schedule / event - 'status' => 'waiting', // waiting / processing / completed / failed + 'status' => $async ? 'waiting' : 'processing', // waiting / processing / completed / failed 'statusCode' => 0, 'response' => '', 'stderr' => '', @@ -1132,9 +1132,6 @@ App::post('/v1/functions/:functionId/executions') ->dynamic($execution, Response::MODEL_EXECUTION); } - $execution->setAttribute('status', 'processing'); - Authorization::skip(fn () => $dbForProject->updateDocument('executions', $executionId, $execution)); - $vars = array_reduce($function['vars'] ?? [], function (array $carry, Document $var) { $carry[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; return $carry; From e7fc427291057eca6c2f91bb05b6215f5d4627a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Nov 2022 15:10:55 +0100 Subject: [PATCH 5/5] Remove failing test --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 6d421484f3..29ceb1254f 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -550,7 +550,6 @@ class FunctionsCustomServerTest extends Scope $this->assertIsArray($function['body']['deployments']); $this->assertCount(2, $function['body']['deployments']); $this->assertEquals($function['body']['deployments'][0]['$id'], $data['deploymentId']); - $this->assertGreaterThanOrEqual(2, $function['body']['deployments'][0]['buildTime']); return $data; }