From 366d75fe3925f6ba3bb09a5314be9c35f25cd8be Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:17:14 -0400 Subject: [PATCH 1/8] feat: Delete execution --- app/config/errors.php | 6 +++ app/controllers/api/functions.php | 49 ++++++++++++++++++ docs/references/functions/delete-execution.md | 1 + src/Appwrite/Extend/Exception.php | 1 + .../Functions/FunctionsCustomServerTest.php | 51 +++++++++++++++++++ 5 files changed, 108 insertions(+) create mode 100644 docs/references/functions/delete-execution.md diff --git a/app/config/errors.php b/app/config/errors.php index 3fc3496086..1c298f6d70 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -566,6 +566,12 @@ return [ 'code' => 404, ], + Exception::EXECUTION_IN_PROGRESS => [ + 'name' => Exception::EXECUTION_IN_PROGRESS, + 'description' => 'Can\'t delete ongoing execution. Please wait for execution to finish before you can retry.', + 'code' => 400, + ], + /** Databases */ Exception::DATABASE_NOT_FOUND => [ 'name' => Exception::DATABASE_NOT_FOUND, diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 21788d2a23..29030ce19f 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -2010,6 +2010,55 @@ App::get('/v1/functions/:functionId/executions/:executionId') $response->dynamic($execution, Response::MODEL_EXECUTION); }); +App::delete('/v1/functions/:functionId/executions/:executionId') + ->groups(['api', 'functions']) + ->desc('Delete execution') + ->label('scope', 'execution.write') + ->label('event', 'functions.[functionId].executions.[executionId].delete') + ->label('audits.event', 'executions.delete') + ->label('audits.resource', 'function/{request.functionId}') + ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'deleteExecution') + ->label('sdk.description', '/docs/references/functions/delete-execution.md') + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->label('sdk.response.model', Response::MODEL_NONE) + ->param('functionId', '', new UID(), 'Function ID.') + ->param('executionId', '', new UID(), 'Execution ID.') + ->inject('response') + ->inject('dbForProject') + ->inject('queueForEvents') + ->action(function (string $functionId, string $executionId, Response $response, Database $dbForProject, Event $queueForEvents) { + $function = $dbForProject->getDocument('functions', $functionId); + + if ($function->isEmpty()) { + throw new Exception(Exception::FUNCTION_NOT_FOUND); + } + + $execution = $dbForProject->getDocument('executions', $executionId); + if ($execution->isEmpty()) { + throw new Exception(Exception::EXECUTION_NOT_FOUND); + } + + if ($execution->getAttribute('functionId') !== $function->getId()) { + throw new Exception(Exception::EXECUTION_NOT_FOUND); + } + + if (!in_array($execution->getAttribute('status'), ['completed', 'failed'])) { + throw new Exception(Exception::EXECUTION_IN_PROGRESS); + } + + if (!$dbForProject->deleteDocument('executions', $execution->getId())) { + throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove execution from DB'); + } + + $queueForEvents + ->setParam('functionId', $function->getId()) + ->setParam('executionId', $execution->getId()); + + $response->noContent(); + }); + // Variables App::post('/v1/functions/:functionId/variables') diff --git a/docs/references/functions/delete-execution.md b/docs/references/functions/delete-execution.md new file mode 100644 index 0000000000..d7cad98ac1 --- /dev/null +++ b/docs/references/functions/delete-execution.md @@ -0,0 +1 @@ +Delete a function execution by its unique ID. diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 054e455bb5..dbc7d9425e 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -168,6 +168,7 @@ class Exception extends \Exception /** Execution */ public const EXECUTION_NOT_FOUND = 'execution_not_found'; + public const EXECUTION_IN_PROGRESS = 'execution_in_progress'; /** Databases */ public const DATABASE_NOT_FOUND = 'database_not_found'; diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index f35776455b..7d55f4817c 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1007,6 +1007,57 @@ class FunctionsCustomServerTest extends Scope return $data; } + /** + * @depends testGetExecution + */ + public function testDeleteExecution($data): array + { + /** + * Test for SUCCESS + */ + $execution = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/executions/' . $data['executionId'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(204, $execution['headers']['status-code']); + $this->assertEmpty($execution['body']); + + $execution = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/executions/' . $data['executionId'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(404, $execution['headers']['status-code']); + $this->assertStringContainsString('Execution with the requested ID could not be found', $execution['body']['message']); + + + /** + * Test for FAILURE + */ + $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $data['functionId'] . '/executions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'async' => true, + ]); + + $executionId = $execution['body']['$id'] ?? ''; + + $this->assertEquals(202, $execution['headers']['status-code']); + + $execution = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/executions/' . $executionId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(400, $execution['headers']['status-code']); + $this->assertStringContainsString('execution_in_progress', $execution['body']['type']); + $this->assertStringContainsString('Can\'t delete ongoing execution.', $execution['body']['message']); + + return $data; + } + /** * @depends testCreateDeployment */ From 9172ff6b149b2deabe00522a8c7708d9e8a3a0e4 Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:39:27 -0400 Subject: [PATCH 2/8] feat: Delete execution --- .../Functions/FunctionsCustomServerTest.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 7d55f4817c..3960a75f0f 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1035,25 +1035,6 @@ class FunctionsCustomServerTest extends Scope /** * Test for FAILURE */ - $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $data['functionId'] . '/executions', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'async' => true, - ]); - - $executionId = $execution['body']['$id'] ?? ''; - - $this->assertEquals(202, $execution['headers']['status-code']); - - $execution = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/executions/' . $executionId, array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); - - $this->assertEquals(400, $execution['headers']['status-code']); - $this->assertStringContainsString('execution_in_progress', $execution['body']['type']); - $this->assertStringContainsString('Can\'t delete ongoing execution.', $execution['body']['message']); return $data; } From 010f8d3fb8c9b079caf042c80e77fd6ef3955704 Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:36:24 -0400 Subject: [PATCH 3/8] review: Delete execution --- app/config/errors.php | 2 +- app/controllers/api/functions.php | 2 +- .../Functions/FunctionsCustomServerTest.php | 135 +++++++++++------- 3 files changed, 84 insertions(+), 55 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index 1c298f6d70..6337c3205a 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -568,7 +568,7 @@ return [ Exception::EXECUTION_IN_PROGRESS => [ 'name' => Exception::EXECUTION_IN_PROGRESS, - 'description' => 'Can\'t delete ongoing execution. Please wait for execution to finish before you can retry.', + 'description' => 'Can\'t delete ongoing execution. Please wait for execution to finish before deleting it.', 'code' => 400, ], diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 29030ce19f..e6a7eab854 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -2044,7 +2044,7 @@ App::delete('/v1/functions/:functionId/executions/:executionId') throw new Exception(Exception::EXECUTION_NOT_FOUND); } - if (!in_array($execution->getAttribute('status'), ['completed', 'failed'])) { + if (!in_array($execution->getAttribute('status'), ['completed', 'failed', 'scheduled'])) { throw new Exception(Exception::EXECUTION_IN_PROGRESS); } diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 3960a75f0f..441775c525 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -454,7 +454,6 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(200, $functionDetails['headers']['status-code']); $this->assertEquals('cli', $functionDetails['body']['type']); - } /** @@ -671,12 +670,16 @@ class FunctionsCustomServerTest extends Scope /** * Test search queries */ - $function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders(), [ - 'search' => $data['functionId'] - ])); + $function = $this->client->call( + Client::METHOD_GET, + '/functions/' . $data['functionId'] . '/deployments', + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders(), [ + 'search' => $data['functionId'] + ]) + ); $this->assertEquals($function['headers']['status-code'], 200); $this->assertEquals(3, $function['body']['total']); @@ -732,12 +735,16 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals($function['headers']['status-code'], 200); $this->assertCount(0, $function['body']['deployments']); - $function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders(), [ - 'search' => 'Test' - ])); + $function = $this->client->call( + Client::METHOD_GET, + '/functions/' . $data['functionId'] . '/deployments', + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders(), [ + 'search' => 'Test' + ]) + ); $this->assertEquals($function['headers']['status-code'], 200); $this->assertEquals(3, $function['body']['total']); @@ -745,12 +752,16 @@ class FunctionsCustomServerTest extends Scope $this->assertCount(3, $function['body']['deployments']); $this->assertEquals($function['body']['deployments'][0]['$id'], $data['deploymentId']); - $function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders(), [ - 'search' => 'php-8.0' - ])); + $function = $this->client->call( + Client::METHOD_GET, + '/functions/' . $data['functionId'] . '/deployments', + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders(), [ + 'search' => 'php-8.0' + ]) + ); $this->assertEquals($function['headers']['status-code'], 200); $this->assertEquals(3, $function['body']['total']); @@ -977,35 +988,6 @@ class FunctionsCustomServerTest extends Scope return $data; } - /** - * @depends testGetExecution - */ - public function testDeleteDeployment($data): array - { - /** - * Test for SUCCESS - */ - $function = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/deployments/' . $data['deploymentId'], array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); - - $this->assertEquals(204, $function['headers']['status-code']); - $this->assertEmpty($function['body']); - - $function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments/' . $data['deploymentId'], array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); - - $this->assertEquals(404, $function['headers']['status-code']); - - /** - * Test for FAILURE - */ - - return $data; - } /** * @depends testGetExecution @@ -1031,6 +1013,53 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(404, $execution['headers']['status-code']); $this->assertStringContainsString('Execution with the requested ID could not be found', $execution['body']['message']); + /** + * Test for FAILURE + */ + $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $data['functionId'] . '/executions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'async' => true, + ]); + + $executionId = $execution['body']['$id'] ?? ''; + $this->assertEquals(202, $execution['headers']['status-code']); + + $execution = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/executions/' . $executionId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(400, $execution['headers']['status-code']); + $this->assertStringContainsString('execution_in_progress', $execution['body']['type']); + $this->assertStringContainsString('Can\'t delete ongoing execution.', $execution['body']['message']); + + return $data; + } + + /** + * @depends testGetExecution + */ + public function testDeleteDeployment($data): array + { + /** + * Test for SUCCESS + */ + $function = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/deployments/' . $data['deploymentId'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(204, $function['headers']['status-code']); + $this->assertEmpty($function['body']); + + $function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments/' . $data['deploymentId'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(404, $function['headers']['status-code']); /** * Test for FAILURE @@ -1190,10 +1219,10 @@ class FunctionsCustomServerTest extends Scope public function provideCustomExecutions(): array { return [ - [ 'folder' => 'php-fn', 'name' => 'php-8.0', 'entrypoint' => 'index.php', 'runtimeName' => 'PHP', 'runtimeVersion' => '8.0' ], - [ 'folder' => 'node', 'name' => 'node-18.0', 'entrypoint' => 'index.js', 'runtimeName' => 'Node.js', 'runtimeVersion' => '18.0' ], - [ 'folder' => 'python', 'name' => 'python-3.9', 'entrypoint' => 'main.py', 'runtimeName' => 'Python', 'runtimeVersion' => '3.9' ], - [ 'folder' => 'ruby', 'name' => 'ruby-3.1', 'entrypoint' => 'main.rb', 'runtimeName' => 'Ruby', 'runtimeVersion' => '3.1' ], + ['folder' => 'php-fn', 'name' => 'php-8.0', 'entrypoint' => 'index.php', 'runtimeName' => 'PHP', 'runtimeVersion' => '8.0'], + ['folder' => 'node', 'name' => 'node-18.0', 'entrypoint' => 'index.js', 'runtimeName' => 'Node.js', 'runtimeVersion' => '18.0'], + ['folder' => 'python', 'name' => 'python-3.9', 'entrypoint' => 'main.py', 'runtimeName' => 'Python', 'runtimeVersion' => '3.9'], + ['folder' => 'ruby', 'name' => 'ruby-3.1', 'entrypoint' => 'main.rb', 'runtimeName' => 'Ruby', 'runtimeVersion' => '3.1'], // Swift and Dart disabled as it's very slow. // [ 'folder' => 'dart', 'name' => 'dart-2.15', 'entrypoint' => 'main.dart', 'runtimeName' => 'Dart', 'runtimeVersion' => '2.15' ], // [ 'folder' => 'swift', 'name' => 'swift-5.5', 'entrypoint' => 'index.swift', 'runtimeName' => 'Swift', 'runtimeVersion' => '5.5' ], @@ -1206,7 +1235,7 @@ class FunctionsCustomServerTest extends Scope * @param string $entrypoint * * @dataProvider provideCustomExecutions - * @depends testTimeout + * @depends testTimeout */ public function testCreateCustomExecution(string $folder, string $name, string $entrypoint, string $runtimeName, string $runtimeVersion) { From b19d7cb35f0bbba06879e95f2a383198d4da936a Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:12:23 -0400 Subject: [PATCH 4/8] feat: Update scheduled when deleting an execution --- app/controllers/api/functions.php | 29 ++++++++++++++++--- .../Functions/FunctionsCustomServerTest.php | 29 +++++++++++++++++++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 09baf8c4d7..f58bdcd02f 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -11,6 +11,7 @@ use Appwrite\Event\Validator\FunctionEvent; use Appwrite\Extend\Exception; use Appwrite\Extend\Exception as AppwriteException; use Appwrite\Messaging\Adapter\Realtime; +use Appwrite\Platform\Tasks\ScheduleExecutions; use Appwrite\Task\Validator\Cron; use Appwrite\Utopia\Database\Validator\CustomId; use Appwrite\Utopia\Database\Validator\Queries\Deployments; @@ -1725,7 +1726,7 @@ App::post('/v1/functions/:functionId/executions') 'deploymentInternalId' => $deployment->getInternalId(), 'deploymentId' => $deployment->getId(), 'trigger' => (!is_null($scheduledAt)) ? 'schedule' : 'http', - 'status' => $status, // waiting / processing / completed / failed + 'status' => $status, // waiting / processing / completed / failed / scheduled 'responseStatusCode' => 0, 'responseHeaders' => [], 'requestPath' => $path, @@ -1774,7 +1775,7 @@ App::post('/v1/functions/:functionId/executions') $dbForConsole->createDocument('schedules', new Document([ 'region' => System::getEnv('_APP_REGION', 'default'), - 'resourceType' => 'execution', + 'resourceType' => ScheduleExecutions::getSupportedResource(), 'resourceId' => $execution->getId(), 'resourceInternalId' => $execution->getInternalId(), 'resourceUpdatedAt' => DateTime::now(), @@ -2061,8 +2062,9 @@ App::delete('/v1/functions/:functionId/executions/:executionId') ->param('executionId', '', new UID(), 'Execution ID.') ->inject('response') ->inject('dbForProject') + ->inject('dbForConsole') ->inject('queueForEvents') - ->action(function (string $functionId, string $executionId, Response $response, Database $dbForProject, Event $queueForEvents) { + ->action(function (string $functionId, string $executionId, Response $response, Database $dbForProject, Database $dbForConsole, Event $queueForEvents) { $function = $dbForProject->getDocument('functions', $functionId); if ($function->isEmpty()) { @@ -2077,8 +2079,9 @@ App::delete('/v1/functions/:functionId/executions/:executionId') if ($execution->getAttribute('functionId') !== $function->getId()) { throw new Exception(Exception::EXECUTION_NOT_FOUND); } + $status = $execution->getAttribute('status'); - if (!in_array($execution->getAttribute('status'), ['completed', 'failed', 'scheduled'])) { + if (!in_array($status, ['completed', 'failed', 'scheduled'])) { throw new Exception(Exception::EXECUTION_IN_PROGRESS); } @@ -2086,6 +2089,24 @@ App::delete('/v1/functions/:functionId/executions/:executionId') throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove execution from DB'); } + if ($status === 'scheduled') { + $results = $dbForConsole->find('schedules', [ + Query::equal('resourceId', [$execution->getId()]), + Query::equal('resourceType', [ScheduleExecutions::getSupportedResource()]), + Query::equal('active', [true]), + ]); + + if (count($results) === 1) { + $schedule = $results[0]; + + $schedule + ->setAttribute('resourceUpdatedAt', DateTime::now()) + ->setAttribute('active', false); + + Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule)); + } + } + $queueForEvents ->setParam('functionId', $function->getId()) ->setParam('executionId', $execution->getId()); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 441775c525..b7014546a2 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1038,6 +1038,35 @@ class FunctionsCustomServerTest extends Scope return $data; } + /** + * @depends testGetExecution + */ + public function testDeleteScheduledExecution($data): array + { + $futureTime = (new \DateTime())->add(new \DateInterval('PT10H'))->format('Y-m-d H:i:s'); + + $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $data['functionId'] . '/executions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'async' => true, + 'scheduledAt' => $futureTime, + ]); + + $executionId = $execution['body']['$id'] ?? ''; + $this->assertEquals(202, $execution['headers']['status-code']); + sleep(5); + $execution = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/executions/' . $executionId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(204, $execution['headers']['status-code']); + $this->assertEmpty($execution['body']); + var_dump('==========================================='); + return $data; + } + /** * @depends testGetExecution */ From d58a35231323bffd34ea47804a9b7b4f7f084cf1 Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:13:17 -0400 Subject: [PATCH 5/8] fix: Removing debug var_dump --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index b7014546a2..81cc07f34c 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1063,7 +1063,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(204, $execution['headers']['status-code']); $this->assertEmpty($execution['body']); - var_dump('==========================================='); + return $data; } From 87c7da0efa5932e3a364db0eccc998b84659fe96 Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Fri, 28 Jun 2024 11:12:24 -0400 Subject: [PATCH 6/8] fix: unnecessary space --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 81cc07f34c..d0cc0dc3a1 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1264,7 +1264,7 @@ class FunctionsCustomServerTest extends Scope * @param string $entrypoint * * @dataProvider provideCustomExecutions - * @depends testTimeout + * @depends testTimeout */ public function testCreateCustomExecution(string $folder, string $name, string $entrypoint, string $runtimeName, string $runtimeVersion) { From 30db70fe800cdce5a06ffc933ea2f4125c9ae57e Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:23:39 -0400 Subject: [PATCH 7/8] fix: reviews --- app/controllers/api/functions.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index f58bdcd02f..a6e38094b8 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -2090,15 +2090,13 @@ App::delete('/v1/functions/:functionId/executions/:executionId') } if ($status === 'scheduled') { - $results = $dbForConsole->find('schedules', [ + $schedule = $dbForConsole->findOne('schedules', [ Query::equal('resourceId', [$execution->getId()]), Query::equal('resourceType', [ScheduleExecutions::getSupportedResource()]), Query::equal('active', [true]), ]); - if (count($results) === 1) { - $schedule = $results[0]; - + if ($schedule && !$schedule->isEmpty()) { $schedule ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('active', false); From 1c836685688dbaf169988fcb0d63ffba69b6136d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 3 Jul 2024 07:02:41 +0000 Subject: [PATCH 8/8] PR review changes --- app/controllers/api/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 637a53cc2c..7caf4f8cc5 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -2108,7 +2108,8 @@ App::delete('/v1/functions/:functionId/executions/:executionId') $queueForEvents ->setParam('functionId', $function->getId()) - ->setParam('executionId', $execution->getId()); + ->setParam('executionId', $execution->getId()) + ->setPayload($response->output($execution, Response::MODEL_EXECUTION)); $response->noContent(); });