From aabff5db5df1aa8a8205c14fc8b0ccd7fe099c81 Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Tue, 17 Dec 2024 12:40:29 +0100 Subject: [PATCH 1/2] Add failing test cases --- .../streams_bootstrap/test_streams_bootstrap.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/components/streams_bootstrap/test_streams_bootstrap.py b/tests/components/streams_bootstrap/test_streams_bootstrap.py index d7deebae4..d09bd5bbb 100644 --- a/tests/components/streams_bootstrap/test_streams_bootstrap.py +++ b/tests/components/streams_bootstrap/test_streams_bootstrap.py @@ -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), From 302a4f453d971e5ffac1c95e20839674cbeb14aa Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Tue, 17 Dec 2024 12:41:19 +0100 Subject: [PATCH 2/2] Update regex --- docs/docs/schema/defaults.json | 2 +- docs/docs/schema/pipeline.json | 2 +- kpops/components/common/kubernetes_model.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/docs/schema/defaults.json b/docs/docs/schema/defaults.json index 189f2b510..a8c28bc10 100644 --- a/docs/docs/schema/defaults.json +++ b/docs/docs/schema/defaults.json @@ -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" }, { diff --git a/docs/docs/schema/pipeline.json b/docs/docs/schema/pipeline.json index ba3865ecf..63a2ecfbf 100644 --- a/docs/docs/schema/pipeline.json +++ b/docs/docs/schema/pipeline.json @@ -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" }, { diff --git a/kpops/components/common/kubernetes_model.py b/kpops/components/common/kubernetes_model.py index e2fd0b7a6..777729010 100644 --- a/kpops/components/common/kubernetes_model.py +++ b/kpops/components/common/kubernetes_model.py @@ -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)?$"), ]