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

Support multi-stage imports in import populator #2767

Merged
merged 5 commits into from
Jul 12, 2023

Conversation

alromeros
Copy link
Collaborator

@alromeros alromeros commented Jun 21, 2023

What this PR does / why we need it:

This Pull Request aims to update the import populator to support multi-stage imports.

The API and functionality remain the same as with DataVolumes, with the only difference being that the used VolumeImportSource will now require a populated TargetClaim field that refers to the specific PVC to be imported (only mandatory in multistage imports).

For more information: https://github.com/kubevirt/containerized-data-importer/blob/main/doc/datavolumes.md#multi-stage-import

Special notes for your reviewer:

Release note:

Support multi-stage imports in import populator

@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Jun 21, 2023
@kubevirt-bot kubevirt-bot added 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/XL labels Jun 21, 2023
@alromeros
Copy link
Collaborator Author

/test pull-containerized-data-importer-e2e-ceph
/test pull-containerized-data-importer-non-csi-hpp
/test pull-containerized-data-importer-e2e-hpp-latest

@alromeros alromeros force-pushed the add-multistage-import-support branch from 603e6c4 to 81aa294 Compare June 23, 2023 11:08
@alromeros alromeros marked this pull request as ready for review June 23, 2023 11:08
@alromeros alromeros force-pushed the add-multistage-import-support branch 4 times, most recently from 22b0df3 to e0cdedb Compare June 23, 2023 16:29
@alromeros
Copy link
Collaborator Author

/retest-required

@alromeros alromeros force-pushed the add-multistage-import-support branch from e0cdedb to a4225f5 Compare June 26, 2023 11:14
@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 26, 2023
Copy link
Member

@mhenriks mhenriks left a comment

Choose a reason for hiding this comment

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

looks pretty good! Some minor comments

Copy link
Contributor

@ShellyKa13 ShellyKa13 left a comment

Choose a reason for hiding this comment

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

Over all looks good! some comments and need to add some tests and UT

pkg/apiserver/webhooks/populators-validate.go Show resolved Hide resolved
pkg/apiserver/webhooks/populators-validate.go Outdated Show resolved Hide resolved
pkg/apiserver/webhooks/populators-validate.go Outdated Show resolved Hide resolved
case string(corev1.PodFailed):
// We'll get called later once it succeeds
r.recorder.Eventf(pvc, corev1.EventTypeWarning, importFailed, messageImportFailed, pvc.Name)
case string(corev1.PodSucceeded):
if _, multiStageInProgress = pvc.Annotations[cc.AnnCurrentCheckpoint]; multiStageInProgress {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe put this in a function since you use it twice and it will be cleaner?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After adding the change I think it's a little bit unintuitive to have a function for this (sometimes I want the value, sometimes I don't). If it's not a must I'll leave the annotation as check as it is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Had to fix a bug involving this annotation so ended up following your suggestion.

pkg/apiserver/webhooks/populators-validate_test.go Outdated Show resolved Hide resolved
tests/import_test.go Outdated Show resolved Hide resolved
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 30, 2023
@alromeros alromeros force-pushed the add-multistage-import-support branch from a4225f5 to cde28c5 Compare June 30, 2023 10:04
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 30, 2023
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 10, 2023
@alromeros alromeros force-pushed the add-multistage-import-support branch from cde28c5 to 83942fe Compare July 10, 2023 10:01
This commit modifies the VolumeImportSource API to support multi-stage imports, adding the following fields:
- Checkpoints, to represent the stages of a multistage import
- TargetClaim, the name of the specific PVC to be imported
- FinalCheckpoint, to indicate that the current Checkpoint is the final one

Signed-off-by: Alvaro Romero <alromero@redhat.com>
This commit updates the import populator to support multi-stage imports. The API and functionality remains the same as with DataVolumes, with the only difference that the used VolumeImportSource will now require a populated "TargetClaim" field that reffers to the specific PVC to be populated.

The DataVolume controller is also updated to allow using the populator flow with VDDK and ImageIO sources.

Signed-off-by: Alvaro Romero <alromero@redhat.com>
@alromeros alromeros force-pushed the add-multistage-import-support branch from 83942fe to 442ae5c Compare July 10, 2023 10:05
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 10, 2023
@alromeros alromeros force-pushed the add-multistage-import-support branch from 442ae5c to 7566617 Compare July 10, 2023 10:07
@@ -1119,7 +1119,7 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component]DataVolume tests",
size: "1Gi",
url: vcenterURL,
dvFunc: createVddkDataVolume,
eventReason: common.AwaitingVDDK,
eventReason: "Pending",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note for the reviewer: I changed this eventReason to pending since with populators, DataVolumes won't get boundCondition events.

@alromeros alromeros force-pushed the add-multistage-import-support branch 2 times, most recently from c0d2b61 to 95c04c9 Compare July 10, 2023 11:43
@alromeros alromeros changed the title [WIP] Support multi-stage imports in import populator Support multi-stage imports in import populator Jul 10, 2023
@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 Jul 10, 2023
@alromeros alromeros force-pushed the add-multistage-import-support branch 2 times, most recently from 3d7dded to b4fb700 Compare July 11, 2023 12:49
@alromeros
Copy link
Collaborator Author

@mhenriks @ShellyKa13 I hopefully just fixed the last major bug here, would appreciate more reviews :)

Signed-off-by: Alvaro Romero <alromero@redhat.com>
Signed-off-by: Alvaro Romero <alromero@redhat.com>
This commit fixes several bugs in the import-populator logic for multi-stage imports.

Signed-off-by: Alvaro Romero <alromero@redhat.com>
@alromeros alromeros force-pushed the add-multistage-import-support branch from b4fb700 to 814b25d Compare July 11, 2023 12:59
Copy link
Contributor

@ShellyKa13 ShellyKa13 left a comment

Choose a reason for hiding this comment

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

looks great! small question just to make sure, giving lgtm anyways if the question is irrelevant :)
/lgtm

if isMultiStage {
importSource.Spec.TargetClaim = &dv.Name
importSource.Spec.Checkpoints = dv.Spec.Checkpoints
importSource.Spec.FinalCheckpoint = &dv.Spec.FinalCheckpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

just making sure FinalCheckpoint cant be nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah it can be nil, but it's always checked before dereferencing (and, in that case, we assume its value to be false)

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 11, 2023
@alromeros
Copy link
Collaborator Author

alromeros commented Jul 11, 2023

/hold

I think everything is fixed but let's see how well tests behave. I've been struggling with some racy behavior.

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 11, 2023
@alromeros
Copy link
Collaborator Author

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

@alromeros
Copy link
Collaborator Author

I'm confident this is working
/unhold

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 12, 2023
@mhenriks
Copy link
Member

/approve

@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 Jul 12, 2023
@kubevirt-bot kubevirt-bot merged commit 9c443b4 into kubevirt:main Jul 12, 2023
16 checks passed
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/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants