Skip to content

Commit 8cc0829

Browse files
feat(serverless): add option to scale on CPU usage (#722)
Co-authored-by: Laure-di <62625835+Laure-di@users.noreply.github.com>
1 parent 7732d10 commit 8cc0829

File tree

6 files changed

+28
-0
lines changed

6 files changed

+28
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ async def create_container(
630630
:param local_storage_limit: Local storage limit of the container (in MB).
631631
:param scaling_option: Possible values:
632632
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
633+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
633634
:return: :class:`Container <Container>`
634635
635636
Usage:
@@ -728,6 +729,7 @@ async def update_container(
728729
:param local_storage_limit: Local storage limit of the container (in MB).
729730
:param scaling_option: Possible values:
730731
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
732+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
731733
:return: :class:`Container <Container>`
732734
733735
Usage:

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption:
5959
else:
6060
args["concurrent_requests_threshold"] = None
6161

62+
field = data.get("cpu_usage_threshold", None)
63+
if field is not None:
64+
args["cpu_usage_threshold"] = field
65+
else:
66+
args["cpu_usage_threshold"] = None
67+
6268
return ContainerScalingOption(**args)
6369

6470

@@ -702,6 +708,7 @@ def marshal_ContainerScalingOption(
702708
"concurrent_requests_threshold",
703709
request.concurrent_requests_threshold,
704710
),
711+
OneOfPossibility("cpu_usage_threshold", request.cpu_usage_threshold),
705712
]
706713
),
707714
)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ def __str__(self) -> str:
195195
class ContainerScalingOption:
196196
concurrent_requests_threshold: Optional[int]
197197

198+
cpu_usage_threshold: Optional[int]
199+
198200

199201
@dataclass
200202
class SecretHashedValue:
@@ -447,6 +449,7 @@ class Container:
447449
"""
448450
Possible values:
449451
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
452+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
450453
"""
451454

452455
created_at: Optional[datetime]
@@ -790,6 +793,7 @@ class CreateContainerRequest:
790793
"""
791794
Possible values:
792795
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
796+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
793797
"""
794798

795799

@@ -1462,6 +1466,7 @@ class UpdateContainerRequest:
14621466
"""
14631467
Possible values:
14641468
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
1469+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
14651470
"""
14661471

14671472

scaleway/scaleway/container/v1beta1/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ def create_container(
626626
:param local_storage_limit: Local storage limit of the container (in MB).
627627
:param scaling_option: Possible values:
628628
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
629+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
629630
:return: :class:`Container <Container>`
630631
631632
Usage:
@@ -724,6 +725,7 @@ def update_container(
724725
:param local_storage_limit: Local storage limit of the container (in MB).
725726
:param scaling_option: Possible values:
726727
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
728+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
727729
:return: :class:`Container <Container>`
728730
729731
Usage:

scaleway/scaleway/container/v1beta1/marshalling.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption:
5959
else:
6060
args["concurrent_requests_threshold"] = None
6161

62+
field = data.get("cpu_usage_threshold", None)
63+
if field is not None:
64+
args["cpu_usage_threshold"] = field
65+
else:
66+
args["cpu_usage_threshold"] = None
67+
6268
return ContainerScalingOption(**args)
6369

6470

@@ -702,6 +708,7 @@ def marshal_ContainerScalingOption(
702708
"concurrent_requests_threshold",
703709
request.concurrent_requests_threshold,
704710
),
711+
OneOfPossibility("cpu_usage_threshold", request.cpu_usage_threshold),
705712
]
706713
),
707714
)

scaleway/scaleway/container/v1beta1/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ def __str__(self) -> str:
195195
class ContainerScalingOption:
196196
concurrent_requests_threshold: Optional[int]
197197

198+
cpu_usage_threshold: Optional[int]
199+
198200

199201
@dataclass
200202
class SecretHashedValue:
@@ -447,6 +449,7 @@ class Container:
447449
"""
448450
Possible values:
449451
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
452+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
450453
"""
451454

452455
created_at: Optional[datetime]
@@ -790,6 +793,7 @@ class CreateContainerRequest:
790793
"""
791794
Possible values:
792795
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
796+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
793797
"""
794798

795799

@@ -1462,6 +1466,7 @@ class UpdateContainerRequest:
14621466
"""
14631467
Possible values:
14641468
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
1469+
- cpu_usage_threshold: Scale depending on the CPU usage of a container instance.
14651470
"""
14661471

14671472

0 commit comments

Comments
 (0)