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

Mount block PVC rw in clone source pods #2944

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

akalenyu
Copy link
Collaborator

@akalenyu akalenyu commented Oct 26, 2023

What this PR does / why we need it:
Some CSI drivers [0] don't allow mounting block ro, so they simply cannot perform host assisted clones.
Host assisted clones are important as they are a last resort in some cases like switching over to a new storage provisioner.

This may or may not have some performance implications (parallel cloning from single source)
but we are choosing compatibility over performance in this case.

[0] https://github.com/dell/csi-unity/blob/76cb78decd0c7e0ae3bded9668e7fbe9b39dd2ff/service/node.go#L420-L424

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 #
https://issues.redhat.com/browse/CNV-33859

Special notes for your reviewer:

Release note:

BugFix: Some provisioners don't allow mounting block PVC ro

Some CSI drivers [0] don't allow mounting block ro,
so they simply cannot perform host assisted clones.
Host assisted clones are important as they are a last resort in some cases
like switching over to a new storage provisioner.

This may or may not have some performance implications (parallel cloning from single source)
but we are choosing compatibility over performance in this case.

[0] https://github.com/dell/csi-unity/blob/76cb78decd0c7e0ae3bded9668e7fbe9b39dd2ff/service/node.go#L420-L424

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Oct 26, 2023
Comment on lines +606 to +611
for _, vm := range c.VolumeDevices {
if vm.Name == volume.Name {
// Node level rw mount and container can't mount block device ro
onlyReadOnly = false
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mhenriks @awels I think this check was always broken for pods with volumeDevices

Copy link
Member

Choose a reason for hiding this comment

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

Kind of. This will only cover cases where block PVCs are in the pod spec read/write but not referred to by a container.

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

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

1 similar comment
@akalenyu
Copy link
Collaborator Author

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

pod.Labels[common.CDIComponentLabel] == common.ClonerSourcePodName {
// Host assisted clone source pod only reads from source
// But some drivers disallow mounting a block PVC ReadOnly
addPod = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Several consecutive conditions lead to the same result (false addPod), would it be possible to clean-up this a little so we have it more condenssed? Maybe something like a shouldAddPod function? Not a must but I think this code is getting hard to follow.

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 the whole function can be refactored but I prefer to stay on the safe side since this is going to backport all the way to 0.55

@@ -178,6 +178,41 @@ var _ = Describe("Clone controller reconcile loop", func() {
}),
)

It("Should create new source pod if source PVC is in use by other host assisted source pod", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice test

@alromeros
Copy link
Collaborator

/lgtm

@awels
Copy link
Member

awels commented Oct 31, 2023

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awels

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 Oct 31, 2023
@mhenriks
Copy link
Member

/hold
let me look at this

@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 Oct 31, 2023
@@ -612,6 +618,12 @@ func GetPodsUsingPVCs(ctx context.Context, c client.Client, namespace string, na
// all mounts must be ro
addPod = false
}
if strings.HasSuffix(pod.Name, common.ClonerSourcePodNameSuffix) && pod.Labels != nil &&
pod.Labels[common.CDIComponentLabel] == common.ClonerSourcePodName {
Copy link
Member

Choose a reason for hiding this comment

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

pod.Labels != nil is not required. pod.Labels[common.CDIComponentLabel] == common.ClonerSourcePodName can still be executed when pod.Labels is nil

@mhenriks
Copy link
Member

/hold cancel

@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 Oct 31, 2023
@kubevirt-bot kubevirt-bot merged commit 7c1d7db into kubevirt:main Oct 31, 2023
18 checks passed
@akalenyu
Copy link
Collaborator Author

akalenyu commented Nov 1, 2023

/cherrypick release-v1.58

@kubevirt-bot
Copy link
Contributor

@akalenyu: new pull request created: #2956

In response to this:

/cherrypick release-v1.58

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
Copy link
Collaborator Author

akalenyu commented Nov 1, 2023

/cherrypick release-v1.57

@kubevirt-bot
Copy link
Contributor

@akalenyu: new pull request created: #2957

In response to this:

/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.

@akalenyu
Copy link
Collaborator Author

akalenyu commented Nov 1, 2023

/cherrypick release-v1.56

@kubevirt-bot
Copy link
Contributor

@akalenyu: new pull request created: #2958

In response to this:

/cherrypick release-v1.56

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/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants