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

Improve handling of prePopulated DV #2205

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

brybacki
Copy link
Contributor

@brybacki brybacki commented Mar 25, 2022

Signed-off-by: Bartosz Rybacki brybacki@redhat.com

What this PR does / why we need it:

Previously, when a DataVolume was Reconciled then CDI created PVC
regardless of prePopulated annotation.

There is a possibility that DataVolume and PVC pair is being
restored or moved from other cluster. When DataVolume is marked
as prePopulated, the CDI should not try to populate it.

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 #

Special notes for your reviewer:

Release note:

Handle prepopulated DV

@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/L release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Mar 25, 2022
@kubevirt-bot kubevirt-bot removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Mar 25, 2022
@brybacki brybacki changed the title Improve handling prePopulated DV WIP: Improve handling prePopulated DV Mar 25, 2022
@kubevirt-bot kubevirt-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 25, 2022
@brybacki
Copy link
Contributor Author

Both tests fail on:

"reason": "Error",
"message": "Unable to connect to imageio data source: bad status: 403 Forbidden kubevirt.io/containerized-data-importer/pkg/importer.createImageioReader \tpkg/importer/imageio-datasource.go:589 kubevirt.io/containerized-data-importer/pkg/importer.NewImageioDataSource \tpkg/importer/imageio-datasource.go:71 main.newDataSource \tcmd/cdi-importer/importer.go:235 main.handleImport \tcmd/cdi-importer/importer.go:146 main.main \tcmd/cdi-importer/importer.go:116 runtime.main \tGOROOT/src/runtime/proc.go:255 runtime.goexit \tGOROOT/src/runtime/asm_amd64.s:1581"
}

@brybacki
Copy link
Contributor Author

/test pull-containerized-data-importer-e2e-k8s-1.22-hpp

@mhenriks
Copy link
Member

Can you give an example of the bug/issue addressed here? Is it simply that a "pre populated" DV may exist but the PVC may not yet? What will be the DV status in that case?

@brybacki
Copy link
Contributor Author

the case is as follows (happens when restoring DV + PVC using velero but I suppose ):

  1. DV is created (with the annotation prePopulated), PVC will be created next
  2. CDI checks the DV and starts import ignoring the annotation

I think in such case it should mark DV as Pending and wait for PVC

tests/datavolume_test.go Outdated Show resolved Hide resolved
Previously, when a DataVolume was Reconciled then CDI created PVC
regardless of prePopulated annotation.

There is a possibility that DataVolume and PVC pair is being
restored or moved from other cluster. When DataVolume is marked
as prePopulated, the CDI should not try to populate it.

Signed-off-by: Bartosz Rybacki <brybacki@redhat.com>
@brybacki brybacki changed the title WIP: Improve handling prePopulated DV Improve handling of prePopulated DV Mar 30, 2022
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 30, 2022
@brybacki
Copy link
Contributor Author

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

@brybacki
Copy link
Contributor Author

/test pull-containerized-data-importer-e2e-k8s-1.21-hpp

@awels
Copy link
Member

awels commented Mar 30, 2022

/test pull-containerized-data-importer-e2e-k8s-1.21-hpp
/test pull-containerized-data-importer-e2e-k8s-1.22-upg
/test pull-containerized-data-importer-e2e-k8s-1.21-ceph

@awels
Copy link
Member

awels commented Mar 30, 2022

/test pull-containerized-data-importer-e2e-k8s-1.22-hpp

@brybacki
Copy link
Contributor Author

lets try If CI is up
/test pull-containerized-data-importer-e2e-k8s-1.22-hpp

@brybacki
Copy link
Contributor Author

/test pull-containerized-data-importer-e2e-k8s-1.21-hpp

@brybacki
Copy link
Contributor Author

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

