Skip to content

Commit 819952a

Browse files
author
Alan Christie
committed
fix: Image cores now a string
1 parent 82a51b8 commit 819952a

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

decoder/job-definition-schema.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,11 @@ definitions:
144144
- project-directory
145145
- working-directory
146146

147-
# A kubernetes CPU (cores) declaration.
148-
# Here we only accept numbers in the range 1 to 32.
147+
# A kubernetes CPU (cores) declaration (minimum of 10m).
148+
# Here we allow an up-to 4-digit m value or a 2-digit integer.
149149
cores:
150-
type: integer
151-
minimum: 1
152-
maximum: 32
150+
type: string
151+
pattern: '^([1-9][0-9]{1,3}m|[1-9][0-9]{0,1})$'
153152

154153
# A kubernetes memory declaration.
155154
# Here we allow an up-to 4-digit Mi value (minimum of 100Mi)

tests/test_validate_job_schema.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,37 @@ def test_validate_image_cores_1():
164164
assert error is None
165165

166166

167-
def test_validate_image_cores_32():
167+
def test_validate_image_cores_99():
168168
# Arrange
169169
text: Dict[str, Any] = deepcopy(_MINIMAL)
170170
demo_job: Dict[str, Any] = text["jobs"]["demo"]
171-
demo_job["image"]["cores"] = 32
171+
demo_job["image"]["cores"] = 99
172+
173+
# Act
174+
error = decoder.validate_job_schema(text)
175+
176+
# Assert
177+
assert error is None
178+
179+
180+
def test_validate_image_cores_10m():
181+
# Arrange
182+
text: Dict[str, Any] = deepcopy(_MINIMAL)
183+
demo_job: Dict[str, Any] = text["jobs"]["demo"]
184+
demo_job["image"]["cores"] = "10m"
185+
186+
# Act
187+
error = decoder.validate_job_schema(text)
188+
189+
# Assert
190+
assert error is None
191+
192+
193+
def test_validate_image_cores_1500m():
194+
# Arrange
195+
text: Dict[str, Any] = deepcopy(_MINIMAL)
196+
demo_job: Dict[str, Any] = text["jobs"]["demo"]
197+
demo_job["image"]["cores"] = "1500m"
172198

173199
# Act
174200
error = decoder.validate_job_schema(text)

0 commit comments

Comments
 (0)