Skip to content

Commit

Permalink
fix: GPU attributes must be empty if units 0
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Jun 13, 2023
1 parent d879c24 commit f91f9a8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions go/node/deployment/v1beta3/resource_list_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,16 @@ func validateGPU(u *types.GPU) (sdk.Int, error) {
if u == nil {
return sdk.Int{}, fmt.Errorf("error: invalid unit GPU, cannot be nil")
}

if (u.Units.Value() > uint64(validationConfig.MaxUnitGPU)) || (u.Units.Value() < uint64(validationConfig.MinUnitGPU)) {
return sdk.Int{}, fmt.Errorf("error: invalid unit GPU (%v > %v > %v fails)",
validationConfig.MaxUnitGPU, u.Units.Value(), validationConfig.MinUnitGPU)
}

if u.Units.Value() == 0 && len(u.Attributes) > 0 {
return sdk.Int{}, fmt.Errorf("error: invalid GPU state. attributes cannot be present if units == 0")
}

if err := u.Attributes.Validate(); err != nil {
return sdk.Int{}, fmt.Errorf("error: invalid GPU attributes: %w", err)
}
Expand Down

0 comments on commit f91f9a8

Please sign in to comment.