if err := r.setCloneOfOnPvc(pvc); err != nil {
switch selectedCloneStrategy {
case HostAssistedClone:
if err := r.ensureExtendedToken(pvc); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think this PR does a good job of handling the case where a DV has "pre populated" annotation and the PVC does not exist. But it appears we have to better handle the case where the PVC has "populated for".

This bug has more details: https://bugzilla.redhat.com/show_bug.cgi?id=2070366

Basically, the controller sees "populated for", takes ownership of the PVC, but still gets to this ensureExtendedToken call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you want me to handle the problem with this PR, or create a new PR?

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 the logic, now I need to prepare a test so this can be confirmed,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking at the tests

@brybacki
Copy link
Contributor Author

brybacki commented Apr 4, 2022

I think current version will work but I suppose it can be written with a better style

@akalenyu
Copy link
Collaborator

akalenyu commented Apr 5, 2022

/retest

@brybacki
Copy link
Contributor Author

brybacki commented Apr 5, 2022

Updated the logic to cover DV and PVC, also added a test that failed on previous logic on host assisted clone and also on csi clone.

There is only one problem left. If I try to write a test without adding a source PVC it fails on :

                Message: "admission webhook \"datavolume-validate.cdi.kubevirt.io\" denied the request:  Source PVC cdi-e2e-tests-dv-func-test-rq7w9/sourcepvcempty not found",

@brybacki
Copy link
Contributor Author

brybacki commented Apr 6, 2022

Ok, that is bad. I know what to do.
I'll go back to small change, to only handle annotation on DV in this PR, and I'll open a new PR with the changes to handle pvc correctly.

@brybacki
Copy link
Contributor Author

brybacki commented Apr 6, 2022

@mhenriks I have reverted change here to only handle DV with prePopulated annotation. I would like this to be reviewed and merged. The rest of the problem will be done in a separate PR.

WIP PR here #2227. I am still trying to analyze the case and discover edge cases so it might be a mess.

@@ -122,7 +122,7 @@ func updateReadyCondition(conditions []cdiv1.DataVolumeCondition, status corev1.
}

func updateBoundCondition(conditions []cdiv1.DataVolumeCondition, pvc *corev1.PersistentVolumeClaim, reason string) []cdiv1.DataVolumeCondition {
if pvc != nil {
if pvc != nil && pvc.Name != "" {
Copy link
Member

Choose a reason for hiding this comment

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

When would a PVC not have a name? PVC is used after client returns notfound?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the beginning of main reconcile loop we do pvc := &corev1.PersistentVolumeClaim{} to get the PVC.
If it is not found we have an empty PVC with no name.

I can make it null, but I would need to carefully check if all the code is ready for null. This needs to be improved, and I'll try to clean up on the next PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this is pretty ugly, please handle in #2227

@mhenriks
Copy link
Member

mhenriks commented Apr 6, 2022

/retest

1 similar comment
@mhenriks
Copy link
Member

mhenriks commented Apr 7, 2022

/retest

@mhenriks
Copy link
Member

mhenriks commented Apr 7, 2022

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mhenriks

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 Apr 7, 2022
@brybacki
Copy link
Contributor Author

brybacki commented Apr 7, 2022

/test pull-containerized-data-importer-e2e-k8s-1.22-hpp-istio

@kubevirt-bot kubevirt-bot merged commit 2f7987d into kubevirt:main Apr 7, 2022
@brybacki brybacki deleted the bugfix-prepopulated branch May 30, 2022 09:20
@brybacki
Copy link
Contributor Author

/cherrypick release-v1.43

@brybacki brybacki restored the bugfix-prepopulated branch June 14, 2022 11:52
@brybacki
Copy link
Contributor Author

/cherrypick release-v1.43

@kubevirt-bot
Copy link
Contributor

@brybacki: new pull request created: #2322

In response to this:

/cherrypick release-v1.43

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.

@kubevirt-bot
Copy link
Contributor

@brybacki: new pull request could not be created: failed to create pull request against kubevirt/containerized-data-importer#release-v1.43 from head kubevirt-bot:cherry-pick-2205-to-release-v1.43: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for kubevirt-bot:cherry-pick-2205-to-release-v1.43."}],"documentation_url":"https://docs.github.com/rest/reference/pulls#create-a-pull-request"}

In response to this:

/cherrypick release-v1.43

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.

@aglitke
Copy link
Member

aglitke commented Jun 17, 2022

/cherrypick release-v1.49

@kubevirt-bot
Copy link
Contributor

@aglitke: #2205 failed to apply on top of branch "release-v1.49":

Applying: Improve handling prePopulated DV
Using index info to reconstruct a base tree...
M	pkg/controller/datavolume-controller.go
M	tests/datavolume_test.go
Falling back to patching base and 3-way merge...
Auto-merging tests/datavolume_test.go
Auto-merging pkg/controller/datavolume-controller.go
CONFLICT (content): Merge conflict in pkg/controller/datavolume-controller.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Improve handling prePopulated DV
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherrypick release-v1.49

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.

@aglitke
Copy link
Member

aglitke commented Jun 17, 2022

Oops. This is already on release-v1.49

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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants