Skip to content

Commit b4ae46e

Browse files
authored
feat(serverless): add option to scale on memory usage (#740)
1 parent 3ea0371 commit b4ae46e

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

scaleway-async/scaleway_async/container/v1beta1/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ async def create_container(
633633
:param scaling_option: Possible values:
634634
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
635635
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
636+
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
636637
:param health_check: Health check configuration of the container.
637638
:return: :class:`Container <Container>`
638639
@@ -735,8 +736,8 @@ async def update_container(
735736
:param scaling_option: Possible values:
736737
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
737738
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
739+
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
738740
:param health_check: Health check configuration of the container.
739-
740741
:return: :class:`Container <Container>`
741742
742743
Usage:

scaleway-async/scaleway_async/container/v1beta1/marshalling.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption:
131131
else:
132132
args["cpu_usage_threshold"] = None
133133

134+
field = data.get("memory_usage_threshold", None)
135+
if field is not None:
136+
args["memory_usage_threshold"] = field
137+
else:
138+
args["memory_usage_threshold"] = None
139+
134140
return ContainerScalingOption(**args)
135141

136142

@@ -825,6 +831,9 @@ def marshal_ContainerScalingOption(
825831
request.concurrent_requests_threshold,
826832
),
827833
OneOfPossibility("cpu_usage_threshold", request.cpu_usage_threshold),
834+
OneOfPossibility(
835+
"memory_usage_threshold", request.memory_usage_threshold
836+
),
828837
]
829838
),
830839
)

scaleway-async/scaleway_async/container/v1beta1/types.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ class ContainerScalingOption:
228228

229229
cpu_usage_threshold: Optional[int]
230230

231+
memory_usage_threshold: Optional[int]
232+
231233

232234
@dataclass
233235
class SecretHashedValue:
@@ -481,7 +483,7 @@ class Container:
481483
Possible values:
482484
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
483485
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
484-
486+
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
485487
"""
486488

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

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

15141518
health_check: Optional[ContainerHealthCheckSpec]

scaleway/scaleway/container/v1beta1/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ def create_container(
629629
:param scaling_option: Possible values:
630630
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
631631
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
632+
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
632633
:param health_check: Health check configuration of the container.
633634
:return: :class:`Container <Container>`
634635
@@ -731,6 +732,7 @@ def update_container(
731732
:param scaling_option: Possible values:
732733
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
733734
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
735+
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
734736
:param health_check: Health check configuration of the container.
735737
:return: :class:`Container <Container>`
736738

scaleway/scaleway/container/v1beta1/marshalling.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption:
131131
else:
132132
args["cpu_usage_threshold"] = None
133133

134+
field = data.get("memory_usage_threshold", None)
135+
if field is not None:
136+
args["memory_usage_threshold"] = field
137+
else:
138+
args["memory_usage_threshold"] = None
139+
134140
return ContainerScalingOption(**args)
135141

136142

@@ -825,6 +831,9 @@ def marshal_ContainerScalingOption(
825831
request.concurrent_requests_threshold,
826832
),
827833
OneOfPossibility("cpu_usage_threshold", request.cpu_usage_threshold),
834+
OneOfPossibility(
835+
"memory_usage_threshold", request.memory_usage_threshold
836+
),
828837
]
829838
),
830839
)

scaleway/scaleway/container/v1beta1/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ class ContainerScalingOption:
228228

229229
cpu_usage_threshold: Optional[int]
230230

231+
memory_usage_threshold: Optional[int]
232+
231233

232234
@dataclass
233235
class SecretHashedValue:
@@ -481,6 +483,7 @@ class Container:
481483
Possible values:
482484
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
483485
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
486+
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
484487
"""
485488

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

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

15131518
health_check: Optional[ContainerHealthCheckSpec]

0 commit comments

Comments
 (0)