Skip to content

Commit

Permalink
Merge pull request #125 from masnax/remote-disks
Browse files Browse the repository at this point in the history
Allow skipping systems for ceph
  • Loading branch information
Stéphane Graber authored Jun 19, 2023
2 parents e200701 + 4969691 commit 5667ec8
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions microcloud/cmd/microcloud/ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,9 @@ func askDisks(sh *service.ServiceHandler, peers map[string]mdns.ServerInfo, boot

var cephDisks map[string][]cephTypes.DisksPost
if sh.Services[types.MicroCeph] != nil {
skipCeph := false
availableDisks := map[string][]lxdAPI.ResourcesStorageDisk{}
for peer, disks := range validDisks {
availableDisks[peer] = []lxdAPI.ResourcesStorageDisk{}
peerDisks := []lxdAPI.ResourcesStorageDisk{}
for _, disk := range disks {
devicePath := fmt.Sprintf("/dev/%s", disk.ID)
if disk.DeviceID != "" {
Expand All @@ -213,16 +212,15 @@ func askDisks(sh *service.ServiceHandler, peers map[string]mdns.ServerInfo, boot
continue
}

availableDisks[peer] = append(availableDisks[peer], disk)
peerDisks = append(availableDisks[peer], disk)
}

if len(availableDisks[peer]) == 0 {
skipCeph = true
break
if len(peerDisks) > 0 {
availableDisks[peer] = peerDisks
}
}

if skipCeph {
if len(availableDisks) < 3 {
fmt.Println("Insufficient number of disks available to set up distributed storage, skipping at this time")
} else {
ceph := sh.Services[types.MicroCeph].(*service.CephService)
Expand All @@ -232,6 +230,13 @@ func askDisks(sh *service.ServiceHandler, peers map[string]mdns.ServerInfo, boot
if err != nil {
return nil, nil, err
}

if len(peers) != len(availableDisks) && wantsDisks {
wantsDisks, err = cli.AskBool("Some systems are ineligible for distributed storage. Continue anyway? (yes/no) [default=yes]: ", "yes")
if err != nil {
return nil, nil, err
}
}
}

if wantsDisks {
Expand Down Expand Up @@ -470,10 +475,8 @@ func askRemotePool(peerDisks map[string][]lxdAPI.ResourcesStorageDisk, autoSetup
}

_, checkMinSize := peerDisks[ceph.Name()]
if len(diskMap) == len(peerDisks) {
if !checkMinSize || len(peerDisks) >= 3 {
return diskMap, nil
}
if !checkMinSize || len(diskMap) >= 3 {
return diskMap, nil
}

return nil, fmt.Errorf("Unable to add remote storage pool: Each peer (minimum 3) must have allocated disks")
Expand Down Expand Up @@ -520,6 +523,17 @@ func askNetwork(sh *service.ServiceHandler, peers map[string]mdns.ServerInfo, lx
return nil, nil, nil
}

if len(peers) != len(networks) {
wantsSkip, err := cli.AskBool("Some systems are ineligible for distributed networking. Continue anyway? (yes/no) [default=yes]: ", "yes")
if err != nil {
return nil, nil, err
}

if !wantsSkip {
return nil, nil, nil
}
}

// Uplink selection table.
header := []string{"LOCATION", "IFACE", "TYPE"}
fmt.Println("Select exactly one network interface from each cluster member:")
Expand Down

0 comments on commit 5667ec8

Please sign in to comment.