Skip to content

Commit 03fd04d

Browse files
committed
Add error message
1 parent a55574a commit 03fd04d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/k8s/src/hooks/prepare-job.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,18 @@ async function processServiceContainers(
160160
)
161161
})
162162

163-
// Only 1 container in a pod can request TPU's.
164-
if (
165-
services.find(
166-
service =>
167-
service.resources?.limits && service.resources.limits['google.com/tpu']
163+
const tpuRequestingContainers = services.filter(
164+
service =>
165+
service.resources?.limits && service.resources.limits['google.com/tpu']
166+
)
167+
168+
if (tpuRequestingContainers.length > 1) {
169+
throw new Error(
170+
`${tpuRequestingContainers.length} containers request for TPU's. Only 1 container per pod can request for TPU's.`
168171
)
169-
) {
172+
}
173+
174+
if (tpuRequestingContainers.length === 1) {
170175
if (
171176
container?.resources?.requests &&
172177
container.resources.requests['google.com/tpu']

0 commit comments

Comments
 (0)