Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-v1.57] Set clone strategy for ceph to CSI clone #2817

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pkg/storagecapabilities/storagecapabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ var SourceFormatsByProvisionerKey = map[string]cdiv1.DataImportCronSourceFormat{

// CloneStrategyByProvisionerKey defines the advised clone strategy for a provisioner
var CloneStrategyByProvisionerKey = map[string]cdiv1.CDICloneStrategy{
"csi-vxflexos.dellemc.com": cdiv1.CloneStrategyCsiClone,
"csi-isilon.dellemc.com": cdiv1.CloneStrategyCsiClone,
"csi-powermax.dellemc.com": cdiv1.CloneStrategyCsiClone,
"csi-powerstore.dellemc.com": cdiv1.CloneStrategyCsiClone,
"hspc.csi.hitachi.com": cdiv1.CloneStrategyCsiClone,
"csi.hpe.com": cdiv1.CloneStrategyCsiClone,
"spectrumscale.csi.ibm.com": cdiv1.CloneStrategyCsiClone,
"csi-vxflexos.dellemc.com": cdiv1.CloneStrategyCsiClone,
"csi-isilon.dellemc.com": cdiv1.CloneStrategyCsiClone,
"csi-powermax.dellemc.com": cdiv1.CloneStrategyCsiClone,
"csi-powerstore.dellemc.com": cdiv1.CloneStrategyCsiClone,
"hspc.csi.hitachi.com": cdiv1.CloneStrategyCsiClone,
"csi.hpe.com": cdiv1.CloneStrategyCsiClone,
"spectrumscale.csi.ibm.com": cdiv1.CloneStrategyCsiClone,
"rook-ceph.rbd.csi.ceph.com": cdiv1.CloneStrategyCsiClone,
"openshift-storage.rbd.csi.ceph.com": cdiv1.CloneStrategyCsiClone,
"cephfs.csi.ceph.com": cdiv1.CloneStrategyCsiClone,
"openshift-storage.cephfs.csi.ceph.com": cdiv1.CloneStrategyCsiClone,
}

// ProvisionerNoobaa is the provisioner string for the Noobaa object bucket provisioner which does not work with CDI
Expand Down
13 changes: 9 additions & 4 deletions tests/cloner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,11 @@ var _ = Describe("all clone tests", func() {

By(fmt.Sprintf("Got original storage profile: %v", spec))
originalProfileSpec = spec

By(fmt.Sprintf("configure storage profile %s", cloneStorageClassName))
Expect(
utils.ConfigureCloneStrategy(f.CrClient, f.CdiClient, cloneStorageClassName, originalProfileSpec, cdiv1.CloneStrategySnapshot),
).Should(Succeed())
})
AfterEach(func() {
By("[AfterEach] Restore the profile")
Expand Down Expand Up @@ -3162,13 +3167,13 @@ func validateCloneType(f *framework.Framework, dv *cdiv1.DataVolume) {
isCrossNamespaceClone := sourcePVC.Namespace != targetPVC.Namespace

if sourcePVC.Spec.StorageClassName != nil {
spec, err := utils.GetStorageProfileSpec(f.CdiClient, *sourcePVC.Spec.StorageClassName)
Expect(err).NotTo(HaveOccurred())
storageProfile, err := f.CdiClient.CdiV1beta1().StorageProfiles().Get(context.TODO(), *sourcePVC.Spec.StorageClassName, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())

defaultCloneStrategy := cdiv1.CloneStrategySnapshot
cloneStrategy := &defaultCloneStrategy
if spec.CloneStrategy != nil {
cloneStrategy = spec.CloneStrategy
if strategy := storageProfile.Status.CloneStrategy; strategy != nil {
cloneStrategy = strategy
}

sc, err := f.K8sClient.StorageV1().StorageClasses().Get(context.TODO(), f.SnapshotSCName, metav1.GetOptions{})
Expand Down
29 changes: 29 additions & 0 deletions tests/smartclone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,37 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component]SmartClone tests th
})

var _ = Describe("[vendor:cnv-qe@redhat.com][level:component]SmartClone tests", func() {
var originalProfileSpec *cdiv1.StorageProfileSpec
var cloneStorageClassName string

f := framework.NewFramework("dv-func-test")

BeforeEach(func() {
cloneStorageClassName = utils.DefaultStorageClass.GetName()
if f.IsCSIVolumeCloneStorageClassAvailable() {
cloneStorageClassName = f.CsiCloneSCName
}

By(fmt.Sprintf("Get original storage profile: %s", cloneStorageClassName))

spec, err := utils.GetStorageProfileSpec(f.CdiClient, cloneStorageClassName)
originalProfileSpec = spec
Expect(err).ToNot(HaveOccurred())
By(fmt.Sprintf("Got original storage profile: %v", originalProfileSpec))

By(fmt.Sprintf("configure storage profile %s", cloneStorageClassName))
Expect(
utils.ConfigureCloneStrategy(f.CrClient, f.CdiClient, cloneStorageClassName, originalProfileSpec, cdiv1.CloneStrategySnapshot),
).Should(Succeed())
})

AfterEach(func() {
if originalProfileSpec != nil {
By("Restore the profile")
Expect(utils.UpdateStorageProfile(f.CrClient, cloneStorageClassName, *originalProfileSpec)).To(Succeed())
}
})

It("[rfe_id:1106][test_id:3494][crit:high][vendor:cnv-qe@redhat.com][level:component] Verify DataVolume Smart Cloning - volumeMode filesystem - Positive flow", func() {
if !f.IsSnapshotStorageClassAvailable() {
Skip("Smart Clone is not applicable")
Expand Down