mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 14:30:12 +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
|
|
@ -78,15 +78,20 @@ func (c *ZVController) syncZV(zv *apis.ZFSVolume) error {
|
|||
var err error
|
||||
// ZFS Volume should be deleted. Check if deletion timestamp is set
|
||||
if c.isDeletionCandidate(zv) {
|
||||
err = zfs.DestroyVolume(zv)
|
||||
if err == nil {
|
||||
zfs.RemoveZvolFinalizer(zv)
|
||||
userFin := zfs.GetUserFinalizers(zv.Finalizers)
|
||||
if len(userFin) == 0 {
|
||||
// destroy only if other finalizers have been removed
|
||||
err = zfs.DestroyVolume(zv)
|
||||
if err == nil {
|
||||
err = zfs.RemoveVolumeFinalizer(zv)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("volume: can not destroy, waiting for finalizers to be removed %v", userFin)
|
||||
}
|
||||
} else {
|
||||
// if finalizer is not set then it means we are creating
|
||||
// the volume. And if it is set then volume has already been
|
||||
// created and this event is for property change only.
|
||||
if zv.Finalizers != nil {
|
||||
// if volume has already been created and its state is Ready
|
||||
// then this event is for property change only.
|
||||
if zfs.IsVolumeReady(zv) {
|
||||
err = zfs.SetVolumeProp(zv)
|
||||
} else {
|
||||
if len(zv.Spec.SnapName) > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue