mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 06:20:11 +01:00
feat(zfspv): remove finalizer that is owned by ZFS-LocalPV (#303)
We set the Finalizer to nil while handling the delete event, instead, we should try to destroy the volume when there are no user finalizers set. User might have added his own finalizers and we should not try to destroy the volumes until those user finalizers are removed. Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
parent
9888968fd7
commit
68d79d0e0b
4 changed files with 58 additions and 24 deletions
|
|
@ -77,14 +77,20 @@ func (c *SnapController) syncSnap(snap *apis.ZFSSnapshot) error {
|
|||
var err error
|
||||
// ZFSSnapshot should be deleted. Check if deletion timestamp is set
|
||||
if c.isDeletionCandidate(snap) {
|
||||
err = zfs.DestroySnapshot(snap)
|
||||
if err == nil {
|
||||
zfs.RemoveSnapFinalizer(snap)
|
||||
userFin := zfs.GetUserFinalizers(snap.Finalizers)
|
||||
if len(userFin) == 0 {
|
||||
// destroy only if other finalizers have been removed
|
||||
err = zfs.DestroySnapshot(snap)
|
||||
if err == nil {
|
||||
err = zfs.RemoveSnapFinalizer(snap)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("snapshot: can not destroy, waiting for finalizers to be removed %v", userFin)
|
||||
}
|
||||
} else {
|
||||
// if finalizer is not set then it means we are creating
|
||||
// if status is not Ready then it means we are creating
|
||||
// the zfs snapshot.
|
||||
if snap.Finalizers == nil {
|
||||
if snap.Status.State != zfs.ZFSStatusReady {
|
||||
err = zfs.CreateSnapshot(snap)
|
||||
if err == nil {
|
||||
err = zfs.UpdateSnapInfo(snap)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue