Skip to content

Commit

Permalink
Machine Registration must now contain Partition
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Oct 11, 2024
1 parent 84cf9d8 commit 94910c3
Show file tree
Hide file tree
Showing 11 changed files with 386 additions and 735 deletions.
3 changes: 2 additions & 1 deletion cmd/metal-api/internal/datastore/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ func (rs *RethinkStore) SetVrfAtSwitches(m *metal.Machine, vrf string) (metal.Sw
}

func (rs *RethinkStore) ConnectMachineWithSwitches(m *metal.Machine) error {
switches, err := rs.ListSwitches()
var switches metal.Switches
err := rs.SearchSwitches(&SwitchSearchQuery{PartitionID: &m.PartitionID}, &switches)
if err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/metal-api/internal/grpc/boot-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ func (b *BootService) Register(ctx context.Context, req *v1.BootServiceRegisterR
Value: metal.LEDStateOff,
Description: "Machine registered",
},
Tags: req.Tags,
IPMI: ipmi,
Tags: req.Tags,
IPMI: ipmi,
PartitionID: req.PartitionId,
}

err = b.ds.CreateMachine(m)
Expand Down Expand Up @@ -269,7 +270,7 @@ func (b *BootService) Register(ctx context.Context, req *v1.BootServiceRegisterR
old := *m
err = retry.Do(
func() error {
// RackID and PartitionID is set
// RackID is set here
err := b.ds.ConnectMachineWithSwitches(m)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/switch-service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func TestConnectMachineWithSwitches(t *testing.T) {
for i := range tests {
tt := tests[i]
ds, mock := datastore.InitMockDB(t)
mock.On(r.DB("mockdb").Table("switch")).Return(testSwitches, nil)
mock.On(r.DB("mockdb").Table("switch").Filter(r.MockAnything())).Return(testSwitches, nil)
mock.On(r.DB("mockdb").Table("switch").Get(r.MockAnything()).Replace(r.MockAnything())).Return(testdata.EmptyResult, nil)

t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading

0 comments on commit 94910c3

Please sign in to comment.