Skip to content

Commit

Permalink
Show which osds are going to be stoped.
Browse files Browse the repository at this point in the history
Signed-off-by: Chi Wai Chan <[email protected]>
  • Loading branch information
chanchiwai-ray committed Jan 2, 2025
1 parent 23953b5 commit 5d850e1
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions microceph/ceph/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type Operation interface {
type ClusterOps struct {
CephClient client.ClientInterface
ClusterClient *microCli.Client

}

// CheckNodeInClusterOps is an operation to check if a node is in the microceph cluster.
Expand Down Expand Up @@ -75,16 +74,9 @@ type CheckOsdOkToStopOps struct {

// Run checks osds in a node are ok-to-stop.
func (o *CheckOsdOkToStopOps) Run(name string) error {
disks, err := o.CephClient.GetDisks(o.ClusterClient)
OsdsToCheck, err := o.getOsds(name)
if err != nil {
return fmt.Errorf("error getting disks: %v", err)
}

OsdsToCheck := []int64{}
for _, disk := range disks {
if disk.Location == name {
OsdsToCheck = append(OsdsToCheck, disk.OSD)
}
return err
}

if !testSafeStop(OsdsToCheck) {
Expand All @@ -97,7 +89,23 @@ func (o *CheckOsdOkToStopOps) Run(name string) error {

// DryRun prints out the action plan.
func (o *CheckOsdOkToStopOps) DryRun(name string) string {
return fmt.Sprintf("Check if osds in node '%s' are ok-to-stop.", name)
osdsToCheck, _ := o.getOsds(name)
return fmt.Sprintf("Check if osds.%v in node '%s' are ok-to-stop.", osdsToCheck, name)
}

func (o *CheckOsdOkToStopOps) getOsds(name string) ([]int64, error) {
disks, err := o.CephClient.GetDisks(o.ClusterClient)
if err != nil {
return []int64{}, fmt.Errorf("error getting disks: %v", err)
}

OsdsToCheck := []int64{}
for _, disk := range disks {
if disk.Location == name {
OsdsToCheck = append(OsdsToCheck, disk.OSD)
}
}
return OsdsToCheck, nil
}

// CheckNonOsdSvcEnoughOps is an operation to check if non-osd service in a node are enough.
Expand Down Expand Up @@ -144,7 +152,7 @@ func (o *CheckNonOsdSvcEnoughOps) DryRun(name string) string {
}

// SetNooutOps is an operation to set noout for the ceph cluster.
type SetNooutOps struct{
type SetNooutOps struct {
ClusterOps
}

Expand All @@ -163,7 +171,7 @@ func (o *SetNooutOps) DryRun(name string) string {
}

// AssertNooutFlagSetOps is an operation to assert noout has been set for the ceph cluster.
type AssertNooutFlagSetOps struct{
type AssertNooutFlagSetOps struct {
ClusterOps
}

Expand All @@ -186,7 +194,7 @@ func (o *AssertNooutFlagSetOps) DryRun(name string) string {
}

// AssertNooutFlagUnsetOps is an operation to assert noout has been unset for the ceph cluster.
type AssertNooutFlagUnsetOps struct{
type AssertNooutFlagUnsetOps struct {
ClusterOps
}

Expand Down Expand Up @@ -251,7 +259,7 @@ func (o *StartOsdOps) DryRun(name string) string {
}

// UnsetNooutOps is an operation to unset noout for the ceph cluster.
type UnsetNooutOps struct{
type UnsetNooutOps struct {
ClusterOps
}

Expand Down

0 comments on commit 5d850e1

Please sign in to comment.