Skip to content

Commit

Permalink
Increase timeout when deleting registry namespace & Add valid target …
Browse files Browse the repository at this point in the history
…for route creation (#72)

Increase timeout for registry namespace deletion. Add target to route for prefix validation. Upgrade pyproject version and development status.
  • Loading branch information
redanrd authored Apr 12, 2023
1 parent fc0765f commit a5e0258
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
readme = "README.md"
Expand All @@ -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",
Expand Down
11 changes: 1 addition & 10 deletions scw_serverless/gateway/gateway_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +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:
self.gateway_client.delete_route(function.gateway_route) # type: ignore

for function in routed_functions:
if function.name not in created_functions:
raise RuntimeError(
Expand All @@ -68,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
5 changes: 4 additions & 1 deletion tests/integrations/project_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -62,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)
registry_api.wait_for_namespace(
namespace_id=registry.id, options=WaitForOptions(timeout=600)
)
except ScalewayException as e:
if e.status_code != 404:
raise e
Expand Down
8 changes: 0 additions & 8 deletions tests/test_gateway/test_gateway_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a5e0258

Please sign in to comment.