Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelStuchly committed Sep 2, 2021
1 parent 1ffb207 commit de31e37
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/cloud/gcp/actuators/machine/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,15 @@ func (r *Reconciler) create() error {
}

var guestAccelerators = []*compute.AcceleratorConfig{}
// guestAccelerators slice can not be longer than 1
guestAccelerators = append(guestAccelerators, &compute.AcceleratorConfig{
AcceleratorType: fmt.Sprintf(acceleratorTypeFmt, zone, r.providerSpec.GuestAccelerators[0].AcceleratorType),
AcceleratorCount: r.providerSpec.GuestAccelerators[0].AcceleratorCount,
})

if l := len(r.providerSpec.GuestAccelerators); l == 1 {
guestAccelerators = append(guestAccelerators, &compute.AcceleratorConfig{
AcceleratorType: fmt.Sprintf(acceleratorTypeFmt, zone, r.providerSpec.GuestAccelerators[0].AcceleratorType),
AcceleratorCount: r.providerSpec.GuestAccelerators[0].AcceleratorCount,
})
} else if l > 1 {
return machinecontroller.InvalidMachineConfiguration(fmt.Sprint("More than one type of accelerator provided. Instances support only one accelerator type at a time."))
}

instance.GuestAccelerators = guestAccelerators

Expand Down

0 comments on commit de31e37

Please sign in to comment.