Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Sabaini <[email protected]>
  • Loading branch information
sabaini committed Oct 17, 2023
1 parent be66ac9 commit 79b2339
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions microceph/cmd/microceph/cluster_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ func removeNode(cli *microCli.Client, node string, force bool) error {

// check prerquisites unless we're forcing
if !force {
ok, err := checkPrerequisites(cli, node)
err := checkPrerequisites(cli, node)
if err != nil {
return fmt.Errorf("Error checking prereqs: %v", err)
}
if !ok {
return fmt.Errorf("Prerequisites not met, not removing: %v", err)
return err
}
}

Expand All @@ -84,11 +81,11 @@ func removeNode(cli *microCli.Client, node string, force bool) error {
return nil
}

func checkPrerequisites(cli *microCli.Client, name string) (bool, error) {
func checkPrerequisites(cli *microCli.Client, name string) error {
// check if member exists
clusterMembers, err := client.MClient.GetClusterMembers(cli)
if err != nil {
return false, err
return fmt.Errorf("Error getting cluster members: %v", err)
}
found := false
for _, member := range clusterMembers {
Expand All @@ -97,13 +94,13 @@ func checkPrerequisites(cli *microCli.Client, name string) (bool, error) {
}
}
if !found {
return false, fmt.Errorf("Node %v not found", name)
return fmt.Errorf("Node %v not found", name)
}

// check if any OSDs present
disks, err := client.MClient.GetDisks(cli)
if err != nil {
return false, err
return fmt.Errorf("Error getting disks: %v", err)
}
found = false
for _, disk := range disks {
Expand All @@ -113,13 +110,13 @@ func checkPrerequisites(cli *microCli.Client, name string) (bool, error) {
}
logger.Debugf("Disks: %v, found: %v", disks, found)
if found {
return false, fmt.Errorf("Node %v still has disks configured, remove before proceeding", name)
return fmt.Errorf("Node %v still has disks configured, remove before proceeding", name)
}

// check if this node has the last mon
services, err := client.MClient.GetServices(cli)
if err != nil {
return false, err
return fmt.Errorf("Error getting services: %v", err)
}
// create a map of service names to bool values
// init with false
Expand All @@ -137,10 +134,10 @@ func checkPrerequisites(cli *microCli.Client, name string) (bool, error) {
}
logger.Debugf("Services: %v, foundMap: %v", services, foundMap)
if !foundMap["mon"] || !foundMap["mgr"] || !foundMap["mds"] {
return false, fmt.Errorf("Need at least one mon, mds, and mgr besides %v", name)
return fmt.Errorf("Need at least one mon, mds, and mgr besides %v", name)
}

return true, nil
return nil
}

func deleteNodeServices(cli *microCli.Client, name string) error {
Expand Down

0 comments on commit 79b2339

Please sign in to comment.