Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions vertical-pod-autoscaler/e2e/integration/recommender.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ var _ = utils.RecommenderE2eDescribe("Flags", func() {
})

ginkgo.AfterEach(func() {
f.ClientSet.AppsV1().Deployments(utils.RecommenderNamespace).Delete(context.TODO(), utils.RecommenderDeploymentName, metav1.DeleteOptions{})
f.ClientSet.AppsV1().Deployments(utils.VpaNamespace).Delete(context.TODO(), utils.RecommenderDeploymentName, metav1.DeleteOptions{})
})

ginkgo.It("starts recommender with --vpa-object-namespace parameter", func() {
ginkgo.By("Setting up VPA deployment")
ignoredNamespace, err := f.CreateNamespace(context.TODO(), "ignored-namespace", nil)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

f.Namespace.Name = utils.RecommenderNamespace
f.Namespace.Name = utils.VpaNamespace
vpaDeployment := utils.NewVPADeployment(f, []string{
"--recommender-interval=10s",
fmt.Sprintf("--vpa-object-namespace=%s", hamsterNamespace),
Expand All @@ -69,7 +69,7 @@ var _ = utils.RecommenderE2eDescribe("Flags", func() {
ignoredNamespace, err := f.CreateNamespace(context.TODO(), "ignored-namespace", nil)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

f.Namespace.Name = utils.RecommenderNamespace
f.Namespace.Name = utils.VpaNamespace
vpaDeployment := utils.NewVPADeployment(f, []string{
"--recommender-interval=10s",
fmt.Sprintf("--ignored-vpa-object-namespaces=%s", ignoredNamespace.Name),
Expand Down
15 changes: 13 additions & 2 deletions vertical-pod-autoscaler/e2e/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"time"

ginkgo "github.com/onsi/ginkgo/v2"
Expand All @@ -44,8 +45,6 @@ const (

// RecommenderDeploymentName is VPA recommender deployment name
RecommenderDeploymentName = "vpa-recommender"
// RecommenderNamespace is namespace to deploy VPA recommender
RecommenderNamespace = "kube-system"
Comment on lines -47 to -48
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we should just remove this variable and use VpaNamespace for everything if that's possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, Sounds good!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmmm having two separate variables is redundant since they both serve the same purpose.
The change would be:

  • Keep the variable and init() function in e2e/utils/common.go
  • Rename RecommenderNamespaceVpaNamespace
  • Remove the duplicate from e2e/v1/common.go
  • Use utils.VpaNamespace everywhere

Does that sound good? Any other changes i need to make ????

Copy link
Member

Choose a reason for hiding this comment

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

Sure that makes sense to me. Thanks for doing this :-)

// PollInterval is interval for polling
PollInterval = 10 * time.Second
// PollTimeout is timeout for polling
Expand All @@ -57,6 +56,18 @@ const (
DefaultHamsterBackoffLimit = int32(10)
)

var (
// VpaNamespace is namespace to deploy VPA components.
// Can be overridden via VPA_NAMESPACE environment variable.
VpaNamespace = "kube-system"
)

func init() {
if ns := os.Getenv("VPA_NAMESPACE"); ns != "" {
Copy link
Member

Choose a reason for hiding this comment

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

What happens if there is no VPA_NAMESPACE env variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the VPA_NAMESPACE environment variable is not set, os.Getenv("VPA_NAMESPACE") returns an empty string, so the condition ns != "" evaluates to false, and we don't override the default value. This means VpaNamespace and RecommenderNamespace remain as "kube-system", maintaining full backward compatibility.

Copy link
Member

Choose a reason for hiding this comment

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

oh I missed the VpaNamespace = "kube-system" above. thanks!

VpaNamespace = ns
}
}

// HamsterTargetRef is CrossVersionObjectReference of hamster app
var HamsterTargetRef = &autoscaling.CrossVersionObjectReference{
APIVersion: "apps/v1",
Expand Down
4 changes: 2 additions & 2 deletions vertical-pod-autoscaler/e2e/utils/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func waitWebhookConfigurationReady(f *framework.Framework) error {
func CreateAuthReaderRoleBinding(f *framework.Framework, namespace string) {
ginkgo.By("Create role binding to let webhook read extension-apiserver-authentication")
client := f.ClientSet
_, err := client.RbacV1().RoleBindings("kube-system").Create(context.TODO(), &rbacv1.RoleBinding{
_, err := client.RbacV1().RoleBindings(VpaNamespace).Create(context.TODO(), &rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: roleBindingName,
Annotations: map[string]string{
Expand Down Expand Up @@ -382,5 +382,5 @@ func CleanWebhookTest(client clientset.Interface, namespaceName string) {
_ = client.CoreV1().Services(namespaceName).Delete(context.TODO(), WebhookServiceName, metav1.DeleteOptions{})
_ = client.AppsV1().Deployments(namespaceName).Delete(context.TODO(), deploymentName, metav1.DeleteOptions{})
_ = client.CoreV1().Secrets(namespaceName).Delete(context.TODO(), WebhookServiceName, metav1.DeleteOptions{})
_ = client.RbacV1().RoleBindings("kube-system").Delete(context.TODO(), roleBindingName, metav1.DeleteOptions{})
_ = client.RbacV1().RoleBindings(VpaNamespace).Delete(context.TODO(), roleBindingName, metav1.DeleteOptions{})
}
3 changes: 0 additions & 3 deletions vertical-pod-autoscaler/e2e/v1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ const (
// VpaInPlaceTimeout is a timeout for the VPA to finish in-place resizing a
// pod, if there are no mechanisms blocking it.
VpaInPlaceTimeout = 2 * time.Minute

// VpaNamespace is the default namespace that holds the all the VPA components.
VpaNamespace = "kube-system"
)

// UpdaterE2eDescribe describes a VPA updater e2e test.
Expand Down
2 changes: 1 addition & 1 deletion vertical-pod-autoscaler/e2e/v1/recommender.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ var _ = utils.RecommenderE2eDescribe("VPA CRD object", func() {
})

func deleteRecommender(c clientset.Interface) error {
namespace := "kube-system"
namespace := utils.VpaNamespace
listOptions := metav1.ListOptions{}
podList, err := c.CoreV1().Pods(namespace).List(context.TODO(), listOptions)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions vertical-pod-autoscaler/e2e/v1/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
statusUpdater := status.NewUpdater(
f.ClientSet,
status.AdmissionControllerStatusName,
status.AdmissionControllerStatusNamespace,
utils.VpaNamespace,
statusUpdateInterval,
"e2e test",
)
Expand All @@ -57,7 +57,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
// Status is created outside the test namespace.
ginkgo.By("Deleting the Admission Controller status")
close(stopCh)
err := f.ClientSet.CoordinationV1().Leases(status.AdmissionControllerStatusNamespace).
err := f.ClientSet.CoordinationV1().Leases(utils.VpaNamespace).
Delete(context.TODO(), status.AdmissionControllerStatusName, metav1.DeleteOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}()
Expand All @@ -79,7 +79,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
statusUpdater := status.NewUpdater(
f.ClientSet,
status.AdmissionControllerStatusName,
status.AdmissionControllerStatusNamespace,
utils.VpaNamespace,
statusUpdateInterval,
"e2e test",
)
Expand All @@ -88,7 +88,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
// Status is created outside the test namespace.
ginkgo.By("Deleting the Admission Controller status")
close(stopCh)
err := f.ClientSet.CoordinationV1().Leases(status.AdmissionControllerStatusNamespace).
err := f.ClientSet.CoordinationV1().Leases(utils.VpaNamespace).
Delete(context.TODO(), status.AdmissionControllerStatusName, metav1.DeleteOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}()
Expand All @@ -109,7 +109,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
statusUpdater := status.NewUpdater(
f.ClientSet,
status.AdmissionControllerStatusName,
status.AdmissionControllerStatusNamespace,
utils.VpaNamespace,
statusUpdateInterval,
"e2e test",
)
Expand All @@ -118,7 +118,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
// Status is created outside the test namespace.
ginkgo.By("Deleting the Admission Controller status")
close(stopCh)
err := f.ClientSet.CoordinationV1().Leases(status.AdmissionControllerStatusNamespace).
err := f.ClientSet.CoordinationV1().Leases(utils.VpaNamespace).
Delete(context.TODO(), status.AdmissionControllerStatusName, metav1.DeleteOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}()
Expand Down Expand Up @@ -151,7 +151,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
statusUpdater := status.NewUpdater(
f.ClientSet,
status.AdmissionControllerStatusName,
status.AdmissionControllerStatusNamespace,
utils.VpaNamespace,
statusUpdateInterval,
"e2e test",
)
Expand All @@ -160,7 +160,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
// Status is created outside the test namespace.
ginkgo.By("Deleting the Admission Controller status")
close(stopCh)
err := f.ClientSet.CoordinationV1().Leases(status.AdmissionControllerStatusNamespace).
err := f.ClientSet.CoordinationV1().Leases(utils.VpaNamespace).
Delete(context.TODO(), status.AdmissionControllerStatusName, metav1.DeleteOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}()
Expand All @@ -183,7 +183,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
statusUpdater := status.NewUpdater(
f.ClientSet,
status.AdmissionControllerStatusName,
status.AdmissionControllerStatusNamespace,
utils.VpaNamespace,
statusUpdateInterval,
"e2e test",
)
Expand All @@ -192,7 +192,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
// Status is created outside the test namespace.
ginkgo.By("Deleting the Admission Controller status")
close(stopCh)
err := f.ClientSet.CoordinationV1().Leases(status.AdmissionControllerStatusNamespace).
err := f.ClientSet.CoordinationV1().Leases(utils.VpaNamespace).
Delete(context.TODO(), status.AdmissionControllerStatusName, metav1.DeleteOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}()
Expand Down