From 84e9d985dbc11ca10fc67b4e14ce223b0d4fbf3f Mon Sep 17 00:00:00 2001 From: sai chaithanya Date: Wed, 13 May 2020 13:36:21 +0530 Subject: [PATCH] fix(cspi): remove finalizer on claim of blockdevice which underwent replacement (#71) Signed-off-by: mittachaitu --- pkg/pool/operations/pool_utils.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/pool/operations/pool_utils.go b/pkg/pool/operations/pool_utils.go index 6b168e0b..a68a8474 100644 --- a/pkg/pool/operations/pool_utils.go +++ b/pkg/pool/operations/pool_utils.go @@ -291,7 +291,19 @@ func getVdevFromPath(path string, topology zpool.Topology) (zpool.Vdev, bool) { // by pool func (oc *OperationsConfig) cleanUpReplacementMarks(oldObj, newObj *openebsapis.BlockDeviceClaim) error { if oldObj != nil { - oldObj.RemoveFinalizer(types.CSPCFinalizer) + if util.ContainsString(oldObj.Finalizers, types.CSPCFinalizer) { + oldObj.RemoveFinalizer(types.CSPCFinalizer) + _, err := oc.openebsclientset.OpenebsV1alpha1().BlockDeviceClaims(oldObj.Namespace).Update(oldObj) + if err != nil { + return errors.Wrapf( + err, + "Failed to remove finalizer %s on claim %s of blockdevice %s", + types.CSPCFinalizer, + oldObj.Name, + oldObj.Spec.BlockDeviceName, + ) + } + } err := oc.openebsclientset.OpenebsV1alpha1().BlockDeviceClaims(newObj.Namespace).Delete(oldObj.Name, &metav1.DeleteOptions{}) if err != nil { return errors.Wrapf( @@ -300,6 +312,7 @@ func (oc *OperationsConfig) cleanUpReplacementMarks(oldObj, newObj *openebsapis. oldObj.Spec.BlockDeviceName, ) } + klog.Infof("Triggered deletion on claim %s of blockdevice %s", oldObj.Name, oldObj.Spec.BlockDeviceName) } bdAnnotations := newObj.GetAnnotations() delete(bdAnnotations, types.PredecessorBDLabelKey) @@ -313,6 +326,7 @@ func (oc *OperationsConfig) cleanUpReplacementMarks(oldObj, newObj *openebsapis. newObj.Name, ) } + klog.Infof("Cleared replacement marks on blockdevice %s", newObj.Name) return nil }