Skip to content

Commit 503e30e

Browse files
authored
🌱 Choose HetznerBareMetalHosts with RootDeviceHints set over… (#1197)
🌱 Choose HetznerBareMetalHosts with RootDeviceHints set over those ones without
1 parent 769847c commit 503e30e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/services/baremetal/baremetal/baremetal.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,18 @@ func (s *Service) chooseHost(ctx context.Context) (
476476
return nil, nil, reasonString(mapOfSkipReasons, unusedHostsCounter), nil
477477
}
478478

479+
// Choose HetznerBareMetalHosts with RootDeviceHints set over those ones without
480+
hostsWithRootDeviceHints := make([]*infrav1.HetznerBareMetalHost, 0, len(availableHosts))
481+
for _, host := range availableHosts {
482+
if host.Spec.RootDeviceHints == nil {
483+
continue
484+
}
485+
hostsWithRootDeviceHints = append(hostsWithRootDeviceHints, host)
486+
}
487+
if len(hostsWithRootDeviceHints) > 0 {
488+
availableHosts = hostsWithRootDeviceHints
489+
}
490+
479491
// we found available hosts - choose one
480492
randomNumber, err := rand.Int(rand.Reader, big.NewInt(int64(len(availableHosts))))
481493
if err != nil {

0 commit comments

Comments
 (0)