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

Allow the usage of AnnPodRetainAfterCompletion with populators #2873

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

alromeros
Copy link
Collaborator

@alromeros alromeros commented Aug 28, 2023

What this PR does / why we need it:

When introducing populators we somehow assumed that having the PVC' in Lost phase would interfere with the behavior of AnnPodRetainAfterCompletion. After better testing, the pod state and logs are still fetchable after completion.

This PR allows the usage of this annotation.

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: Let's see how tests behave.

Release note:

Allow the usage of AnnPodRetainAfterCompletion with populators

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. 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 Aug 28, 2023
@kubevirt-bot kubevirt-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L and removed size/M labels Aug 29, 2023
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 29, 2023
@alromeros alromeros force-pushed the debug-populator branch 2 times, most recently from c827df0 to c11056b Compare August 30, 2023 12:01
@alromeros
Copy link
Collaborator Author

/test pull-containerized-data-importer-e2e-hpp-latest

// Avoiding cleanup so we can keep clone objects for debugging purposes.
r.recorder.Eventf(pvc, corev1.EventTypeWarning, retainedPVCPrime, messageRetainedPVCPrime)
} else {
if err := r.planner.Cleanup(ctx, log, pvc); err != 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.

Hey @mhenriks, what do you think of skipping the cleanup when using AnnPodRetainAfterCompletion? I think that for debugging purposes we can allow keeping all the clone objects (even the PVC prime in lost state).

Another possibility is to have the PVC Prime in terminating state until the user deletes the pod, but having the PVC stuck there seems awkward to me. Maybe we could also consider removing the PVC protection finalizer to delete the PVC prime.

Copy link
Member

Choose a reason for hiding this comment

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

Only do this for host clone

Copy link
Member

Choose a reason for hiding this comment

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

One thing to note here though. Pods will be in the source namespace. With cross namespace clone, the user may not have access to them. And I'm not sure we want to allow the user to do this in cross namespace case

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 that's a good point. What about the check in the DV controller to see if we use populators or not?

// currently populators don't support retain pod annotation so don't use populators in that case
if retain := dv.Annotations[cc.AnnPodRetainAfterCompletion]; retain == "true" {
log.Info("Not using CDI populators, currently we don't support populators with retainAfterCompletion annotation")
return false, nil
}

Are we ok with turning to populators even if we only use AnnPodRetainAfterCompletion with host assisted clone?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess we are since it's basically the same behavior without populators.

Copy link
Member

Choose a reason for hiding this comment

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

Without populators, the target pod is in the target namespace. With populators both pods are in the source then rebind happens. The reason for having the target pod in the source is to better support k8s native cross namespace auth (when it goes live). In that case there will be no clone token. So can't do cross namespace host clone

@alromeros
Copy link
Collaborator Author

@mhenriks This could be also an opportunity to add the importer pod name annotation to the target PVC. I personally liked the idea and find it better than expecting users to build the pod name with the UID.

@alromeros alromeros changed the title [WIP] Allow the usage of AnnPodRetainAfterCompletion with populators Allow the usage of AnnPodRetainAfterCompletion with populators Aug 31, 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 Aug 31, 2023
@alromeros alromeros force-pushed the debug-populator branch 4 times, most recently from 05905ce to 2fa5fb0 Compare September 5, 2023 08:23
@alromeros
Copy link
Collaborator Author

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

// to keep the pods.
// - Clone is host-assisted, which is the only clone type with transfer pods worth debugging.
// - Clone occurs in a single namespace, so we avoid retaining pods in a namespace we don't have right to access.
dataSourceNamespace, ok := pvc.Annotations[AnnDataSourceNamespace]
Copy link
Member

Choose a reason for hiding this comment

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

Let's future proof this for when cross namespace datasource goes live. In that case pvc.spec.dataCource.Namespace may be set

This annotation causes CDI transfer pods (importer, uploader, cloner) to be retained after a successful or failed completion.

This makes debugging and testing easier, as users can get the pod state and logs after completion.

Signed-off-by: Alvaro Romero <alromero@redhat.com>
@alromeros
Copy link
Collaborator Author

/test pull-containerized-data-importer-fossa

@mhenriks
Copy link
Member

/lgtm
/approve

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 12, 2023
@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 Sep 12, 2023
@kubevirt-bot kubevirt-bot merged commit f7f95c5 into kubevirt:main Sep 13, 2023
18 checks passed
akalenyu added a commit to akalenyu/containerized-data-importer that referenced this pull request Sep 21, 2023
I find myself going back a lot to this function and I noticed
some of the fallback reasons are outdated following:
kubevirt#2765
kubevirt#2873

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
akalenyu added a commit to akalenyu/containerized-data-importer that referenced this pull request Sep 26, 2023
I find myself going back a lot to this function and I noticed
some of the fallback reasons are outdated following:
kubevirt#2765
kubevirt#2873

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
kubevirt-bot pushed a commit that referenced this pull request Sep 26, 2023
I find myself going back a lot to this function and I noticed
some of the fallback reasons are outdated following:
#2765
#2873

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
@alromeros
Copy link
Collaborator Author

Backporting this as requested in Jira
/cherrypick release-v1.57

@kubevirt-bot
Copy link
Contributor

@alromeros: #2873 failed to apply on top of branch "release-v1.57":

Applying: Allow the usage of AnnPodRetainAfterCompletion with populators
Using index info to reconstruct a base tree...
M	pkg/controller/datavolume/controller-base.go
M	pkg/controller/datavolume/import-controller_test.go
M	pkg/controller/populators/import-populator_test.go
M	pkg/controller/populators/populator-base.go
M	tests/cloner_test.go
M	tests/import_proxy_test.go
M	tests/import_test.go
Falling back to patching base and 3-way merge...
Auto-merging tests/import_test.go
CONFLICT (content): Merge conflict in tests/import_test.go
Auto-merging tests/import_proxy_test.go
Auto-merging tests/cloner_test.go
Auto-merging pkg/controller/populators/populator-base.go
Auto-merging pkg/controller/populators/import-populator_test.go
CONFLICT (content): Merge conflict in pkg/controller/populators/import-populator_test.go
Auto-merging pkg/controller/datavolume/import-controller_test.go
Auto-merging pkg/controller/datavolume/controller-base.go
CONFLICT (content): Merge conflict in pkg/controller/datavolume/controller-base.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 Allow the usage of AnnPodRetainAfterCompletion with populators
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:

Backporting this as requested in Jira
/cherrypick release-v1.57

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.

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.

None yet

3 participants