Skip to content

Commit cc2f7f7

Browse files
clintonkvivintw
andauthored
Allow ONTAP volumes to skip recovery queue on deletion
Co-authored-by: Vivin Thomas Wilson <[email protected]>
1 parent 76d9490 commit cc2f7f7

36 files changed

+1791
-255
lines changed

core/orchestrator_core.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,6 +2364,7 @@ func (o *TridentOrchestrator) cloneVolumeInitial(
23642364
cloneConfig.ReadOnlyClone = volumeConfig.ReadOnlyClone
23652365
cloneConfig.Namespace = volumeConfig.Namespace
23662366
cloneConfig.RequestName = volumeConfig.RequestName
2367+
cloneConfig.SkipRecoveryQueue = volumeConfig.SkipRecoveryQueue
23672368

23682369
// If it's from snapshot, we need the LUKS passphrases value from the snapshot
23692370
isLUKS, err := strconv.ParseBool(cloneConfig.LUKSEncryption)

frontend/csi/controller_helpers/kubernetes/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const (
6060
AnnVolumeShareToNS = annPrefix + "/shareToNamespace"
6161
AnnReadOnlyClone = annPrefix + "/readOnlyClone"
6262
AnnLUKSEncryption = annPrefix + "/luksEncryption" // import only
63+
AnnSkipRecoveryQueue = annPrefix + "/skipRecoveryQueue"
6364
)
6465

6566
var features = map[controllerhelpers.Feature]*versionutils.Version{

frontend/csi/controller_helpers/kubernetes/helper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ func getVolumeConfig(
819819
PreferredTopologies: preferredTopology,
820820
Namespace: pvc.Namespace,
821821
RequestName: pvc.Name,
822+
SkipRecoveryQueue: getAnnotation(annotations, AnnSkipRecoveryQueue),
822823
}
823824
}
824825

mocks/mock_storage_drivers/mock_ontap/mock_api.go

Lines changed: 37 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocks/mock_storage_drivers/mock_ontap/mock_ontap_rest_interface.go

Lines changed: 37 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocks/mock_storage_drivers/mock_ontap/mock_ontap_zapi_interface.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

storage/volume.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type VolumeConfig struct {
6868
SubordinateVolumes map[string]interface{} `json:"-"`
6969
Namespace string `json:"namespace"`
7070
RequestName string `json:"requestName"`
71+
SkipRecoveryQueue string `json:"skipRecoveryQueue"`
7172
}
7273

7374
type VolumeCreatingConfig struct {

storage_drivers/ontap/api/abstraction.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type OntapAPI interface {
6868
) error
6969
FlexgroupMount(ctx context.Context, name, junctionPath string) error
7070
FlexgroupListByPrefix(ctx context.Context, prefix string) (Volumes, error)
71-
FlexgroupDestroy(ctx context.Context, volumeName string, force bool) error
71+
FlexgroupDestroy(ctx context.Context, volumeName string, force, skipRecoveryQueue bool) error
7272
FlexgroupSetSize(ctx context.Context, name, newSize string) error
7373
FlexgroupSize(ctx context.Context, volumeName string) (uint64, error)
7474
FlexgroupUnmount(ctx context.Context, name string, force bool) error
@@ -195,7 +195,7 @@ type OntapAPI interface {
195195
VolumeCloneSplitStart(ctx context.Context, cloneName string) error
196196

197197
VolumeCreate(ctx context.Context, volume Volume) error
198-
VolumeDestroy(ctx context.Context, volumeName string, force bool) error
198+
VolumeDestroy(ctx context.Context, volumeName string, force, skipRecoveryQueue bool) error
199199
VolumeModifySnapshotDirectoryAccess(ctx context.Context, name string, enable bool) error
200200
VolumeExists(ctx context.Context, volumeName string) (bool, error)
201201
VolumeInfo(ctx context.Context, volumeName string) (*Volume, error)
@@ -221,6 +221,8 @@ type OntapAPI interface {
221221
ctx context.Context, volumeName string, desiredStates, abortStates []string,
222222
maxElapsedTime time.Duration,
223223
) (string, error)
224+
VolumeRecoveryQueuePurge(ctx context.Context, recoveryQueueVolumeName string) error
225+
VolumeRecoveryQueueGetName(ctx context.Context, name string) (string, error)
224226
SMBShareCreate(ctx context.Context, shareName, path string) error
225227
SMBShareExists(ctx context.Context, shareName string) (bool, error)
226228
SMBShareDestroy(ctx context.Context, shareName string) error

storage_drivers/ontap/api/abstraction_rest.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,30 @@ func (d OntapAPIREST) VolumeCreate(ctx context.Context, volume Volume) error {
180180
return nil
181181
}
182182

183-
func (d OntapAPIREST) VolumeDestroy(ctx context.Context, name string, force bool) error {
184-
deletionErr := d.api.VolumeDestroy(ctx, name)
183+
func (d OntapAPIREST) VolumeDestroy(ctx context.Context, name string, force, skipRecoveryQueue bool) error {
184+
deletionErr := d.api.VolumeDestroy(ctx, name, skipRecoveryQueue)
185185
if deletionErr != nil {
186186
return fmt.Errorf("error destroying volume %v: %v", name, deletionErr)
187187
}
188188
return nil
189189
}
190190

191+
func (d OntapAPIREST) VolumeRecoveryQueuePurge(ctx context.Context, recoveryQueueVolumeName string) error {
192+
purgeErr := d.api.VolumeRecoveryQueuePurge(ctx, recoveryQueueVolumeName)
193+
if purgeErr != nil {
194+
return fmt.Errorf("error purging volume vfrom recovery queue %v: %v", recoveryQueueVolumeName, purgeErr)
195+
}
196+
return nil
197+
}
198+
199+
func (d OntapAPIREST) VolumeRecoveryQueueGetName(ctx context.Context, name string) (string, error) {
200+
recoveryQueueVolumeName, err := d.api.VolumeRecoveryQueueGetName(ctx, name)
201+
if err != nil {
202+
return "", fmt.Errorf("error listing volumes in recovery queue: %v", err)
203+
}
204+
return recoveryQueueVolumeName, nil
205+
}
206+
191207
func (d OntapAPIREST) VolumeInfo(ctx context.Context, name string) (*Volume, error) {
192208
fields := []string{
193209
"type", "size", "comment", "aggregates", "nas", "guarantee",
@@ -722,7 +738,7 @@ func (d OntapAPIREST) FlexgroupMount(ctx context.Context, name, junctionPath str
722738
return nil
723739
}
724740

725-
func (d OntapAPIREST) FlexgroupDestroy(ctx context.Context, volumeName string, force bool) error {
741+
func (d OntapAPIREST) FlexgroupDestroy(ctx context.Context, volumeName string, force, skipRecoveryQueue bool) error {
726742
if err := d.FlexgroupUnmount(ctx, volumeName, true); err != nil {
727743
return fmt.Errorf("error unmounting volume %v: %v", volumeName, err)
728744
}
@@ -733,7 +749,7 @@ func (d OntapAPIREST) FlexgroupDestroy(ctx context.Context, volumeName string, f
733749
// utilized space. Is that what we want? Or should we just deny the delete, and force the
734750
// user to keep the volume around until all of the clones are gone? If we do that, need a
735751
// way to list the clones. Maybe volume inspect.
736-
deletionErr := d.api.FlexGroupDestroy(ctx, volumeName)
752+
deletionErr := d.api.FlexGroupDestroy(ctx, volumeName, skipRecoveryQueue)
737753
if deletionErr != nil {
738754
return fmt.Errorf("error destroying volume %v: %v", volumeName, deletionErr)
739755
}

storage_drivers/ontap/api/abstraction_rest_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,13 +1459,13 @@ func TestVolumeDestroy(t *testing.T) {
14591459
oapi, rsi := newMockOntapAPIREST(t)
14601460

14611461
// case 1: Delete volume, Positive test
1462-
rsi.EXPECT().VolumeDestroy(ctx, "vol1").Return(nil)
1463-
err := oapi.VolumeDestroy(ctx, "vol1", false)
1462+
rsi.EXPECT().VolumeDestroy(ctx, "vol1", false).Return(nil)
1463+
err := oapi.VolumeDestroy(ctx, "vol1", false, false)
14641464
assert.NoError(t, err, "error returned while deleting a volume")
14651465

14661466
// case 2: Delete volume, returned error.
1467-
rsi.EXPECT().VolumeDestroy(ctx, "vol1").Return(fmt.Errorf("failed to delete volume"))
1468-
err = oapi.VolumeDestroy(ctx, "vol1", false)
1467+
rsi.EXPECT().VolumeDestroy(ctx, "vol1", false).Return(fmt.Errorf("failed to delete volume"))
1468+
err = oapi.VolumeDestroy(ctx, "vol1", false, false)
14691469
assert.Error(t, err, "no error returned while deleting a volume")
14701470
}
14711471

@@ -1863,21 +1863,21 @@ func TestFlexgroupDestroy(t *testing.T) {
18631863

18641864
// case 1: Flexgroup destroy
18651865
rsi.EXPECT().FlexgroupUnmount(ctx, "trident-pvc-1234").Return(nil)
1866-
rsi.EXPECT().FlexGroupDestroy(ctx, "trident-pvc-1234").Return(nil)
1867-
err := oapi.FlexgroupDestroy(ctx, "trident-pvc-1234", true)
1866+
rsi.EXPECT().FlexGroupDestroy(ctx, "trident-pvc-1234", false).Return(nil)
1867+
err := oapi.FlexgroupDestroy(ctx, "trident-pvc-1234", true, false)
18681868
assert.NoError(t, err, "error returned while deleting a volume")
18691869

18701870
// case 2: Flexgroup destroyed returned error
18711871
rsi.EXPECT().FlexgroupUnmount(ctx, "trident-pvc-1234").Return(nil)
1872-
rsi.EXPECT().FlexGroupDestroy(ctx, "trident-pvc-1234").Return(
1872+
rsi.EXPECT().FlexGroupDestroy(ctx, "trident-pvc-1234", false).Return(
18731873
fmt.Errorf("failed to delete flexgroup volume"))
1874-
err = oapi.FlexgroupDestroy(ctx, "trident-pvc-1234", true)
1874+
err = oapi.FlexgroupDestroy(ctx, "trident-pvc-1234", true, false)
18751875
assert.Error(t, err, "no error returned while deleting a volume")
18761876

18771877
// case 3: Flexgroup unmount returned error
18781878
rsi.EXPECT().FlexgroupUnmount(ctx, "trident-pvc-1234").Return(
18791879
fmt.Errorf("failed to unmount flexgroup volume"))
1880-
err = oapi.FlexgroupDestroy(ctx, "trident-pvc-1234", true)
1880+
err = oapi.FlexgroupDestroy(ctx, "trident-pvc-1234", true, false)
18811881
assert.Error(t, err, "no error returned while deleting a volume")
18821882
}
18831883

0 commit comments

Comments
 (0)