-
Notifications
You must be signed in to change notification settings - Fork 248
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
Set pod affinity for host assisted clone #2647
Set pod affinity for host assisted clone #2647
Conversation
Hi @ido106. Thanks for your PR. I'm waiting for a kubevirt member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
tests/cloner_test.go
Outdated
@@ -2911,6 +2915,8 @@ func doFileBasedCloneTest(f *framework.Framework, srcPVCDef *v1.PersistentVolume | |||
targetDV.Labels["test-label-1"] = "test-label-key-1" | |||
targetDV.Annotations["test-annotation-1"] = "test-annotation-key-1" | |||
|
|||
targetDV.Annotations[controller.AnnPodRetainAfterCompletion] = "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This already happens in the test at
targetDV.Annotations[controller.AnnPodRetainAfterCompletion] = "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is enough. I will delete it and run the tests again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also verify in a functional test that when we clone multiple times from the same source, and the source is RWO, that all the source pods are on the same node? We already have a multiple clone test here
We just need to modify it to check if all the pods are on the same node IF the source volume is RWO (which is not always the case, nfs and ceph will be RWX)
pkg/controller/clone-controller.go
Outdated
@@ -650,6 +656,25 @@ func MakeCloneSourcePodSpec(sourceVolumeMode corev1.PersistentVolumeMode, image, | |||
pod.Spec.Affinity.PodAffinity = &corev1.PodAffinity{} | |||
} | |||
|
|||
if sourcePvc.Spec.AccessModes[0] == corev1.ReadWriteOnce { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is entirely possible to have multiple accessModes (Our manually created NFS test instances do this) and there is no guarantee that the first element is the RWO access mode. So I would loop over the list and find if any of them are RWO. But if there is RWO and RWX, you don't need this because the RWX part will take care of the problem.
Or check if the length of the list is 1 first. And if it is 1 then check if it is RWO. Otherwise don't use the affinity
Changes look good, but I think you might have missed my overall comment about verifying that when we do multiple clones at once (we have tests that already do this) we should ensure that the source pods are all on the same node. I put in a link to the tests. |
So this test actually doesn't test ceph with host assisted (only smart clone), that is why I made #2575 I canceled the hold on that PR so we can decide if we want it in |
The problem is that this test will work anyway even without these changes. Maybe I can create 2 clones with 2 different source pvc's and check if each one was placed on the correct node ? |
/retest-required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good just one minor comment. was having a hard time understanding what that part of the test was doing.
tests/cloner_test.go
Outdated
By(fmt.Sprintf("Getting pod %s/%s", dv.Namespace, cloneSourcePod)) | ||
pod, err := f.K8sClient.CoreV1().Pods(dv.Namespace).Get(context.TODO(), cloneSourcePod, metav1.GetOptions{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
podsNodeName[dv.Name] = pod.Spec.NodeName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have the map be map[string]bool
and on this line just say podsNodeName[pod.Spec.NodeName]=true
and below check Expect(podsNodeName).To(HaveLen(1))
We are essentially creating a set of node names, and ensure there is only 1 node name. This demonstrates all the pods were on the same node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
Signed-off-by: Ido Aharon <iaharon@redhat.com>
8d0650e
to
04fa501
Compare
99c4c3c
to
920f0d7
Compare
tests/cloner_test.go
Outdated
} | ||
}) | ||
|
||
It("[rfe_id:1277][test_id:1899][crit:High][vendor:cnv-qe@redhat.com][level:component] Should allow multiple cloning operations in parallel for block devices", func() { | ||
FIt("[rfe_id:1277][test_id:1899][crit:High][vendor:cnv-qe@redhat.com][level:component] Should allow multiple cloning operations in parallel for block devices", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the FIts the PR looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops
By("Deleting verifier pod") | ||
err = f.K8sClient.CoreV1().Pods(f.Namespace.Name).Delete(context.TODO(), utils.VerifierPodName, metav1.DeleteOptions{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
_, err = utils.WaitPodDeleted(f.K8sClient, utils.VerifierPodName, f.Namespace.Name, verifyPodDeletedTimeout) | ||
Expect(err).ToNot(HaveOccurred()) | ||
} | ||
|
||
// All pods should be in the same node except when the map is empty in smart clone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to use cloneType
in this context to tell you if this is going to be smart clone or not
For example cloneType == "network"
means host assisted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I changed the condition to if cloneType == "network"
4739f57
to
1ba621e
Compare
/lgtm |
/test pull-containerized-data-importer-e2e-ceph Same issue as in #2550, |
Signed-off-by: Ido Aharon <iaharon@redhat.com>
1ba621e
to
b79af1f
Compare
/retest |
/test pull-containerized-data-importer-e2e-upg /cc @awels |
forgot to lgtm again |
/approve |
[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 |
/lgtm |
Signed-off-by: Ido Aharon iaharon@redhat.com
What this PR does / why we need it:
Pods using the same PVC are scheduled on different nodes. We expect them to be scheduled on the same K8S node but they don't and thus cannot be attached to the PersistentVolume. The solution is to set pod affinity.
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 #2576
Special notes for your reviewer:
Release note: