Skip to content

Commit

Permalink
Fix Kubernetes memory not accepting decimal values (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted authored Dec 17, 2024
1 parent e6e2ae4 commit eeb0b27
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/docs/schema/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -2342,7 +2342,7 @@
"memory": {
"anyOf": [
{
"pattern": "^\\d+([EPTGMk]|Ei|Pi|Ti|Gi|Mi|Ki)?$",
"pattern": "^\\d+(\\.\\d+)?([EPTGMk]|Ei|Pi|Ti|Gi|Mi|Ki)?$",
"type": "string"
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/schema/pipeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,7 @@
"memory": {
"anyOf": [
{
"pattern": "^\\d+([EPTGMk]|Ei|Pi|Ti|Gi|Mi|Ki)?$",
"pattern": "^\\d+(\\.\\d+)?([EPTGMk]|Ei|Pi|Ti|Gi|Mi|Ki)?$",
"type": "string"
},
{
Expand Down
3 changes: 2 additions & 1 deletion kpops/components/common/kubernetes_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ class Toleration(DescConfigModel, CamelCaseConfigModel):
CPUStr = Annotated[str, pydantic.StringConstraints(pattern=r"^\d+m$")]
MemoryStr = Annotated[
# Matches plain number string or number with valid suffixes: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory
str, pydantic.StringConstraints(pattern=r"^\d+([EPTGMk]|Ei|Pi|Ti|Gi|Mi|Ki)?$")
str,
pydantic.StringConstraints(pattern=r"^\d+(\.\d+)?([EPTGMk]|Ei|Pi|Ti|Gi|Mi|Ki)?$"),
]


Expand Down
8 changes: 8 additions & 0 deletions tests/components/streams_bootstrap/test_streams_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ async def test_should_raise_validation_error_for_invalid_helm_chart_version(self
pytest.param(
{"memory": "10Mi"}, does_not_raise(), id="memory str mebibyte"
),
pytest.param(
{"memory": "2.5G"}, does_not_raise(), id="memory str decimal gigabyte"
),
pytest.param(
{"memory": "0.599M"},
does_not_raise(),
id="memory str decimal megabyte",
),
pytest.param(
{"memory": 0},
pytest.raises(ValidationError),
Expand Down

0 comments on commit eeb0b27

Please sign in to comment.