From 979360e85b3dff2d7f616f042a3a7792af8aaaad Mon Sep 17 00:00:00 2001 From: Alexander Trost Date: Mon, 9 Jul 2018 18:36:04 +0200 Subject: [PATCH] osd: skip wait loop when initial PGs or used KBs is 0 for an OSD Resolves #1708 Signed-off-by: Alexander Trost --- pkg/operator/ceph/cluster/osd/remove.go | 39 +++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/pkg/operator/ceph/cluster/osd/remove.go b/pkg/operator/ceph/cluster/osd/remove.go index 5d743c6d6..78ba6a90b 100644 --- a/pkg/operator/ceph/cluster/osd/remove.go +++ b/pkg/operator/ceph/cluster/osd/remove.go @@ -89,11 +89,46 @@ func waitForRebalance(context *clusterd.Context, namespace string, osdID int, in osdID, initialUsage, currUsage) } - if curr.UsedKB == "0" && curr.Pgs == "" { + var initUsedKB, initPGs int64 + if init.UsedKB != "" { + initUsedKB, err = init.UsedKB.Int64() + if err != nil { + return fmt.Errorf("error converting init used KB to int64. %+v", err) + } + } + if init.Pgs != "" { + initPGs, err = init.Pgs.Int64() + if err != nil { + return fmt.Errorf("error converting init PGs to int64. %+v", err) + } + } + + // when the initial OSD PG count or used KB is zero there is nothing to do here + if initPGs == 0 || initUsedKB == 0 { return nil } - if curr.UsedKB >= init.UsedKB && curr.Pgs >= init.Pgs { + var currUsedKB, currPGs int64 + + if curr.UsedKB != "" { + currUsedKB, err = curr.UsedKB.Int64() + if err != nil { + return fmt.Errorf("error converting current used KB to int64. %+v", err) + } + } + + if curr.Pgs != "" { + currPGs, err = curr.Pgs.Int64() + if err != nil { + return fmt.Errorf("error converting current PGs to int64. %+v", err) + } + } + + if currUsedKB == 0 && currPGs == 0 { + return nil + } + + if currUsedKB >= initUsedKB && currPGs >= initPGs { return fmt.Errorf("current used space and pg count for osd.%d has not decreased still. curr=%+v", osdID, curr) }