Skip to content

Commit

Permalink
fix(pvc): fixing stale ZFSVolume CR issue when deleting pending PVC
Browse files Browse the repository at this point in the history
PVC will not bound if there is wrong parameters/poolname in the storageclass,
the ZFSVolume CR will be still created and will remain in Pending State,
deletion of the PVC will delete PVC and since PVC is not bound, ZFS-LocalPV
driver will not get the delete call and will leave the ZFSVolume CR hanging there.
Reverting the behavior introduced in openebs#121,
Now PVC will be bound but still ZFSVolume will be in Pending state until the volume is created.

Signed-off-by: Pawan <pawan@mayadata.io>
  • Loading branch information
pawanpraka1 committed Jun 4, 2020
1 parent 377b881 commit 10682a1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/145-pawanpraka1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixing stale ZFSVolume resource
22 changes: 0 additions & 22 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,6 @@ func (cs *controller) CreateVolume(
return nil, err
}

selected, state, err := zfs.GetZFSVolumeState(req.Name)

if err == nil {
// ZFSVolume CR has been created, check if it is in Ready state
if state == zfs.ZFSStatusReady {
goto CreateVolumeResponse
}
return nil, status.Errorf(codes.Internal, "volume %s creation is Pending", volName)
}

if contentSource != nil && contentSource.GetSnapshot() != nil {
snapshotID := contentSource.GetSnapshot().GetSnapshotId()

Expand All @@ -231,18 +221,6 @@ func (cs *controller) CreateVolume(
return nil, status.Error(codes.Internal, err.Error())
}

_, state, err = zfs.GetZFSVolumeState(req.Name)

if err != nil {
return nil, status.Errorf(codes.Internal, "createvolume: failed to fetch the volume %v", err.Error())
}

if state == zfs.ZFSStatusPending {
return nil, status.Errorf(codes.Internal, "volume %s is being created", volName)
}

CreateVolumeResponse:

sendEventOrIgnore(volName, strconv.FormatInt(int64(size), 10), "zfs-localpv", analytics.VolumeProvision)

topology := map[string]string{zfs.ZFSTopologyKey: selected}
Expand Down

0 comments on commit 10682a1

Please sign in to comment.