osd: osdSafeToDestroy check should be after osd out
currently, osdSafeToDestroy check is done before
marking osd out which prevents ceph from rebalancing.
With this changes, we are moving check for
osdSafeToDestroy after osd is marked out.
Signed-off-by: subhamkrai <srai@redhat.com>
(cherry picked from commit 77f9e0d5b6)
This commit is contained in:
1 parent
15f6692bad
commit
d076f343d5
1 file changed
+35
-35
@@ -62,46 +62,13 @@ func RemoveOSDs(context *clusterd.Context, clusterInfo *client.ClusterInfo, osds
|
||||
logger.Infof("osd.%d is marked 'DOWN'", osdID)
|
||||
}
|
||||
|
||||
// Check we can remove the OSD
|
||||
// Loop forever until the osd is safe-to-destroy
|
||||
for {
|
||||
isSafeToDestroy, err := client.OsdSafeToDestroy(context, clusterInfo, osdID)
|
||||
if err != nil {
|
||||
// If we want to force remove the OSD and there was an error let's break outside of
|
||||
// the loop and proceed with the OSD removal
|
||||
if forceOSDRemoval {
|
||||
logger.Errorf("failed to check if osd %d is safe to destroy, but force removal is enabled so proceeding with removal. %v", osdID, err)
|
||||
break
|
||||
} else {
|
||||
logger.Errorf("failed to check if osd %d is safe to destroy, retrying in 1m. %v", osdID, err)
|
||||
time.Sleep(1 * time.Minute)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// If no error and the OSD is safe to destroy, we can proceed with the OSD removal
|
||||
if isSafeToDestroy {
|
||||
logger.Infof("osd.%d is safe to destroy, proceeding", osdID)
|
||||
break
|
||||
} else {
|
||||
// If we arrive here and forceOSDRemoval is true, we should proceed with the OSD removal
|
||||
if forceOSDRemoval {
|
||||
logger.Infof("osd.%d is NOT be ok to destroy but force removal is enabled so proceeding with removal", osdID)
|
||||
break
|
||||
}
|
||||
// Else we wait until the OSD can be removed
|
||||
logger.Warningf("osd.%d is NOT be ok to destroy, retrying in 1m until success", osdID)
|
||||
time.Sleep(1 * time.Minute)
|
||||
}
|
||||
}
|
||||
|
||||
removeOSD(context, clusterInfo, osdID, preservePVC)
|
||||
removeOSD(context, clusterInfo, osdID, preservePVC, forceOSDRemoval)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInfo, osdID int, preservePVC bool) {
|
||||
func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInfo, osdID int, preservePVC, forceOSDRemoval bool) {
|
||||
// Get the host where the OSD is found
|
||||
hostName, err := client.GetCrushHostName(clusterdContext, clusterInfo, osdID)
|
||||
if err != nil {
|
||||
@@ -116,6 +83,39 @@ func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInf
|
||||
logger.Errorf("failed to exclude osd.%d out of the crush map. %v", osdID, err)
|
||||
}
|
||||
|
||||
// Check we can remove the OSD
|
||||
// Loop forever until the osd is safe-to-destroy
|
||||
for {
|
||||
isSafeToDestroy, err := client.OsdSafeToDestroy(clusterdContext, clusterInfo, osdID)
|
||||
if err != nil {
|
||||
// If we want to force remove the OSD and there was an error let's break outside of
|
||||
// the loop and proceed with the OSD removal
|
||||
if forceOSDRemoval {
|
||||
logger.Errorf("failed to check if osd %d is safe to destroy, but force removal is enabled so proceeding with removal. %v", osdID, err)
|
||||
break
|
||||
} else {
|
||||
logger.Errorf("failed to check if osd %d is safe to destroy, retrying in 1m. %v", osdID, err)
|
||||
time.Sleep(1 * time.Minute)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// If no error and the OSD is safe to destroy, we can proceed with the OSD removal
|
||||
if isSafeToDestroy {
|
||||
logger.Infof("osd.%d is safe to destroy, proceeding", osdID)
|
||||
break
|
||||
} else {
|
||||
// If we arrive here and forceOSDRemoval is true, we should proceed with the OSD removal
|
||||
if forceOSDRemoval {
|
||||
logger.Infof("osd.%d is NOT be ok to destroy but force removal is enabled so proceeding with removal", osdID)
|
||||
break
|
||||
}
|
||||
// Else we wait until the OSD can be removed
|
||||
logger.Warningf("osd.%d is NOT be ok to destroy, retrying in 1m until success", osdID)
|
||||
time.Sleep(1 * time.Minute)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the OSD deployment
|
||||
deploymentName := fmt.Sprintf("rook-ceph-osd-%d", osdID)
|
||||
deployment, err := clusterdContext.Clientset.AppsV1().Deployments(clusterInfo.Namespace).Get(clusterInfo.Context, deploymentName, metav1.GetOptions{})
|
||||
|
||||
Reference in new issue
Block a user