@@ -33,7 +33,7 @@ import (
33
33
)
34
34
35
35
// 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 {
37
37
// Generate the ceph config for running ceph commands similar to the operator
38
38
if err := client .WriteCephConfig (context , clusterInfo ); err != nil {
39
39
return errors .Wrap (err , "failed to write the ceph config" )
@@ -63,13 +63,13 @@ func RemoveOSDs(context *clusterd.Context, clusterInfo *client.ClusterInfo, osds
63
63
logger .Infof ("osd.%d is marked 'DOWN'" , osdID )
64
64
}
65
65
66
- removeOSD (context , clusterInfo , osdID , preservePVC , forceRemovalCallback )
66
+ removeOSD (context , clusterInfo , osdID , preservePVC , forceOSDRemoval )
67
67
}
68
68
69
69
return nil
70
70
}
71
71
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 ) {
73
73
// Get the host where the OSD is found
74
74
hostName , err := client .GetCrushHostName (clusterdContext , clusterInfo , osdID )
75
75
if err != nil {
@@ -83,21 +83,17 @@ func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInf
83
83
if err != nil {
84
84
logger .Errorf ("failed to exclude osd.%d out of the crush map. %v" , osdID , err )
85
85
}
86
- forceRemoval , exitIfNotSafe := forceRemovalCallback ( osdID )
86
+
87
87
// Check we can remove the OSD
88
88
// Loop forever until the osd is safe-to-destroy
89
89
for {
90
90
isSafeToDestroy , err := client .OsdSafeToDestroy (clusterdContext , clusterInfo , osdID )
91
91
if err != nil {
92
92
// If we want to force remove the OSD and there was an error let's break outside of
93
93
// the loop and proceed with the OSD removal
94
-
95
- if forceRemoval {
94
+ if forceOSDRemoval {
96
95
logger .Errorf ("failed to check if osd %d is safe to destroy, but force removal is enabled so proceeding with removal. %v" , osdID , err )
97
96
break
98
- } else if exitIfNotSafe {
99
- logger .Error ("osd.%d is not safe to destroy" )
100
- return
101
97
} else {
102
98
logger .Errorf ("failed to check if osd %d is safe to destroy, retrying in 1m. %v" , osdID , err )
103
99
time .Sleep (1 * time .Minute )
@@ -111,12 +107,9 @@ func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInf
111
107
break
112
108
} else {
113
109
// If we arrive here and forceOSDRemoval is true, we should proceed with the OSD removal
114
- if forceRemoval {
110
+ if forceOSDRemoval {
115
111
logger .Infof ("osd.%d is NOT ok to destroy but force removal is enabled so proceeding with removal" , osdID )
116
112
break
117
- } else if exitIfNotSafe {
118
- logger .Error ("osd.%d is not safe to destroy" )
119
- return
120
113
}
121
114
// Else we wait until the OSD can be removed
122
115
logger .Warningf ("osd.%d is NOT ok to destroy, retrying in 1m until success" , osdID )
0 commit comments