@@ -308,16 +308,16 @@ function overrideEntrypoint(container: JobContainerInfo, createOptions: string)
308308 core . debug ( `entrypoints are ${ entryPointAndArgs } ` )
309309 container . entryPoint = entryPointAndArgs [ 0 ]
310310 container . entryPointArgs = entryPointAndArgs . slice ( 1 )
311- core . debug ( `container is ${ JSON . stringify ( container ) } ` )
311+ core . debug ( `overriden container is ${ JSON . stringify ( container ) } ` )
312312}
313313
314- function overrideTpuRequest ( container : JobContainerInfo , createOptions : string ) {
314+ function getTpuRequest ( container : JobContainerInfo , createOptions : string ) : number {
315315 core . debug ( 'create options' + createOptions )
316316 const match = createOptions . match ( tpuRegex )
317317 core . debug ( `match is ${ match } ` )
318318 if ( ! match || match [ 1 ] === undefined ) {
319319 core . debug ( `no tpu override for ${ container } ` )
320- return
320+ return 0
321321 }
322322 if ( ! container . resources ) {
323323 container . resources = { }
@@ -326,8 +326,7 @@ function overrideTpuRequest(container: JobContainerInfo, createOptions: string)
326326 container . resources . limits = { }
327327 }
328328
329- container . resources . limits [ "google.com/tpu" ] = match [ 1 ]
330- core . debug ( `new container ${ JSON . stringify ( container ) } ` )
329+ return Number ( match [ 1 ] )
331330}
332331
333332export function createContainerSpec (
@@ -354,13 +353,16 @@ export function createContainerSpec(
354353 }
355354 }
356355
356+ let tpuRequest = 0
357357 // Override service container entrypoint with createOptions
358358 if ( ! jobContainer && createOptions && createOptions ?. length > 0 ) {
359359 core . debug ( `overriding with createOptions ${ createOptions } ` )
360360 overrideEntrypoint ( container , createOptions )
361- overrideTpuRequest ( container , createOptions )
361+ tpuRequest = getTpuRequest ( container , createOptions )
362362 }
363363
364+ core . debug ( `tpu request is ${ tpuRequest } ` )
365+
364366 const podContainer = {
365367 name,
366368 image : container . image ,
@@ -387,6 +389,16 @@ export function createContainerSpec(
387389 }
388390 }
389391
392+ if ( tpuRequest > 0 ) {
393+ core . debug ( `assingin tpu to podContainer` )
394+ podContainer . resources = {
395+ limits : {
396+ "google.com/tpu" : String ( tpuRequest )
397+ }
398+ }
399+ core . debug ( `podcontainer is ${ podContainer } ` )
400+ }
401+
390402 podContainer . env . push ( {
391403 name : 'GITHUB_ACTIONS' ,
392404 value : 'true'
0 commit comments