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

fix issue #2391 When clone dv from an existing pvc use smart clone, s… #2397

Merged
merged 2 commits into from
Aug 25, 2022
Merged

fix issue #2391 When clone dv from an existing pvc use smart clone, s… #2397

merged 2 commits into from
Aug 25, 2022

Conversation

Longchuanzheng
Copy link
Contributor

@Longchuanzheng Longchuanzheng commented Aug 16, 2022

…ome ann of dv can't be inherited by the new pvc.

Signed-off-by: zhuanlan zhuanlan_yewu@cmss.chinamobile.com

What this PR does / why we need it:
fix issue#2391: When clone dv from an existing pvc use smart clone, some ann of dv can't be inherited by the new pvc. #2391

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2391

Special notes for your reviewer:
Although my code works, but I think these code may not meet the logic of reconcile and need to be improved.

Release note:

BugFix: Pass annotations from DV to PVC when smart cloning.

…ome ann of dv can't be inherited by the new pvc.

Signed-off-by: zhuanlan <zhuanlan_yewu@cmss.chinamobile.com>
@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 16, 2022
@kubevirt-bot
Copy link
Contributor

Hi @Longchuanzheng. Thanks for your PR.

I'm waiting for a kubevirt member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@awels
Copy link
Member

awels commented Aug 16, 2022

/test all

@awels
Copy link
Member

awels commented Aug 16, 2022

Your code is fine, we have a very similar process for other DVs and it seems the smart clone case just slipped through the cracks. I do ask that you add or modify a functional test to verify the annotations are properly passed to the PVC. For example this test you could modify it to look something like this:

  dataVolume, err = utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, dataVolume)
  Expect(err).ToNot(HaveOccurred())
  // Set annotation on DV which we can verify on PVC later
  dataVolume.GetAnnotations()["test"] = "test-value"
  f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.SmartCloneSourceInUse))
  err = f.K8sClient.CoreV1().Pods(f.Namespace.Name).Delete(context.TODO(), pod.Name, metav1.DeleteOptions{})
  Expect(err).ToNot(HaveOccurred())

  f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.SnapshotForSmartCloneInProgress))
  f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.SmartClonePVCInProgress))
  // Wait for operation Succeeded
  waitForDvPhase(cdiv1.Succeeded, dataVolume, f)
  f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.CloneSucceeded))
  // Verify PVC's content
  verifyPVC(dataVolume, f, utils.DefaultImagePath, utils.UploadFileMD5)
  targetPvc, err := f.K8sClient.CoreV1().PersistentVolumeClaims(dataVolume.Namespace).Get(context.TODO(), dataVolume.Name, metav1.GetOptions{})
  Expect(err).ToNot(HaveOccurred())
  Expect(targetPvc.GetAnnotations()["test"]).To(Equal("test-value"))

That way you have verified that the smart clone annotations are being transferred properly. Maybe use some constants, I just wrote this while I was typing.

…e properly passed to the PVC

Signed-off-by: zhuanlan <zhuanlan_yewu@cmss.chinamobile.com>
@Longchuanzheng
Copy link
Contributor Author

thank you for your instance, I modify the pkg/controller/smart-clone-controller_test.go test: Should create PVC if snapshot ready. I have tested this modify can detect whether the pvc get anns from the dv.

@awels
Copy link
Member

awels commented Aug 18, 2022

/test all

@Longchuanzheng
Copy link
Contributor Author

/retest

@kubevirt-bot
Copy link
Contributor

@Longchuanzheng: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@awels
Copy link
Member

awels commented Aug 22, 2022

/test pull-containerized-data-importer-e2e-upg

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 25, 2022
@awels
Copy link
Member

awels commented Aug 25, 2022

/lgtm
/approve

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2022
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awels

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 25, 2022
@kubevirt-bot kubevirt-bot merged commit 48e9694 into kubevirt:main Aug 25, 2022
@Longchuanzheng Longchuanzheng deleted the dev-SmartCloneController branch September 1, 2022 11:53
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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When clone dv from an existing pvc use smart clone, some ann of dv can't be inherited by the new pvc.
3 participants