mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-11 22:10:11 +01:00
fix(destroy): making ZFS-LocalPV aware of pool import (#406)
If we are destroying a volume/snapshot and pool is not imported, the ZFS-LocalPV driver assumes that the volume/snapshot is not there and deletes the corresponding zfsvolume and zfssnap CR. Here we are checking the parent dataset presence before attempting to delete the volume or snapshot. Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
parent
ea246090af
commit
5a6f3a745b
1 changed files with 20 additions and 0 deletions
|
|
@ -621,6 +621,15 @@ func SetVolumeProp(vol *apis.ZFSVolume) error {
|
||||||
// DestroyVolume deletes the zfs volume
|
// DestroyVolume deletes the zfs volume
|
||||||
func DestroyVolume(vol *apis.ZFSVolume) error {
|
func DestroyVolume(vol *apis.ZFSVolume) error {
|
||||||
volume := vol.Spec.PoolName + "/" + vol.Name
|
volume := vol.Spec.PoolName + "/" + vol.Name
|
||||||
|
parentDataset := vol.Spec.PoolName
|
||||||
|
|
||||||
|
// check if parent dataset is present or not before attempting to delete the volume
|
||||||
|
if err := getVolume(parentDataset); err != nil {
|
||||||
|
klog.Errorf(
|
||||||
|
"destroy: parent dataset %v is not present, error: %s", parentDataset, err.Error(),
|
||||||
|
)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := getVolume(volume); err != nil {
|
if err := getVolume(volume); err != nil {
|
||||||
klog.Errorf(
|
klog.Errorf(
|
||||||
|
|
@ -697,6 +706,17 @@ func DestroySnapshot(snap *apis.ZFSSnapshot) error {
|
||||||
volume := snap.Labels[ZFSVolKey]
|
volume := snap.Labels[ZFSVolKey]
|
||||||
snapDataset := snap.Spec.PoolName + "/" + volume + "@" + snap.Name
|
snapDataset := snap.Spec.PoolName + "/" + volume + "@" + snap.Name
|
||||||
|
|
||||||
|
parentDataset := snap.Spec.PoolName
|
||||||
|
|
||||||
|
// check if parent dataset is present or not before attempting to delete the snapshot
|
||||||
|
if err := getVolume(parentDataset); err != nil {
|
||||||
|
klog.Errorf(
|
||||||
|
"destroy: snapshot's(%v) parent dataset %v is not present, error: %s",
|
||||||
|
snapDataset, parentDataset, err.Error(),
|
||||||
|
)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := getVolume(snapDataset); err != nil {
|
if err := getVolume(snapDataset); err != nil {
|
||||||
klog.Errorf(
|
klog.Errorf(
|
||||||
"destroy: snapshot %v is not present, error: %s", volume, err.Error(),
|
"destroy: snapshot %v is not present, error: %s", volume, err.Error(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue