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

VPA: Try make recommender e2e a little faster #7483

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adrianmoisey
Copy link
Member

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?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


By exiting early if the successful state exists
@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 11, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: adrianmoisey
Once this PR has been reviewed and has the lgtm label, please assign voelzmo for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 11, 2024
@@ -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...")
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

Choose a reason for hiding this comment

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

Yes . Klog seems better

Copy link
Member Author

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{})
Copy link
Member

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

Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member Author

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.

Copy link
Member

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 :)

Copy link
Member

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?

I see. so leave it as it is, it's just one more api call so I don't mind

Copy link
Member Author

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?

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.

@omerap12
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants