Skip to content

Commit

Permalink
Fix for feature 1647 that allows non gpu k8s accelerator resources. (#…
Browse files Browse the repository at this point in the history
…1649)

Signed-off-by: Mike Smoot <msmoot@illumina.com>
  • Loading branch information
mes5k committed Jun 24, 2020
1 parent afc4375 commit c1efa29
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Expand Up @@ -396,17 +396,33 @@ class PodSpecBuilder {
return pod
}


@PackageScope
@CompileDynamic
String getAcceleratorType(AcceleratorResource accelerator) {

def type = accelerator.type ?: 'nvidia.com'

if ( type.contains('/') )
// Assume the user has fully specified the resource type.
return type

// Assume we're using GPU and update as necessary.
if( !type.contains('.') ) type += '.com'
type += '/gpu'

return type
}


@PackageScope
@CompileDynamic
Map addAcceleratorResources(AcceleratorResource accelerator, Map res) {

if( res == null )
res = new LinkedHashMap(2)

// tpu gou custom resource type
def type = accelerator.type ?: 'nvidia.com'
if( !type.contains('.') ) type += '.com'
type += '/gpu'
def type = getAcceleratorType(accelerator)

if( accelerator.request ) {
final req = res.requests ?: new LinkedHashMap<>(2)
Expand Down
Expand Up @@ -627,6 +627,17 @@ class PodSpecBuilderTest extends Specification {
res.requests == ['foo.org/gpu': 5]
res.limits == [cpus:2, 'foo.org/gpu': 10]

when:
res = builder.addAcceleratorResources(new AcceleratorResource(request: 5, type:'example.com/fpga'), null)
then:
res.requests == ['example.com/fpga': 5]
res.limits == null

when:
res = builder.addAcceleratorResources(new AcceleratorResource(request: 5, limit: 10, type:'example.com/fpga'), [limits: [cpus: 2]])
then:
res.requests == ['example.com/fpga': 5]
res.limits == [cpus:2, 'example.com/fpga': 10]
}


Expand Down

0 comments on commit c1efa29

Please sign in to comment.