-
Notifications
You must be signed in to change notification settings - Fork 4k
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
VPA: Try make recommender e2e a little faster #7483
base: master
Are you sure you want to change the base?
Conversation
By exiting early if the successful state exists
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: adrianmoisey The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -140,7 +140,18 @@ var _ = RecommenderE2eDescribe("Checkpoints", func() { | |||
_, err := vpaClientSet.AutoscalingV1().VerticalPodAutoscalerCheckpoints(ns).Create(context.TODO(), &checkpoint, metav1.CreateOptions{}) | |||
gomega.Expect(err).NotTo(gomega.HaveOccurred()) | |||
|
|||
time.Sleep(15 * time.Minute) | |||
fmt.Println("Sleeping for up to 15 minutes...") |
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 use logger instead of println?
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 we can. I'm not sure what is recommended for tests though. There seems to be a mix of Print and klog.
I guess klog makes sense?
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.
Yes . Klog seems better
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.
Fixed in 56afad2
maxRetries := 90 | ||
retryDelay := 10 * time.Second | ||
for i := 0; i < maxRetries; i++ { | ||
list, err := vpaClientSet.AutoscalingV1().VerticalPodAutoscalerCheckpoints(ns).List(context.TODO(), metav1.ListOptions{}) |
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.
Doesn't it set in line 156?
If so we can drop line 156
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.
And should we break earlier if the vpa was created within the max retries?
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.
Doesn't it set in line 156? If so we can drop line 156
Yup, but it seems that the list
and err
in the loop is only scoped to that loop.
This is another option:
var list *vpa_types.VerticalPodAutoscalerCheckpointList
for i := 0; i < maxRetries; i++ {
list, err = vpaClientSet.AutoscalingV1().VerticalPodAutoscalerCheckpoints(ns).List(context.TODO(), metav1.ListOptions{})
if err == nil && len(list.Items) == 0 {
break
}
klog.InfoS("Still waiting...")
time.Sleep(retryDelay)
}
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(list.Items).To(gomega.BeEmpty())
Honestly, I quite like the way it is now, the first declaration is to test if the loop should exit, the second is to test if the test passes.
However, I'm not strongly opinionated on either option. What do you think?
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.
And should we break earlier if the vpa was created within the max retries?
Not sure what you mean here. This test is looking to see if a VPA Checkpoint is deleted within 15 minutes.
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.
And should we break earlier if the vpa was created within the max retries?
Not sure what you mean here. This test is looking to see if a VPA Checkpoint is deleted within 15 minutes.
My mistake. ignore it :)
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.
Doesn't it set in line 156? If so we can drop line 156
Yup, but it seems that the
list
anderr
in the loop is only scoped to that loop.This is another option:
var list *vpa_types.VerticalPodAutoscalerCheckpointList for i := 0; i < maxRetries; i++ { list, err = vpaClientSet.AutoscalingV1().VerticalPodAutoscalerCheckpoints(ns).List(context.TODO(), metav1.ListOptions{}) if err == nil && len(list.Items) == 0 { break } klog.InfoS("Still waiting...") time.Sleep(retryDelay) } gomega.Expect(err).NotTo(gomega.HaveOccurred()) gomega.Expect(list.Items).To(gomega.BeEmpty())
Honestly, I quite like the way it is now, the first declaration is to test if the loop should exit, the second is to test if the test passes.
However, I'm not strongly opinionated on either option. What do you think?
I see. so leave it as it is, it's just one more api call so I don't mind
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.
Doesn't it set in line 156? If so we can drop line 156
Yup, but it seems that the
list
anderr
in the loop is only scoped to that loop.
This is another option:var list *vpa_types.VerticalPodAutoscalerCheckpointList for i := 0; i < maxRetries; i++ { list, err = vpaClientSet.AutoscalingV1().VerticalPodAutoscalerCheckpoints(ns).List(context.TODO(), metav1.ListOptions{}) if err == nil && len(list.Items) == 0 { break } klog.InfoS("Still waiting...") time.Sleep(retryDelay) } gomega.Expect(err).NotTo(gomega.HaveOccurred()) gomega.Expect(list.Items).To(gomega.BeEmpty())
Honestly, I quite like the way it is now, the first declaration is to test if the loop should exit, the second is to test if the test passes.
However, I'm not strongly opinionated on either option. What do you think?I see. so leave it as it is, it's just one more api call so I don't mind
Yup, that's what I thought too.
I'm happy to change if any reviewer has any strong opinions.
/lgtm |
By exiting early if the successful state exists
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
The e2e tests have a few moments where it sleeps, waiting on a change. It's not obvious to the user if it's stuck or sleeping.
This PR tries to make it clear that it's sleeping.
For the 15 minute sleep, I made it periodically look for the successful state, and exist early if needed.
Which issue(s) this PR fixes:
Related to #7455
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: