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(import-populator): Make copying of annotations more robust #3388

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

0xFelix
Copy link
Member

@0xFelix 0xFelix commented Aug 15, 2024

What this PR does / why we need it:

Similar to 2fa5f27, make copying of annotations from a prime PVC to a target PVC more robust, by moving it before rebinding the PV from prime to target. This way we can ensure the annotations are already present once the PVC becomes ready.

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:

None

@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. size/XS labels Aug 15, 2024
@0xFelix
Copy link
Member Author

0xFelix commented Aug 15, 2024

@akalenyu PTAL, not sure this is 100% required.

@coveralls
Copy link

coveralls commented Aug 15, 2024

Coverage Status

coverage: 59.162% (-0.01%) from 59.176%
when pulling 3060548 on 0xFelix:import-annotations
into 5d7fe96 on kubevirt:main.

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 16, 2024
@0xFelix
Copy link
Member Author

0xFelix commented Aug 22, 2024

@akalenyu Do you think this is still needed?

@akalenyu
Copy link
Collaborator

akalenyu commented Aug 22, 2024

@akalenyu Do you think this is still needed?

I think so, yeah
It's completely possible that the annotations only make it after the target is rebound
If you want you can close this and just open an issue to track and we will take it from there

Similar to 2fa5f27, make copying of annotations from a prime PVC to a
target PVC more robust, by doing it before rebinding the PV from prime
to target. This way we can ensure the annotations are already present
once the PVC becomes ready.

Signed-off-by: Felix Matouschek <[email protected]>
@0xFelix 0xFelix force-pushed the import-annotations branch from be660ec to 3060548 Compare August 22, 2024 09:03
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 22, 2024
@0xFelix
Copy link
Member Author

0xFelix commented Aug 22, 2024

@akalenyu It looks better now, wdyt?

@akalenyu
Copy link
Collaborator

/cc @alromeros @mhenriks wdyt?

@mhenriks
Copy link
Member

looks good I think but I'll let @alromeros be the judge

@@ -160,7 +160,10 @@ func (r *ImportPopulatorReconciler) reconcileTargetPVC(pvc, pvcPrime *corev1.Per
}

if cc.IsPVCComplete(pvcPrime) && cc.IsUnbound(pvc) {
// Once the import is succeeded, we copy labels and rebind the PV from PVC to target PVC
// Once the import is succeeded, we copy annotations and labels and rebind the PV from PVC to target PVC
Copy link
Collaborator

Choose a reason for hiding this comment

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

We will update the annotations again after the rebind, are we sure we need that? Having three updatePVCWithPVCPrimeAnnotations calls in the same function makes this harder to maintain. It's not this PR's fault though. Maybe we could move the two updateAnnotations and updateLabels just above the switch?

Copy link
Collaborator

@alromeros alromeros Aug 28, 2024

Choose a reason for hiding this comment

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

Nevermind, UpdatesMultistageImportSucceeded updates the PVC prime annotations and we would need to call it afterwards (though that would leave us with two calls instead of three.)

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right that the order of calls to updatePVCWithPVCPrimeAnnotations is a bit weird here. But we need the call in L173, so that the annotations are also updated when no Pod condition above has matched. I tried without this call and this caused imports to fail because Pods in Pending condition never triggered the required annotation updates.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about having one at the top before entering the switch and another one after checking UpdatesMultistageImportSucceeded? That would leave us with two calls. Not a must though, I'll lgtm and we can consider improving this code a bit in the near future.

@alromeros
Copy link
Collaborator

Thanks!
/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2024
@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 Aug 29, 2024
@0xFelix
Copy link
Member Author

0xFelix commented Aug 30, 2024

/retest-required

@awels
Copy link
Member

awels commented Aug 30, 2024

/test pull-containerized-data-importer-fossa

@kubevirt-bot kubevirt-bot merged commit dd31547 into kubevirt:main Aug 30, 2024
19 checks passed
universal-itengineer pushed a commit to deckhouse/3p-containerized-data-importer that referenced this pull request Oct 29, 2024
…irt#3388)

Similar to 2fa5f27, make copying of annotations from a prime PVC to a
target PVC more robust, by doing it before rebinding the PV from prime
to target. This way we can ensure the annotations are already present
once the PVC becomes ready.

Signed-off-by: Felix Matouschek <[email protected]>
universal-itengineer pushed a commit to deckhouse/3p-containerized-data-importer that referenced this pull request Oct 29, 2024
…irt#3388)

Similar to 2fa5f27, make copying of annotations from a prime PVC to a
target PVC more robust, by doing it before rebinding the PV from prime
to target. This way we can ensure the annotations are already present
once the PVC becomes ready.

Signed-off-by: Felix Matouschek <[email protected]>
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-none Denotes a PR that doesn't merit a release note. size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants