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

test: added check for snapshot and clone creation in e2e #206

Merged
merged 3 commits into from
Jul 8, 2022

Conversation

riya-singhal31
Copy link
Contributor

@riya-singhal31 riya-singhal31 commented Jun 13, 2022

It creates snapshots and clones and check if the cloned PVC is bound or not.

Signed-off-by: riya-singhal31 [email protected]

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 13, 2022
@riya-singhal31 riya-singhal31 changed the title [WIP]test: added check for snapshot creation in e2e test: added check for snapshot creation in e2e Jun 13, 2022
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 13, 2022
@riya-singhal31 riya-singhal31 changed the title test: added check for snapshot creation in e2e [WIP]test: added check for snapshot creation in e2e Jun 15, 2022
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 15, 2022
@riya-singhal31 riya-singhal31 changed the title [WIP]test: added check for snapshot creation in e2e [WIP]test: added check for snapshot and clone creation in e2e Jun 15, 2022
Copy link
Contributor

@nbalacha nbalacha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include a test to restore the snapshot as we...

e2e/testdata.go Outdated
}

func GetSampleClone(quantity, name string, volumemode k8sv1.PersistentVolumeMode) *k8sv1.PersistentVolumeClaim {
storageClassName := "odf-lvm-vg1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pass this as an argument. Then if we change the storageclass name, it only has to be changed in one place. Comment holds for all instances of this usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@riya-singhal31 riya-singhal31 changed the title [WIP]test: added check for snapshot and clone creation in e2e test: added check for snapshot and clone creation in e2e Jun 17, 2022
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 17, 2022
@@ -25,6 +26,12 @@ func PVCTest() {
var filepod *k8sv1.Pod
var blockpvc *k8sv1.PersistentVolumeClaim
var blockpod *k8sv1.Pod
var fileSnapshot *snapapi.VolumeSnapshot
var blockSnapshot *snapapi.VolumeSnapshot
var filepvcclone *k8sv1.PersistentVolumeClaim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names should follow the camelcase convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 21, 2022
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2022
@riya-singhal31
Copy link
Contributor Author

riya-singhal31 commented Jun 22, 2022

O/P:

[riyasinghal@fedora lvm-operator]$ oc get pvc,pods -n lvm-endtoendtest
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/lvmblockpvc Bound pvc-f6d06c9f-f97c-4cf1-af0e-66b99bd7c8ee 5Gi RWO odf-lvm-vg1 112s
persistentvolumeclaim/lvmblockpvcclone Bound pvc-72eaeaf8-f515-465d-b679-b0c28256dfac 5Gi RWO odf-lvm-vg1 82s
persistentvolumeclaim/lvmblockpvcsnapshotrestore Bound pvc-cb66278a-a18e-48cf-931b-631c1fac79a3 5Gi RWO odf-lvm-vg1 51s
persistentvolumeclaim/lvmfilepvc Bound pvc-845197bc-903f-4179-9b11-6cfa1b59eff3 5Gi RWO odf-lvm-vg1 3m23s
persistentvolumeclaim/lvmfilepvcclone Bound pvc-3342fac2-3532-48fb-8e5f-13e05d98f96f 5Gi RWO odf-lvm-vg1 2m53s
persistentvolumeclaim/lvmfilepvcsnapshotrestore Bound pvc-d34f9780-837f-41e3-b089-fa79fdfc5c8d 5Gi RWO odf-lvm-vg1 2m22s

NAME READY STATUS RESTARTS AGE
pod/clone-lvmblockpod 1/1 Running 0 81s
pod/clone-lvmfilepod 1/1 Running 0 2m53s
pod/lvmblockpod 1/1 Running 0 112s
pod/lvmfilepod 1/1 Running 0 3m23s
pod/restore-lvmblockpod 1/1 Running 0 51s
pod/restore-lvmfilepod 1/1 Running 0 2m22s

[riyasinghal@fedora lvm-operator]$ oc get volumesnapshot -n lvm-endtoendtest
NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE
lvmblockpvcsnapshot true lvmblockpvc 5Gi odf-lvm-vg1 snapcontent-b9123e0e-1d08-436d-a3ef-147d884565b6 75s 75s
lvmfilepvcsnapshot true lvmfilepvc 5Gi odf-lvm-vg1 snapcontent-a608b6ad-d2a5-4074-b9e2-db7b1680dec6 2m46s 2m46s

var restoreBlockPod *k8sv1.Pod

Context("create pvc, pod, snapshots, clones", func() {
It("Verifies the status for filepvc", func() {
By("Creates pvc and pod")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By("Creates pvc and pod")
By("Creating pvc and pod")

filepvc = tests.GetSamplePVC(tests.StorageClass, "5Gi", "lvmfilepvc", k8sv1.PersistentVolumeFilesystem)
filepod = tests.GetSamplePod("lvmfilepod", "lvmfilepvc")
err := tests.DeployManagerObj.GetCrClient().Create(context.TODO(), filepvc)
filePvc = tests.GetSamplePVC(tests.StorageClass, quantity, "lvmfilepvc", k8sv1.PersistentVolumeFilesystem)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
filePvc = tests.GetSamplePVC(tests.StorageClass, quantity, "lvmfilepvc", k8sv1.PersistentVolumeFilesystem)
filePvc = tests.GetSamplePVC(tests.StorageClass, size, "lvmfilepvc", k8sv1.PersistentVolumeFilesystem)

Please rename the variable to size. Quantity sounds more like count.

err := tests.DeployManagerObj.GetCrClient().Create(context.TODO(), filepvc)
filePvc = tests.GetSamplePVC(tests.StorageClass, quantity, "lvmfilepvc", k8sv1.PersistentVolumeFilesystem)
filePod = tests.GetSamplePod("lvmfilepod", filePvc.Name)
err := tests.DeployManagerObj.GetCrClient().Create(context.TODO(), filePvc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling tests.DeployManagerObj.GetCrClient() everywhere, please save this to a variable in the beginning and use that everywhere.

blockpvc = tests.GetSamplePVC(tests.StorageClass, "5Gi", "lvmblockpvc", k8sv1.PersistentVolumeBlock)
blockpod = tests.GetSamplePod("lvmblockpod", "lvmblockpvc")
err = tests.DeployManagerObj.GetCrClient().Create(context.TODO(), blockpvc)
By("PVC(file system) Should be bound and Pod should be running")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By("PVC(file system) Should be bound and Pod should be running")
By("Verifying that the PVC(file system) is bound and the Pod is running")

}, timeout, interval).Should(BeTrue())
fmt.Printf("Pod %s is running\n", filePod.Name)

By("Snapshot for file-pvc")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By("Snapshot for file-pvc")
By("Creating a Snapshot of the file-pvc")

Expect(err).To(BeNil())
fmt.Printf("Clone PVC %s is deleted\n", blockPvcClone.Name)

err = tests.DeployManagerObj.GetCrClient().Delete(context.TODO(), blockPvcRestore)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err = tests.DeployManagerObj.GetCrClient().Delete(context.TODO(), blockPvcRestore)
err = tests.DeployManagerObj.GetCrClient().Delete(context.TODO(), restoreBlockPod)

Expect(err).To(BeNil())
fmt.Printf("Clone PVC %s is deleted\n", filePvcClone.Name)

err = tests.DeployManagerObj.GetCrClient().Delete(context.TODO(), filePvcRestore)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err = tests.DeployManagerObj.GetCrClient().Delete(context.TODO(), filePvcRestore)
err = tests.DeployManagerObj.GetCrClient().Delete(context.TODO(), restoreFilePod)

e2e/testdata.go Outdated
return vs
}

func GetSampleClone(quantity, name string, volumemode k8sv1.PersistentVolumeMode, storageClass string) *k8sv1.PersistentVolumeClaim {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func GetSampleClone(quantity, name string, volumemode k8sv1.PersistentVolumeMode, storageClass string) *k8sv1.PersistentVolumeClaim {
func GetSampleClone(size, name string, volumemode k8sv1.PersistentVolumeMode, storageClass string) *k8sv1.PersistentVolumeClaim {

e2e/testdata.go Outdated
return pvc
}

func GetRestoreVolume(quantity, name string, storageClass string) *k8sv1.PersistentVolumeClaim {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func GetRestoreVolume(quantity, name string, storageClass string) *k8sv1.PersistentVolumeClaim {
func GetRestoreVolume(size, name string, storageClass string) *k8sv1.PersistentVolumeClaim {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also consider defining resources the way topolvm does for its e2e tests.

e2e/testdata.go Outdated
return vs
}

func GetSampleClone(quantity, name string, volumemode k8sv1.PersistentVolumeMode, storageClass string) *k8sv1.PersistentVolumeClaim {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine the clone and restore functions into a single one taking a sourceType argument. The rest of the code is the same.

@riya-singhal31
Copy link
Contributor Author

Thanks @nbalacha for your suggestions, have addressed them all.

var clonePod *k8sv1.Pod
var restorePvc *k8sv1.PersistentVolumeClaim
var restorePod *k8sv1.Pod
test := tests.DeployManagerObj.GetCrClient()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test := tests.DeployManagerObj.GetCrClient()
client := tests.DeployManagerObj.GetCrClient()

By("Creating pvc and pod")
pvc = tests.GetSamplePVC(tests.StorageClass, size, "lvmfilepvc", k8sv1.PersistentVolumeFilesystem)
pod = tests.GetSamplePod("lvmfilepod", pvc.Name)
err := test.Create(context.TODO(), pvc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these resources cleaned up in case of error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end, we are deleting this namespace only, so anyway all of these will get removed.

fmt.Printf("Snapshot %s is created\n", snapshot.Name)

By("Creating a clone of the file-pvc")
clonePvc = tests.GetPvc(size, pvc.Name, k8sv1.PersistentVolumeFilesystem, tests.StorageClass, "clone", "PersistentVolumeClaim")
Copy link
Contributor

@nbalacha nbalacha Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any input should be in terms of the PVC being cloned. For example:
clonePvc = tests.GetPvc(pvc.size, pvc.Name, pvc.AccessMode, tests.StorageClass, "clone")

The last argument can be removed.
If sourceType== clone, it is of type PVC.
If sourceType==snapshot, it is of type VolumeSnapshot.

fmt.Printf("Cloned PVC %s is bound\n", clonePvc.Name)

By("Restore Snapshot for file-pvc")
restorePvc = tests.GetPvc(size, pvc.Name+"snapshot", k8sv1.PersistentVolumeFilesystem, tests.StorageClass, "restore", "VolumeSnapshot")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restoring a snapshot will create a PVC, not a snapshot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have passed snapshot as string here(pvc.Name+"snapshot") to specify the dataSource, as this is the format I used to name the snapshot.

Copy link
Contributor

@nbalacha nbalacha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the GetSamplePVC be extended to do what GetPVC is doing?

e2e/testdata.go Outdated
}

// GetSamplePvc returns restore or clone of the pvc based on the kind(kindName) provided.
func GetSamplePvc(size, name string, volumemode k8sv1.PersistentVolumeMode, storageClass string, sourceType string) *k8sv1.PersistentVolumeClaim {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor to something like this:

func GetSamplePvc(size, name string, volumemode k8sv1.PersistentVolumeMode, storageClass string, sourceType, sourceName string) *k8sv1.PersistentVolumeClaim {
	var kindName string
	var sourceName string


	pvc := &k8sv1.PersistentVolumeClaim{
		ObjectMeta: metav1.ObjectMeta{
			Name:      name,
			Namespace: TestNamespace,
		},
		Spec: k8sv1.PersistentVolumeClaimSpec{
			StorageClassName: &storageClass,
			AccessModes:      []k8sv1.PersistentVolumeAccessMode{k8sv1.ReadWriteOnce},
			VolumeMode:       &volumemode,
			Resources: k8sv1.ResourceRequirements{
				Requests: k8sv1.ResourceList{
					k8sv1.ResourceStorage: resource.MustParse(size),
				},
			},

		},
	}
	if sourceType != "" && sourceName != "" {
	pvc.Spec.DataSource = &k8sv1.TypedLocalObjectReference{
				Name: sourceName,
				Kind: sourceType,
			},
	}
	return pvc
}

e2e/testdata.go Outdated
@@ -61,3 +44,62 @@ func GetSamplePod(name, pvcName string) *k8sv1.Pod {
}
return pod
}

// GetSampleVolumeSnapshot creates and returns the VolumeSnapshot for the provided PVC.
func GetSampleVolumeSnapshot(name string, storageClass string) *snapapi.VolumeSnapshot {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func GetSampleVolumeSnapshot(name string, storageClass string) *snapapi.VolumeSnapshot {
func GetSampleVolumeSnapshot(name string, storageClass string, sourceName string) *snapapi.VolumeSnapshot {

e2e/testdata.go Outdated
vs := &snapapi.VolumeSnapshot{
ObjectMeta: metav1.ObjectMeta{
// name = name of pvc + snapshot
Name: name + "snapshot",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Name: name + "snapshot",
Name: name,

e2e/testdata.go Outdated
Spec: snapapi.VolumeSnapshotSpec{
VolumeSnapshotClassName: &storageClass,
Source: snapapi.VolumeSnapshotSource{
PersistentVolumeClaimName: &name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PersistentVolumeClaimName: &name,
PersistentVolumeClaimName: &sourceName,

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 7, 2022
fmt.Printf("Snapshot %s is created\n", snapshot.Name)

By("Creating a clone of the file-pvc")
clonePvc = tests.GetSamplePvc(size, pvc.Name, k8sv1.PersistentVolumeFilesystem, tests.StorageClass, "PersistentVolumeClaim", pvc.Name)
Copy link
Contributor

@nbalacha nbalacha Jul 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
clonePvc = tests.GetSamplePvc(size, pvc.Name, k8sv1.PersistentVolumeFilesystem, tests.StorageClass, "PersistentVolumeClaim", pvc.Name)
clonePvc = tests.GetSamplePvc(size, pvc.Name + "-clone", k8sv1.PersistentVolumeFilesystem, tests.StorageClass, "PersistentVolumeClaim", pvc.Name)


err = tests.DeployManagerObj.GetCrClient().Delete(context.TODO(), filepvc)
By("Creating a clone of the block-pvc")
clonePvc = tests.GetSamplePvc(size, pvc.Name, k8sv1.PersistentVolumeBlock, tests.StorageClass, "PersistentVolumeClaim", pvc.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
clonePvc = tests.GetSamplePvc(size, pvc.Name, k8sv1.PersistentVolumeBlock, tests.StorageClass, "PersistentVolumeClaim", pvc.Name)
clonePvc = tests.GetSamplePvc(size, pvc.Name+ "-clone", k8sv1.PersistentVolumeBlock, tests.StorageClass, "PersistentVolumeClaim", pvc.Name)

fmt.Printf("Cloned PVC %s is bound\n", clonePvc.Name)

By("Restore Snapshot for file-pvc")
restorePvc = tests.GetSamplePvc(size, pvc.Name, k8sv1.PersistentVolumeFilesystem, tests.StorageClass, snapshot.Name, pvc.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
restorePvc = tests.GetSamplePvc(size, pvc.Name, k8sv1.PersistentVolumeFilesystem, tests.StorageClass, snapshot.Name, pvc.Name)
restorePvc = tests.GetSamplePvc(size, pvc.Name + "-restore", k8sv1.PersistentVolumeFilesystem, tests.StorageClass, snapshot.Name, pvc.Name)

fmt.Printf("Cloned PVC %s is bound\n", clonePvc.Name)

By("Restore Snapshot for block-pvc")
restorePvc = tests.GetSamplePvc(size, pvc.Name, k8sv1.PersistentVolumeBlock, tests.StorageClass, snapshot.Name, pvc.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
restorePvc = tests.GetSamplePvc(size, pvc.Name, k8sv1.PersistentVolumeBlock, tests.StorageClass, snapshot.Name, pvc.Name)
restorePvc = tests.GetSamplePvc(size, pvc.Name+"-restore", k8sv1.PersistentVolumeBlock, tests.StorageClass, snapshot.Name, pvc.Name)

e2e/testdata.go Outdated
}
pvc := &k8sv1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: name + kindName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Name: name + kindName,
Name: name ,

e2e/testdata.go Outdated
@@ -61,3 +41,54 @@ func GetSamplePod(name, pvcName string) *k8sv1.Pod {
}
return pod
}

// GetSampleVolumeSnapshot creates and returns the VolumeSnapshot for the provided PVC.
func GetSampleVolumeSnapshot(sourceName string, storageClass string) *snapapi.VolumeSnapshot {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func GetSampleVolumeSnapshot(sourceName string, storageClass string) *snapapi.VolumeSnapshot {
func GetSampleVolumeSnapshot(snapshotName, sourceName string, storageClass string) *snapapi.VolumeSnapshot {

e2e/testdata.go Outdated
func GetSampleVolumeSnapshot(sourceName string, storageClass string) *snapapi.VolumeSnapshot {
vs := &snapapi.VolumeSnapshot{
ObjectMeta: metav1.ObjectMeta{
Name: sourceName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Name: sourceName,
Name: snapshotName,

@riya-singhal31
Copy link
Contributor Author

Thanks @nbalacha. Addressed all the reviews.

fmt.Printf("Cloned PVC %s is bound\n", clonePvc.Name)

By("Restore Snapshot for block-pvc")
restorePvc = tests.GetSamplePvc(size, pvc.Name+"-restore", k8sv1.PersistentVolumeBlock, tests.StorageClass, snapshot.Name, pvc.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right - shouldn't it be

Suggested change
restorePvc = tests.GetSamplePvc(size, pvc.Name+"-restore", k8sv1.PersistentVolumeBlock, tests.StorageClass, snapshot.Name, pvc.Name)
restorePvc = tests.GetSamplePvc(size, pvc.Name+"-restore", k8sv1.PersistentVolumeBlock, tests.StorageClass, "VolumeSnapshot", snapshot.Name)

fmt.Printf("Cloned PVC %s is bound\n", clonePvc.Name)

By("Restore Snapshot for file-pvc")
restorePvc = tests.GetSamplePvc(size, pvc.Name+"-restore", k8sv1.PersistentVolumeFilesystem, tests.StorageClass, snapshot.Name, pvc.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
restorePvc = tests.GetSamplePvc(size, pvc.Name+"-restore", k8sv1.PersistentVolumeFilesystem, tests.StorageClass, snapshot.Name, pvc.Name)
restorePvc = tests.GetSamplePvc(size, pvc.Name+"-restore", k8sv1.PersistentVolumeFilesystem, tests.StorageClass, "VolumeSnapshot", pvc.Name)

e2e/testdata.go Outdated
Comment on lines 81 to 96
if sourceType != "" && sourceName != "" {
pvc.Spec.DataSource = &k8sv1.TypedLocalObjectReference{
Name: sourceName,
Kind: sourceType,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if sourceType != "" && sourceName != "" {
pvc.Spec.DataSource = &k8sv1.TypedLocalObjectReference{
Name: sourceName,
Kind: sourceType,
}
}
if sourceType != "" && sourceName != "" {
if sourceType == "VolumeSnapshot" {
pvc.Spec.DataSource = &k8sv1.TypedLocalObjectReference{
Name: sourceName,
Kind: sourceType,
ApiGroup: "snapshot.storage.k8s.io"
}
} else {
pvc.Spec.DataSource = &k8sv1.TypedLocalObjectReference{
Name: sourceName,
Kind: sourceType,
}
}
}

@riya-singhal31
Copy link
Contributor Author

For file system:
[riyasinghal@fedora lvm-operator]$ oc get pvc,pods -n lvm-endtoendtest
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/lvmfilepvc Bound pvc-c4f7eee1-669f-4cdc-b24a-dad92d65243a 5Gi RWO odf-lvm-vg1 115s
persistentvolumeclaim/lvmfilepvc-clone Bound pvc-f513e931-911a-4737-b439-c6e8f850a6f5 5Gi RWO odf-lvm-vg1 84s
persistentvolumeclaim/lvmfilepvc-restore Bound pvc-e1d6d5fa-ce66-4b5c-822a-25da12dd49f9 5Gi RWO odf-lvm-vg1 54s

NAME READY STATUS RESTARTS AGE
pod/clone-lvmfilepod 1/1 Running 0 84s
pod/lvmfilepod 1/1 Running 0 115s
pod/restore-lvmfilepod 1/1 Running 0 54s

[riyasinghal@fedora lvm-operator]$ oc get vs -n lvm-endtoendtest
NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE
lvmfilepvc-snapshot true lvmfilepvc 5Gi odf-lvm-vg1 snapcontent-2ed9ef99-a30c-4672-9676-509c6307f823 11m 11m

For block:
[riyasinghal@fedora lvm-operator]$ oc get pvc,pods -n lvm-endtoendtest
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/lvmblockpvc Bound pvc-bd631014-a9a2-4cb5-83e6-4c65ce74f1aa 5Gi RWO odf-lvm-vg1 112s
persistentvolumeclaim/lvmblockpvc-clone Bound pvc-3c5b8ee3-fdaf-4a20-b416-a484072f8076 5Gi RWO odf-lvm-vg1 81s
persistentvolumeclaim/lvmblockpvc-restore Bound pvc-219028eb-8123-4d62-8ed5-c6d966c81786 5Gi RWO odf-lvm-vg1 51s

NAME READY STATUS RESTARTS AGE
pod/clone-lvmblockpod 1/1 Running 0 81s
pod/lvmblockpod 1/1 Running 0 112s
pod/restore-lvmblockpod 1/1 Running 0 51s

[riyasinghal@fedora lvm-operator]$ oc get vs
NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE
lvmblockpvc-snapshot true lvmblockpvc 5Gi odf-lvm-vg1 snapcontent-feef9e3f-e215-4520-aade-097c33ac4032 2m50s 2m50s

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 8, 2022

@riya-singhal31: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/lvm-operator-bundle-e2e-aws 8d00bb5 link false /test lvm-operator-bundle-e2e-aws

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 8, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 8, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nbalacha, riya-singhal31, sp98

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 8, 2022
@openshift-ci openshift-ci bot merged commit 4de23c2 into openshift:main Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants