From 7e5110660cd0d55a37a6b2939fa1ceabe3189811 Mon Sep 17 00:00:00 2001 From: Reda Noureddine Date: Tue, 11 Apr 2023 15:37:59 +0200 Subject: [PATCH 1/6] fix: increase timeout for registry namespace deletion --- tests/integrations/project_fixture.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integrations/project_fixture.py b/tests/integrations/project_fixture.py index 68b7091..2dc839f 100644 --- a/tests/integrations/project_fixture.py +++ b/tests/integrations/project_fixture.py @@ -9,6 +9,7 @@ from scaleway.function.v1beta1 import FunctionV1Beta1API from scaleway.registry.v1 import RegistryV1API from scaleway_core.api import ScalewayException +from scaleway_core.utils import WaitForOptions from .utils import create_client @@ -62,7 +63,7 @@ def _cleanup_project(client: Client, project_id: ProjectID): raise e for registry in registries: try: - registry_api.wait_for_namespace(namespace_id=registry.id) + registry_api.wait_for_namespace(namespace_id=registry.id, options=WaitForOptions(timeout=600)) except ScalewayException as e: if e.status_code != 404: raise e From 9e574dbcae79c231603ba4540b4cb36b03481719 Mon Sep 17 00:00:00 2001 From: Reda Noureddine Date: Tue, 11 Apr 2023 17:27:13 +0200 Subject: [PATCH 2/6] fix: add target to route for prefix validation --- scw_serverless/gateway/gateway_manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scw_serverless/gateway/gateway_manager.py b/scw_serverless/gateway/gateway_manager.py index ced4d1f..9ae5b11 100644 --- a/scw_serverless/gateway/gateway_manager.py +++ b/scw_serverless/gateway/gateway_manager.py @@ -55,6 +55,7 @@ def update_routes(self) -> None: # otherwise we might accidentally delete a route we previously created. # If it has the same relative_url but different http methods. for function in routed_functions: + function.gateway_route.target = "https://" self.gateway_client.delete_route(function.gateway_route) # type: ignore for function in routed_functions: From a1b0f425c4b261ecda8eab6d962d713284f52a9f Mon Sep 17 00:00:00 2001 From: Reda Noureddine Date: Tue, 11 Apr 2023 17:40:56 +0200 Subject: [PATCH 3/6] feat: get targets of deployed functions without a start clean up --- scw_serverless/gateway/gateway_manager.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/scw_serverless/gateway/gateway_manager.py b/scw_serverless/gateway/gateway_manager.py index 9ae5b11..1dcd8d0 100644 --- a/scw_serverless/gateway/gateway_manager.py +++ b/scw_serverless/gateway/gateway_manager.py @@ -50,14 +50,6 @@ def update_routes(self) -> None: if function.gateway_route ] - # The Gateway deletes routes based on the relative_url, - # so we need to cleanup all routes at the start, - # otherwise we might accidentally delete a route we previously created. - # If it has the same relative_url but different http methods. - for function in routed_functions: - function.gateway_route.target = "https://" - self.gateway_client.delete_route(function.gateway_route) # type: ignore - for function in routed_functions: if function.name not in created_functions: raise RuntimeError( @@ -69,6 +61,4 @@ def update_routes(self) -> None: function.gateway_route.target = target # type: ignore for function in routed_functions: - if not function.gateway_route: - continue - self.gateway_client.create_route(function.gateway_route) + self.gateway_client.create_route(function.gateway_route) # type: ignore From 38a14aa6439cb59c39a12016f990124e6e5e8517 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 15:47:08 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scw_serverless/gateway/gateway_manager.py | 2 +- tests/integrations/project_fixture.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scw_serverless/gateway/gateway_manager.py b/scw_serverless/gateway/gateway_manager.py index 1dcd8d0..94bd83e 100644 --- a/scw_serverless/gateway/gateway_manager.py +++ b/scw_serverless/gateway/gateway_manager.py @@ -61,4 +61,4 @@ def update_routes(self) -> None: function.gateway_route.target = target # type: ignore for function in routed_functions: - self.gateway_client.create_route(function.gateway_route) # type: ignore + self.gateway_client.create_route(function.gateway_route) # type: ignore diff --git a/tests/integrations/project_fixture.py b/tests/integrations/project_fixture.py index 2dc839f..ac263e6 100644 --- a/tests/integrations/project_fixture.py +++ b/tests/integrations/project_fixture.py @@ -63,7 +63,9 @@ def _cleanup_project(client: Client, project_id: ProjectID): raise e for registry in registries: try: - registry_api.wait_for_namespace(namespace_id=registry.id, options=WaitForOptions(timeout=600)) + registry_api.wait_for_namespace( + namespace_id=registry.id, options=WaitForOptions(timeout=600) + ) except ScalewayException as e: if e.status_code != 404: raise e From 82b0bae1abda726b707bd6a7ac772dccbffc6511 Mon Sep 17 00:00:00 2001 From: Reda Noureddine Date: Tue, 11 Apr 2023 17:50:54 +0200 Subject: [PATCH 5/6] test: remove delete response mock --- tests/test_gateway/test_gateway_manager.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/test_gateway/test_gateway_manager.py b/tests/test_gateway/test_gateway_manager.py index 1334372..52023e1 100644 --- a/tests/test_gateway/test_gateway_manager.py +++ b/tests/test_gateway/test_gateway_manager.py @@ -87,14 +87,6 @@ def test_gateway_manager_update_routes( json={"functions": []}, ) - # We should attempt to delete the route - mocked_responses.delete( - MOCK_GATEWAY_URL + "/scw", # type: ignore - match=[ - header_matcher({"X-Auth-Token": MOCK_GATEWAY_API_KEY}), - json_params_matcher(params=function.gateway_route.asdict()), # type: ignore - ], - ) # We should attempt to create the route mocked_responses.post( MOCK_GATEWAY_URL + "/scw", # type: ignore From f043e91de152cedd94d5c0b3d9fe73673097960f Mon Sep 17 00:00:00 2001 From: Reda Noureddine Date: Wed, 12 Apr 2023 13:37:37 +0200 Subject: [PATCH 6/6] chore: bump pyproject version and dev status --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a5265c1..aa5ab5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "scw-serverless" -version = "1.0.0" +version = "1.0.1" description = "Framework for writing serverless APIs in Python, using Scaleway functions and containers." authors = ["Scaleway Serverless Team "] readme = "README.md" @@ -14,7 +14,7 @@ keywords = ["serverless", "scaleway", "functions", "cloud", "faas"] # "Development Status :: 4 - Beta" # "Development Status :: 5 - Production/Stable" classifiers = [ - "Development Status :: 3 - Alpha", + "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Topic :: Software Development :: Libraries :: Application Frameworks",