Skip to content

Commit

Permalink
fix(cspi): remove finalizer on claim of blockdevice which underwent r…
Browse files Browse the repository at this point in the history
…eplacement (#71) (#72)

Signed-off-by: mittachaitu <sai.chaithanya@mayadata.io>
  • Loading branch information
sai chaithanya authored May 13, 2020
1 parent e432807 commit 0f16def
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/pool/operations/pool_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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
}

Expand Down

0 comments on commit 0f16def

Please sign in to comment.