Skip to content

Commit

Permalink
Merge pull request #546 from opsani/OPTSERV-766-servo-helm-memory-min…
Browse files Browse the repository at this point in the history
…-max-passed-without-units

Kubernetes mem handle unitless decimal strings
  • Loading branch information
linkous8 authored Jul 27, 2023
2 parents 6a1da68 + e8c7c37 commit 1ba93ad
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions servo/connectors/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,17 @@ class ShortByteSize(pydantic.ByteSize):
@classmethod
def validate(cls, v: pydantic.StrIntFloat) -> "ShortByteSize":
if isinstance(v, str):
# Unitless decimals are not use by k8s API but are used in servo protocol implicitly as GiB
if re.match(r"^\d*\.\d+$", v):
v = f"{v}GiB"

try:
return super().validate(v)
except:
# Append the byte suffix and retry parsing
return super().validate(v + "b")
elif isinstance(v, float):
# Unitless decimals are not use by k8s API but are used in servo protocol implicitly as GiB
v = v * GiB
return super().validate(v)

Expand Down

0 comments on commit 1ba93ad

Please sign in to comment.