Skip to content

Commit

Permalink
Try and fix twin brother switch detection (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
mreiger authored Sep 8, 2022
1 parent e16e42a commit f31fbec
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmd/metal-api/internal/service/switch-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,15 @@ func (r *switchResource) registerSwitch(request *restful.Request, response *rest
// replaceSwitch replaces a broken switch
//
// assumptions:
// - cabling btw. old, new and twin-brother switch in the same rack is "the same" (m1 is connected to swp1s0 at every switch)
// - cabling btw. old, new and twin-brother switch in the same rack is "the same" (m1 is connected to swp1s0 at every switch)
//
// constraints:
// - old, new and twin-brother switch must have the same partition and rack
// - old switch needs to be marked for replacement
// - twin-brother switch must not be marked for replacement (otherwise there would be no valid source of truth)
// - new switch needs all the nics of the twin-brother switch
// - new switch gets the same vrf configuration as the twin-brother switch based on the switch port name
// - new switch gets the same machine connections as the twin-brother switch based on the switch port name
// - old, new and twin-brother switch must have the same partition and rack
// - old switch needs to be marked for replacement
// - twin-brother switch must not be marked for replacement (otherwise there would be no valid source of truth)
// - new switch needs all the nics of the twin-brother switch
// - new switch gets the same vrf configuration as the twin-brother switch based on the switch port name
// - new switch gets the same machine connections as the twin-brother switch based on the switch port name
func (r *switchResource) replaceSwitch(old, new *metal.Switch) error {
twin, err := r.findTwinSwitch(new)
if err != nil {
Expand Down Expand Up @@ -403,6 +403,9 @@ func (r *switchResource) findTwinSwitch(newSwitch *metal.Switch) (*metal.Switch,
if sw.PartitionID != newSwitch.PartitionID {
continue
}
if sw.Mode == metal.SwitchReplace || sw.ID == newSwitch.ID {
continue
}
if twin == nil {
twin = &sw
} else {
Expand Down

0 comments on commit f31fbec

Please sign in to comment.