-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Refactor the recommender to allow for integration tests #8985
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
base: master
Are you sure you want to change the base?
Refactor the recommender to allow for integration tests #8985
Conversation
|
@adrianmoisey: GitHub didn't allow me to request PR reviews from the following users: jkyros. Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs. DetailsIn response to this:
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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adrianmoisey The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
d54bdcd to
ff6b4bb
Compare
| _ = prometheus.Register(usageRecommendationRelativeDiff) | ||
| _ = prometheus.Register(usageMissingRecommendationCounter) | ||
| _ = prometheus.Register(cpuRecommendationOverUsageDiff) | ||
| _ = prometheus.Register(memoryRecommendationOverUsageDiff) | ||
| _ = prometheus.Register(cpuRecommendationLowerOrEqualUsageDiff) | ||
| _ = prometheus.Register(memoryRecommendationLowerOrEqualUsageDiff) | ||
| _ = prometheus.Register(cpuRecommendations) | ||
| _ = prometheus.Register(memoryRecommendations) | ||
| _ = prometheus.Register(relativeRecommendationChange) |
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'm not 100% sure on this, it's required to startup multiple recommenders in the same process.
I'm unsure if other errors can trigger this, so I need to check if this is safe
ff6b4bb to
584e1d9
Compare
omerap12
left a comment
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.
Since I already gave it a review before I would like to hear other folks.
Just small nits from me in the meantime.
| IgnoredVpaObjectNamespaces string | ||
| } | ||
|
|
||
| func DefaultCommonConfig() *CommonFlags { |
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.
lint
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.
Not sure I understand, what's the lint?
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.
Oh, exported function should have comment or be unexported
| } | ||
| } | ||
|
|
||
| func ValidateRecommenderConfig(config *RecommenderConfig) { |
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.
lint
584e1d9 to
9f4a222
Compare
Configure a struct that can be passed around, and populate that with CLI flags
9f4a222 to
f97b368
Compare
|
Thanks for the PR! Quick question, are we able to leverage the |
I wasn't aware of envtest. I asked Github Copilot to make a few changes, and I put it up as a draft PR: #8992 Some notes on that PR:
Honestly, I think I prefer the envtest PR. If everyone agrees on that path, I can clean it up a little before submitting a real PR for review. Something else to note, this issue has been around for a long time: #6137 |
| return kubeConfigFile.Name() | ||
| } | ||
|
|
||
| func makeVPACP(ns string) *vpa_types.VerticalPodAutoscalerCheckpoint { |
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.
Unused function
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Currently the VPA doesn't have "integration" tests, which allows us to test various CLI flags to each component. The purpose of this change is to set the foundation to allow us to add integration tests. The pattern I tried to base this on is https://github.com/kubernetes/kubernetes/blob/master/test/integration/cloudprovider/ccm_test.go
The idea here is that we can write tests that execute faster without needing an entire Kubernetes cluster to validate these changes.
In theory this change also pushes us closer to the modern patterns that other controllers are using.
I'd also like some extra eyes on this on to see what everyone thinks.
This PR only works on the updater, but if it makes sense to make similar changes to the admission-controller or updater, I'm happy to do so (I think the config change does make sense for all components).
This PR also highlighted that we use stop channels and contexts in some places where we could get away with only the context. That's something we can fix in future PRs.
To run this, etcd is required to be available on the local machine. If this PR is accepted, a README and some scripts will be required, along with some automation to run this on PR and master.
/cc @omerap12 @iamzili @maxcao13 @jkyros
Which issue(s) this PR fixes:
Related to #8934
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: