Skip to content

Commit

Permalink
fix: default GPU resource to 0 if not present (#1789)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Mar 23, 2023
1 parent a7e3cd1 commit 86a9747
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions sdl/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ type v2ComputeResources struct {
Storage v2ResourceStorageArray `yaml:"storage"`
}

// func (sdl *v2ComputeResources) UnmarshalYAML(node *yaml.Node) error {
// res := v2ComputeResources{}
//
// if err := node.Decode(&res); err != nil {
// return err
// }
//
// if res.GPU == nil {
// res.GPU = &v2ResourceGPU {
// Units: 0,
// }
// }
//
// *sdl = res
// return nil
// }

func (sdl *v2ComputeResources) toDGroupResourceUnits() types.ResourceUnits {
if sdl == nil {
return types.ResourceUnits{}
Expand All @@ -47,6 +30,10 @@ func (sdl *v2ComputeResources) toDGroupResourceUnits() types.ResourceUnits {
Units: types.NewResourceValue(uint64(sdl.GPU.Units)),
Attributes: types.Attributes(sdl.GPU.Attributes),
}
} else {
units.GPU = &types.GPU{
Units: types.NewResourceValue(0),
}
}

if sdl.Memory != nil {
Expand Down Expand Up @@ -82,6 +69,10 @@ func toManifestResources(res *v2ComputeResources) types.ResourceUnits {
units.GPU = &types.GPU{
Units: types.NewResourceValue(uint64(res.GPU.Units)),
}
} else {
units.GPU = &types.GPU{
Units: types.NewResourceValue(0),
}
}

if res.Memory != nil {
Expand Down

0 comments on commit 86a9747

Please sign in to comment.