Skip to content

Conversation

@adrianmoisey
Copy link
Member

@adrianmoisey adrianmoisey commented Feb 1, 2026

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 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.

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.

Once this is accepted, I also need to figure out how to add this to CI.

Which issue(s) this PR fixes:

Relates to #8934

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


/cc @maxcao13 @omerap12

I don't have much envtest experience, so happy to make adjustments if there are better ways of handling any of this

Configure a struct that can be passed around, and populate that with
CLI flags
if block ends with a return statement, so drop this else and outdent its block
@k8s-ci-robot k8s-ci-robot requested a review from maxcao13 February 1, 2026 13:25
@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Feb 1, 2026
@k8s-ci-robot k8s-ci-robot requested a review from omerap12 February 1, 2026 13:25
@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/needs-area labels Feb 1, 2026
@k8s-ci-robot
Copy link
Contributor

[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

Details 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 1, 2026
Comment on lines -71 to -76
// HamsterTargetRef is CrossVersionObjectReference of hamster app
var HamsterTargetRef = &autoscaling.CrossVersionObjectReference{
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "hamster-deployment",
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is moved out of the e2e directory.
I didn't want to give the integration tests its own go.mod file, and I didn't want to make the VPA depend on things inside the e2e tests, so handle that, I moved this out of e2e so that it could be used in the integration tests.

@adrianmoisey
Copy link
Member Author

/hold
(just to be sure it gets enough eyes before merging and doesn't merge accidentally)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 1, 2026
Copy link
Member

@maxcao13 maxcao13 left a comment

Choose a reason for hiding this comment

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

I feel like we could move the flag refactoring to a separate PR to merge first, before we introduce this new test suite. It seems to me that we are doing both things in one PR, which is a little hard to review, but for the record I do like the changes :-)

}

// ValidateCommonConfig performs validation of the common flags
func ValidateCommonConfig(config *CommonFlags) {
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be only used in the admission controller right now.

}

// Configure the recommender to watch only the watched namespace
config := recommender_config.DefaultRecommenderConfig()
Copy link
Member

Choose a reason for hiding this comment

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

Some of the stuff in each test seems repeatable. Since we use ginkgo in the regular e2es, can we re-use it here and have some sort of beforeEach which will setup the configurations for the component under test?

Comment on lines +110 to +116
// ValidateAdmissionControllerConfig performs validation of the admission-controller flags
func ValidateAdmissionControllerConfig(config *AdmissionControllerConfig) {
if len(config.CommonFlags.VpaObjectNamespace) > 0 && len(config.CommonFlags.IgnoredVpaObjectNamespaces) > 0 {
klog.ErrorS(nil, "--vpa-object-namespace and --ignored-vpa-object-namespaces are mutually exclusive and can't be set together.")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this? I think we have that common controller config validation right?

Comment on lines +123 to +124
_ = prometheus.Register(usageRecommendationRelativeDiff)
_ = prometheus.Register(usageMissingRecommendationCounter)
Copy link
Member

Choose a reason for hiding this comment

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

Just curious why the changes here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants