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

Check for pvc populated before doing any clone validations and actions #2375

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

ShellyKa13
Copy link
Contributor

@ShellyKa13 ShellyKa13 commented Jul 26, 2022

In case our pvc is already populated no need to check for source PVC
unknown size etc.

Missing tests

What this PR does / why we need 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 #
This should fix bug: https://bugzilla.redhat.com/show_bug.cgi?id=2104479

Special notes for your reviewer:

Release note:

Fix clone datavolume with populated target PVC without source 

@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. size/L labels Jul 26, 2022
@@ -808,6 +806,9 @@ func (r *DatavolumeReconciler) ensureExtendedToken(pvc *corev1.PersistentVolumeC
func (r *DatavolumeReconciler) selectCloneStrategy(datavolume *cdiv1.DataVolume, pvcSpec *corev1.PersistentVolumeClaimSpec) (cloneStrategy, error) {
preferredCloneStrategy, err := r.getCloneStrategy(datavolume)
if err != nil {
if k8serrors.IsNotFound(err) {
return NoClone, nil
Copy link
Member

Choose a reason for hiding this comment

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

maybe it would be better if getCloneStrategy() handles this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what should be returned in that case? preferredCloneStrategy=nil and err=nil? I would still need to add here a check if preferredCloneStrategy=nil and return NoClone. or create a new CDICloneStrategy-> cdiv1.CloneStrategyNoClone? I would still need to add here a check of if preferredCloneStrategy=cdiv1.CloneStrategyNoClone and return NoClone?
I dont mind doing either but doesnt seem any cleaner or simpler then this

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, why do we want to ignore notFound Err?
For example if source is not found it can return notFoundError, and for CDI it means that it needs to exit and retry later. And this is what happens when we return NoClone, err

f err != nil {
		return reconcile.Result{}, err
	}

And how it behaves If we return NoClone, nil

Copy link
Contributor

Choose a reason for hiding this comment

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

If this behaves correctly then I am ok with the rest.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@brybacki I think it behaves as expected: If the source PVC doesn't exist but the target is already populated, we are just updating the DV without triggering any errors. However, if the source PVC doesn't exist and the target is not populated, it'll be handled by validateCloneAndSourcePVC, which will exit without errors to retry once the source is created:

if pvcPopulated || prePopulated {
return r.reconcileDataVolumeStatus(datavolume, pvc, selectedCloneStrategy)
}
// Check if source PVC exists and do proper validation before attempting to clone
if done, err := r.validateCloneAndSourcePVC(datavolume); err != nil {
return reconcile.Result{}, err
} else if !done {
return reconcile.Result{}, nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

@ShellyKa13 ShellyKa13 changed the title [wip] Check for pvc populated before doing any clone validations and actions Check for pvc populated before doing any clone validations and actions Jul 28, 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 Jul 28, 2022
@ShellyKa13 ShellyKa13 requested a review from mhenriks July 28, 2022 08:31
Copy link
Collaborator

@alromeros alromeros left a comment

Choose a reason for hiding this comment

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

Looks good!

@@ -2836,6 +2836,7 @@ func (r *DatavolumeReconciler) validateCloneAndSourcePVC(datavolume *cdiv1.DataV
if err != nil {
// Clone without source
if k8serrors.IsNotFound(err) {
r.recorder.Eventf(datavolume, corev1.EventTypeWarning, ErrUnableToClone, "Source pvc %s not found", datavolume.Spec.Source.PVC.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Overall looks very good, but wouldn't this event be a little bit redundant? We are just recording a very similar event in the line below

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 just moved it from the get clone strategy to here since it didnt seem related there, you added the event so you proabably know best if its redundant, if it is Ill delete :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

The first event says "Source pvc %s not found" while the second one is "The source PVC doesn't exist", so I think they are too similar to record them at the same time. Maybe it's a good idea to merge the two so the second event also displays the PVC name, but I'd just use one.

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

@@ -1904,7 +1905,6 @@ func (r *DatavolumeReconciler) getCloneStrategy(dataVolume *cdiv1.DataVolume) (*
sourcePvc, err := r.findSourcePvc(dataVolume)
if err != nil {
if k8serrors.IsNotFound(err) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just in case, you left an empty condition here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right thanks :)

@alromeros
Copy link
Collaborator

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

targetName,
"1Gi",
map[string]string{
controller.AnnPodPhase: "Succeeded",
Copy link
Member

Choose a reason for hiding this comment

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

What happens if this annotation is missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

checked it, the test still passes, should I remove this annotation from the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 3, 2022
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2022
@alromeros
Copy link
Collaborator

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

_, err = utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, cloneDV)
Expect(err).ToNot(HaveOccurred())
By("Wait for clone DV Succeeded phase")
err = utils.WaitForDataVolumePhaseWithTimeout(f, f.Namespace.Name, cdiv1.Succeeded, targetName, cloneCompleteTimeout)
Copy link
Member

Choose a reason for hiding this comment

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

Should we check to make sure the clone didn't happen? Maybe check for some logging in the controller? Or maybe check if the annCloneType annotation is not set.

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 5, 2022
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 7, 2022
In case our pvc is already populated no need to check for source PVC
unknown size etc.

Signed-off-by: Shelly Kagan <skagan@redhat.com>
@ShellyKa13
Copy link
Contributor Author

/test pull-containerized-data-importer-e2e-ceph-gc

@mhenriks
Copy link
Member

mhenriks commented Aug 8, 2022

/lgtm
/approve

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 8, 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 Aug 8, 2022
@ShellyKa13
Copy link
Contributor Author

/retest

1 similar comment
@ShellyKa13
Copy link
Contributor Author

/retest

@ShellyKa13
Copy link
Contributor Author

/hold
checking if it causes a test flakiness

@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 Aug 9, 2022
@ShellyKa13
Copy link
Contributor Author

/unhold
the test flake I saw is not because of my changes:
[test_id:6612]Clone with CSI as PVC source with target name that already exists
failed on timeout to get the clone type annotation on the dv
It will fail in case the target pvc is created before the data volume is being reconciled at least once,
in that case we will fail on the check of the pvc already exists before we will get to the clone reconcile which there we update the clone type on the datavolume annotation

@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 Aug 10, 2022
@ShellyKa13
Copy link
Contributor Author

/retest

@ShellyKa13
Copy link
Contributor Author

opened a fix for the test flake: #2386

@kubevirt-bot kubevirt-bot merged commit 5364b4b into kubevirt:main Aug 10, 2022
@ShellyKa13
Copy link
Contributor Author

/cherrypick release-v1.53

@kubevirt-bot
Copy link
Contributor

@ShellyKa13: #2375 failed to apply on top of branch "release-v1.53":

Applying: Check for pvc populated before doing any clone validations and actions
Using index info to reconstruct a base tree...
M	pkg/controller/datavolume-controller.go
M	tests/cloner_test.go
Falling back to patching base and 3-way merge...
Auto-merging tests/cloner_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 Check for pvc populated before doing any clone validations and actions
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.53

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.

akalenyu pushed a commit to akalenyu/containerized-data-importer that referenced this pull request Aug 17, 2022
kubevirt#2375)

In case our pvc is already populated no need to check for source PVC
unknown size etc.

Signed-off-by: Shelly Kagan <skagan@redhat.com>

Signed-off-by: Shelly Kagan <skagan@redhat.com>
kubevirt-bot pushed a commit that referenced this pull request Aug 17, 2022
* Status reporting for CSI & Smart clones with WFFC storage (#2364)

* Fix logging level so we respect it in controllers/operator

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Fix CSI & Smart clones with WFFC storage status reporting

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Check for pvc populated before doing any clone validations and actions (#2375)

In case our pvc is already populated no need to check for source PVC
unknown size etc.

Signed-off-by: Shelly Kagan <skagan@redhat.com>

Signed-off-by: Shelly Kagan <skagan@redhat.com>

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
Signed-off-by: Shelly Kagan <skagan@redhat.com>
Co-authored-by: Shelly Kagan <78472213+ShellyKa13@users.noreply.github.com>
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

6 participants