Skip to content

Commit

Permalink
Merge pull request #341 from masnax/sort-disks
Browse files Browse the repository at this point in the history
cmd/microcloud: Force disk ordering by path name

(cherry picked from commit 359cd46)
Signed-off-by: Max Asnaashari <[email protected]>
  • Loading branch information
masnax committed Dec 17, 2024
1 parent 72d3872 commit 8d0dc3f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions microcloud/cmd/microcloud/ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,13 @@ func askLocalPool(systems map[string]InitSystem, autoSetup bool, wipeAllDisks bo
return nil
}

for _, disk := range system.AvailableDisks {
sortedDisks := make([]api.ResourcesStorageDisk, 0, len(system.AvailableDisks))
sortedDisks = append(sortedDisks, system.AvailableDisks...)
sort.Slice(sortedDisks, func(i, j int) bool {
return parseDiskPath(sortedDisks[i]) < parseDiskPath(sortedDisks[j])
})

for _, disk := range sortedDisks {
devicePath := parseDiskPath(disk)
data = append(data, []string{peer, disk.Model, units.GetByteSizeStringIEC(int64(disk.Size), 2), disk.Type, devicePath})

Expand Down Expand Up @@ -404,7 +410,13 @@ func askRemotePool(systems map[string]InitSystem, autoSetup bool, wipeAllDisks b
header := []string{"LOCATION", "MODEL", "CAPACITY", "TYPE", "PATH"}
data := [][]string{}
for peer, system := range systems {
for _, disk := range system.AvailableDisks {
sortedDisks := make([]api.ResourcesStorageDisk, 0, len(system.AvailableDisks))
sortedDisks = append(sortedDisks, system.AvailableDisks...)
sort.Slice(sortedDisks, func(i, j int) bool {
return parseDiskPath(sortedDisks[i]) < parseDiskPath(sortedDisks[j])
})

for _, disk := range sortedDisks {
// Skip any disks that have been reserved for the local storage pool.
devicePath := parseDiskPath(disk)
data = append(data, []string{peer, disk.Model, units.GetByteSizeStringIEC(int64(disk.Size), 2), disk.Type, devicePath})
Expand Down

0 comments on commit 8d0dc3f

Please sign in to comment.