Skip to content

Commit f7fe2e4

Browse files
authored
Merge pull request rook#13350 from rook/mergify/bp/release-1.13/pr-13349
Revert "osd: add callback function in osd removal" (backport rook#13349)
2 parents fa023ea + 2e4f1ec commit f7fe2e4

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

cmd/rook/ceph/osd.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,8 @@ func removeOSDs(cmd *cobra.Command, args []string) error {
326326
return errors.Wrapf(err, "failed to parse --preserve-pvc flag")
327327
}
328328

329-
exitIfNotSafe := false
330-
forceRemovalCallback := func(x int) (bool, bool) {
331-
return forceOSDRemovalBool, exitIfNotSafe
332-
}
333329
// Run OSD remove sequence
334-
err = osddaemon.RemoveOSDs(context, &clusterInfo, strings.Split(osdIDsToRemove, ","), preservePVCBool, forceRemovalCallback)
330+
err = osddaemon.RemoveOSDs(context, &clusterInfo, strings.Split(osdIDsToRemove, ","), preservePVCBool, forceOSDRemovalBool)
335331
if err != nil {
336332
rook.TerminateFatal(err)
337333
}

pkg/daemon/ceph/osd/remove.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
)
3434

3535
// RemoveOSDs purges a list of OSDs from the cluster
36-
func RemoveOSDs(context *clusterd.Context, clusterInfo *client.ClusterInfo, osdsToRemove []string, preservePVC bool, forceRemovalCallback func(osdID int) (bool, bool)) error {
36+
func RemoveOSDs(context *clusterd.Context, clusterInfo *client.ClusterInfo, osdsToRemove []string, preservePVC, forceOSDRemoval bool) error {
3737
// Generate the ceph config for running ceph commands similar to the operator
3838
if err := client.WriteCephConfig(context, clusterInfo); err != nil {
3939
return errors.Wrap(err, "failed to write the ceph config")
@@ -63,13 +63,13 @@ func RemoveOSDs(context *clusterd.Context, clusterInfo *client.ClusterInfo, osds
6363
logger.Infof("osd.%d is marked 'DOWN'", osdID)
6464
}
6565

66-
removeOSD(context, clusterInfo, osdID, preservePVC, forceRemovalCallback)
66+
removeOSD(context, clusterInfo, osdID, preservePVC, forceOSDRemoval)
6767
}
6868

6969
return nil
7070
}
7171

72-
func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInfo, osdID int, preservePVC bool, forceRemovalCallback func(osdID int) (bool, bool)) {
72+
func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInfo, osdID int, preservePVC, forceOSDRemoval bool) {
7373
// Get the host where the OSD is found
7474
hostName, err := client.GetCrushHostName(clusterdContext, clusterInfo, osdID)
7575
if err != nil {
@@ -83,21 +83,17 @@ func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInf
8383
if err != nil {
8484
logger.Errorf("failed to exclude osd.%d out of the crush map. %v", osdID, err)
8585
}
86-
forceRemoval, exitIfNotSafe := forceRemovalCallback(osdID)
86+
8787
// Check we can remove the OSD
8888
// Loop forever until the osd is safe-to-destroy
8989
for {
9090
isSafeToDestroy, err := client.OsdSafeToDestroy(clusterdContext, clusterInfo, osdID)
9191
if err != nil {
9292
// If we want to force remove the OSD and there was an error let's break outside of
9393
// the loop and proceed with the OSD removal
94-
95-
if forceRemoval {
94+
if forceOSDRemoval {
9695
logger.Errorf("failed to check if osd %d is safe to destroy, but force removal is enabled so proceeding with removal. %v", osdID, err)
9796
break
98-
} else if exitIfNotSafe {
99-
logger.Error("osd.%d is not safe to destroy")
100-
return
10197
} else {
10298
logger.Errorf("failed to check if osd %d is safe to destroy, retrying in 1m. %v", osdID, err)
10399
time.Sleep(1 * time.Minute)
@@ -111,12 +107,9 @@ func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInf
111107
break
112108
} else {
113109
// If we arrive here and forceOSDRemoval is true, we should proceed with the OSD removal
114-
if forceRemoval {
110+
if forceOSDRemoval {
115111
logger.Infof("osd.%d is NOT ok to destroy but force removal is enabled so proceeding with removal", osdID)
116112
break
117-
} else if exitIfNotSafe {
118-
logger.Error("osd.%d is not safe to destroy")
119-
return
120113
}
121114
// Else we wait until the OSD can be removed
122115
logger.Warningf("osd.%d is NOT ok to destroy, retrying in 1m until success", osdID)

0 commit comments

Comments
 (0)