Skip to content

Commit

Permalink
Set clone strategy for ceph to CSI clone (#2817)
Browse files Browse the repository at this point in the history
Per recommendation from ceph CSI team,
switching over to doing CSI clones by default for ceph provisioners.
Implementation is very similar to today's smart cloning via temporary snapshot.

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
Co-authored-by: Alex Kalenyuk <akalenyu@redhat.com>
  • Loading branch information
kubevirt-bot and akalenyu authored Jul 26, 2023
1 parent f46544c commit 1d729fd
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
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

0 comments on commit 1d729fd

Please sign in to comment.