Skip to content

Commit

Permalink
Make MedusaRestoreJob properly match nodes when restoring in-place (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvoncek authored Oct 3, 2023
1 parent 9a50d8b commit 3bbdd74
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
4 changes: 3 additions & 1 deletion pkg/medusa/hostmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ func sortLocations(m map[NodeLocation][]string) []rack {
Rack: k,
DC: DC,
}
nodes := m[loc]
sort.Strings(nodes)
out = append(out,
rack{
Location: loc,
Size: len(m[loc]),
Nodes: m[loc],
Nodes: nodes,
},
)
}
Expand Down
34 changes: 17 additions & 17 deletions pkg/medusa/hostmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ func (client mockgRPCClient) GetBackups(ctx context.Context) ([]*BackupSummary,
BackupName: "remote-backupname",
Nodes: []*BackupNode{
{
Host: "192.168.1.2",
Host: "test-cluster-test-dc1-default-sts-0",
Datacenter: "test-dc1",
Rack: "default",
},
{
Host: "192.168.1.3",
Host: "test-cluster-test-dc1-default-sts-2",
Datacenter: "test-dc1",
Rack: "default",
},
{
Host: "192.168.1.4",
Host: "test-cluster-test-dc1-default-sts-1",
Datacenter: "test-dc1",
Rack: "default",
},
{
Host: "192.168.1.5",
Host: "test-cluster-test-dc2-test-rack1-sts-0",
Datacenter: "test-dc2",
Rack: "test-rack1",
},
{
Host: "192.168.1.6",
Host: "test-cluster-test-dc2-test-rack3-sts-0",
Datacenter: "test-dc2",
Rack: "test-rack2",
Rack: "test-rack3",
},
{
Host: "192.168.1.7",
Host: "test-cluster-test-dc2-test-rack2-sts-0",
Datacenter: "test-dc2",
Rack: "test-rack3",
Rack: "test-rack2",
},
},
},
Expand Down Expand Up @@ -79,9 +79,9 @@ func TestGetSourceRacksIPs(t *testing.T) {
sourceRacks, err := getSourceRacksIPs(*medusaBackup, mockgRPCClient, ctx, "test-dc2")
assert.NoError(t, err, err)
expectedSourceRacks := map[NodeLocation][]string{
{Rack: "test-rack1", DC: "test-dc2"}: {"192.168.1.5"},
{Rack: "test-rack2", DC: "test-dc2"}: {"192.168.1.6"},
{Rack: "test-rack3", DC: "test-dc2"}: {"192.168.1.7"},
{Rack: "test-rack1", DC: "test-dc2"}: {"test-cluster-test-dc2-test-rack1-sts-0"},
{Rack: "test-rack2", DC: "test-dc2"}: {"test-cluster-test-dc2-test-rack2-sts-0"},
{Rack: "test-rack3", DC: "test-dc2"}: {"test-cluster-test-dc2-test-rack3-sts-0"},
}
assert.Equal(t, expectedSourceRacks, sourceRacks)
}
Expand Down Expand Up @@ -176,15 +176,15 @@ func TestGetHostMap(t *testing.T) {
assert.NoError(t, err, err)
expected := HostMappingSlice{
{
Source: "192.168.1.2",
Source: "test-cluster-test-dc1-default-sts-0",
Target: "test-cluster-test-dc1-default-sts-0",
},
{
Source: "192.168.1.3",
Source: "test-cluster-test-dc1-default-sts-1",
Target: "test-cluster-test-dc1-default-sts-1",
},
{
Source: "192.168.1.4",
Source: "test-cluster-test-dc1-default-sts-2",
Target: "test-cluster-test-dc1-default-sts-2",
},
}
Expand All @@ -201,15 +201,15 @@ func TestGetHostMap(t *testing.T) {
cassDc.ObjectMeta.Name = "test-dc2"
expected = HostMappingSlice{
{
Source: "192.168.1.5",
Source: "test-cluster-test-dc2-test-rack1-sts-0",
Target: "test-cluster-test-dc2-rack1-sts-0",
},
{
Source: "192.168.1.6",
Source: "test-cluster-test-dc2-test-rack2-sts-0",
Target: "test-cluster-test-dc2-rack2-sts-0",
},
{
Source: "192.168.1.7",
Source: "test-cluster-test-dc2-test-rack3-sts-0",
Target: "test-cluster-test-dc2-rack3-sts-0",
},
}
Expand Down

0 comments on commit 3bbdd74

Please sign in to comment.