Skip to content

feat(serverless): add option to scale on memory usage #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scaleway-async/scaleway_async/container/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ async def create_container(
:param scaling_option: Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
:param health_check: Health check configuration of the container.
:return: :class:`Container <Container>`

Expand Down Expand Up @@ -735,8 +736,8 @@ async def update_container(
:param scaling_option: Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
:param health_check: Health check configuration of the container.

:return: :class:`Container <Container>`

Usage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption:
else:
args["cpu_usage_threshold"] = None

field = data.get("memory_usage_threshold", None)
if field is not None:
args["memory_usage_threshold"] = field
else:
args["memory_usage_threshold"] = None

return ContainerScalingOption(**args)


Expand Down Expand Up @@ -825,6 +831,9 @@ def marshal_ContainerScalingOption(
request.concurrent_requests_threshold,
),
OneOfPossibility("cpu_usage_threshold", request.cpu_usage_threshold),
OneOfPossibility(
"memory_usage_threshold", request.memory_usage_threshold
),
]
),
)
Expand Down
6 changes: 5 additions & 1 deletion scaleway-async/scaleway_async/container/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ class ContainerScalingOption:

cpu_usage_threshold: Optional[int]

memory_usage_threshold: Optional[int]


@dataclass
class SecretHashedValue:
Expand Down Expand Up @@ -481,7 +483,7 @@ class Container:
Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.

- memory_usage_threshold: Scale depending on the memory usage of a container instance.
"""

health_check: Optional[ContainerHealthCheckSpec]
Expand Down Expand Up @@ -831,6 +833,7 @@ class CreateContainerRequest:
Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
"""

health_check: Optional[ContainerHealthCheckSpec]
Expand Down Expand Up @@ -1509,6 +1512,7 @@ class UpdateContainerRequest:
Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
"""

health_check: Optional[ContainerHealthCheckSpec]
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/container/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ def create_container(
:param scaling_option: Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
:param health_check: Health check configuration of the container.
:return: :class:`Container <Container>`

Expand Down Expand Up @@ -731,6 +732,7 @@ def update_container(
:param scaling_option: Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
:param health_check: Health check configuration of the container.
:return: :class:`Container <Container>`

Expand Down
9 changes: 9 additions & 0 deletions scaleway/scaleway/container/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption:
else:
args["cpu_usage_threshold"] = None

field = data.get("memory_usage_threshold", None)
if field is not None:
args["memory_usage_threshold"] = field
else:
args["memory_usage_threshold"] = None

return ContainerScalingOption(**args)


Expand Down Expand Up @@ -825,6 +831,9 @@ def marshal_ContainerScalingOption(
request.concurrent_requests_threshold,
),
OneOfPossibility("cpu_usage_threshold", request.cpu_usage_threshold),
OneOfPossibility(
"memory_usage_threshold", request.memory_usage_threshold
),
]
),
)
Expand Down
5 changes: 5 additions & 0 deletions scaleway/scaleway/container/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ class ContainerScalingOption:

cpu_usage_threshold: Optional[int]

memory_usage_threshold: Optional[int]


@dataclass
class SecretHashedValue:
Expand Down Expand Up @@ -481,6 +483,7 @@ class Container:
Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
"""

health_check: Optional[ContainerHealthCheckSpec]
Expand Down Expand Up @@ -830,6 +833,7 @@ class CreateContainerRequest:
Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
"""

health_check: Optional[ContainerHealthCheckSpec]
Expand Down Expand Up @@ -1508,6 +1512,7 @@ class UpdateContainerRequest:
Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
"""

health_check: Optional[ContainerHealthCheckSpec]
Expand Down