-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[e2e]: fix CPU hotplug flakes #10835
Conversation
f7bf712
to
41e039a
Compare
/test pull-kubevirt-e2e-k8s-1.28-sig-compute-migrations |
41e039a
to
e23f91a
Compare
/test pull-kubevirt-e2e-k8s-1.28-sig-compute-migrations |
/test all |
/cc |
I think this is a great opportunity to fix this Lines 470 to 475 in 7e3aa9f
IMHO there could not be multiple migrations in the test in the same namespace, because tests runs in parallel in different namespace. So I think this is a non-problem.
Thanks! |
/kind flake |
@fossedihelm |
e23f91a
to
3bb20ea
Compare
74cfdcf
to
e220b23
Compare
@xpivarc @fossedihelm Can you PTAL? |
tests/libpod/query.go
Outdated
if readyPod != nil && readyPod.CreationTimestamp.Before(&pod.CreationTimestamp) { | ||
continue | ||
} | ||
|
||
readyPod = &pod |
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.
My bad for the previous wrong suggestion.
Now that I am reading better, shouldn't this be reversed?
if readyPod != nil && readyPod.CreationTimestamp.Before(&pod.CreationTimestamp) { | |
continue | |
} | |
readyPod = &pod | |
if readyPod != nil && pod.CreationTimestamp.Before(&readyPod.CreationTimestamp) { | |
continue | |
} | |
readyPod = &pod |
We want to skip this pod
if the "current" readyPod
was created before it.
Or am I totally confused?
Thanks
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.
+1
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.
@xpivarc @fossedihelm Thanks folks!
909ac7c
to
b69d77e
Compare
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.
Thanks for the patience!
tests/libpod/query.go
Outdated
continue | ||
} | ||
|
||
readyPod = &pod |
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.
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.
Interesting! Nice one!
but maybe is it better to index from range
?
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 does not matter much but I think pod := pod
was mentioned in "effective Go".
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.
@fossedihelm @xpivarc Hey. I have added a function that sorts by creation ts, please share your thoughts about the updated approach
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.
My motivation was not re-inventing the wheel when its about a sorting, and eliminate redundant boilerplate with pointers
this is done as part of the effort to reduce the utils.go boilerplate. Signed-off-by: Igor Bezukh <ibezukh@redhat.com>
the improvement gives the function a sense of library function. Signed-off-by: Igor Bezukh <ibezukh@redhat.com>
b69d77e
to
0ed213d
Compare
import v1 "k8s.io/api/core/v1" | ||
|
||
// PodsByCreationTimestamp sorts a list of Pods by creation timestamp, using their names as a tie breaker. | ||
type PodsByCreationTimestamp []v1.Pod |
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 to me! But honestly I am wondering if it is worth it to make it more general that can be used elsewhere, with smth like:
import (
k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// KMetaObject sorts a list of k8s meta objects by creation timestamp.
type KMetaObject []k8smetav1.ObjectMeta
func (o KMetaObject) Len() int { return len(o) }
func (o KMetaObject) Swap(i, j int) { o[i], o[j] = o[j], o[i] }
func (o KMetaObject) Less(i, j int) bool {
if o[i].CreationTimestamp.Equal(&o[j].CreationTimestamp) {
return o[i].Name < o[j].Name
}
return o[i].CreationTimestamp.Before(&o[j].CreationTimestamp)
}
I see that in the migration controller, we do basically the same thing, but for migrations
kubevirt/pkg/virt-controller/watch/migration.go
Lines 1629 to 1643 in a6f4f91
type vmimCollection []*virtv1.VirtualMachineInstanceMigration | |
func (c vmimCollection) Len() int { | |
return len(c) | |
} | |
func (c vmimCollection) Less(i, j int) bool { | |
t1 := &c[i].CreationTimestamp | |
t2 := &c[j].CreationTimestamp | |
return t1.Before(t2) | |
} | |
func (c vmimCollection) Swap(i, j int) { | |
c[i], c[j] = c[j], c[i] | |
} |
I don't know if it is worth it. WDYT?
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.
@fossedihelm Thanks for the feedback. The problem here is that the casting won't work: sort.Reverse(PodsByCreationTimestamp(pods.Items)
But we can solve it with Go generics. However IMO we would need some place like test-infra to put generic stuff there, and the libs would implement their things on top of that, it would require a separate PR though.
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.
That's fine! Thanks
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.
Note: It would be good to backport this as well.
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.
The 3rd commit is now redundant, the sort is a little more than we need but fine by me.
it wasn't compatible with VM migration case where there could be 2 running virt-laucnher pods. With the fix the function will return the target pod when its ready. also added library function that sorts pods by creation ts Signed-off-by: Igor Bezukh <ibezukh@redhat.com>
a36a15e
to
0991bae
Compare
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.
Thanks
/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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: xpivarc 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 |
Required labels detected, running phase 2 presubmits: |
@enp0s3: The following tests failed, say
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. I understand the commands that are listed here. |
/retest-required |
Signed-off-by: Igor Bezukh ibezukh@redhat.com
What this PR does / why we need it:
CPU hotplug involves live-migration and since
GetRunningPodByLabel
was used in the test, sometimesit returned the wrong running pod, thus resulted in a flake. The PR aims to fix
GetRunningPodByLabel
anddo some code cleanup on the way.
Fixes #
#10690
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note: