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
88 changes: 57 additions & 31 deletions vertical-pod-autoscaler/e2e/v1/admission_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import (

apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/autoscaler/vertical-pod-autoscaler/e2e/utils"
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/features"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/test"
"k8s.io/kubernetes/test/e2e/framework"
podsecurity "k8s.io/pod-security-admission/api"
Expand All @@ -35,20 +37,28 @@ import (
"github.com/onsi/gomega"
)

func init() {
// Dynamically register feature gates from the VPA's versioned feature gate configuration
// This ensures consistency with the main VPA feature gate definitions
if err := utilfeature.DefaultMutableFeatureGate.Add(features.MutableFeatureGate.GetAll()); err != nil {
panic(fmt.Sprintf("Failed to add VPA feature gates: %v", err))
}
}

const (
webhookConfigName = "vpa-webhook-config"
webhookName = "vpa.k8s.io"
)

var _ = AdmissionControllerE2eDescribe("Admission-controller", ginkgo.Label("FG:InPlaceOrRecreate"), func() {
Copy link
Member

Choose a reason for hiding this comment

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

Are these labels just removed then? Does the WithFeatureGate function add something like this for us?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, it adds these:

[FeatureGate:PerVPAConfig] [Alpha] [Feature:OffByDefault]

For beta it just adds the FeatureGate and Beta, it doesn't add an "[Feature:OnByDefault]"

var _ = AdmissionControllerE2eDescribe("Admission-controller", func() {
f := framework.NewDefaultFramework("vertical-pod-autoscaling")
f.NamespacePodSecurityEnforceLevel = podsecurity.LevelBaseline

ginkgo.BeforeEach(func() {
waitForVpaWebhookRegistration(f)
})

ginkgo.It("starts pods with new recommended request with InPlaceOrRecreate mode", func() {
f.It("starts pods with new recommended request with InPlaceOrRecreate mode", framework.WithFeatureGate(features.InPlaceOrRecreate), func() {
d := NewHamsterDeploymentWithResources(f, ParseQuantityOrDie("100m") /*cpu*/, ParseQuantityOrDie("100Mi") /*memory*/)

ginkgo.By("Setting up a VPA CRD")
Expand Down Expand Up @@ -878,33 +888,49 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", ginkgo.Label("FG:
expectedErr string
}{
{
name: "Invalid oomBumpUpRatio (negative value)",
name: "Invalid minAllowed (invalid requests field)",
vpaJSON: `{
"apiVersion": "autoscaling.k8s.io/v1",
"kind": "VerticalPodAutoscaler",
"metadata": {"name": "oom-test-vpa"},
"metadata": {"name": "hamster-vpa-invalid"},
"spec": {
"targetRef": {
"apiVersion": "apps/v1",
"kind": "Deployment",
"name": "oom-test"
},
"updatePolicy": {
"updateMode": "Auto"
"name": "hamster"
},
"resourcePolicy": {
"containerPolicies": [{
"containerName": "*",
"oomBumpUpRatio": -1,
"oomMinBumpUp": 104857600
"minAllowed": {
"requests": {
"cpu": "50m"
}
}
}]
}
}
}`,
expectedErr: "spec.resourcePolicy.containerPolicies[0].oomBumpUpRatio: Invalid value: -1: spec.resourcePolicy.containerPolicies[0].oomBumpUpRatio in body should be greater than or equal to 1",
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 a little confused on this change of the test. Is this feature deprecated, or am I getting confused by a this git diff, or something else?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's a bit confusing because of the diff.

Basically, there are 3 steps:

  1. The original tests, that didn't require a feature gate
  2. Those tests got added too with some that did require a feature gate
  3. Now my change, where I split out the feature gated tests.

Here are links to each phase, to try demonstrate it:

  1. Here is the before, where none of the tests required a gate to be enabled:
    ginkgo.It("accepts valid and rejects invalid VPA object", func() {
    ginkgo.By("Setting up valid VPA object")
    validVPA := []byte(`{
    "kind": "VerticalPodAutoscaler",
    "apiVersion": "autoscaling.k8s.io/v1",
    "metadata": {"name": "hamster-vpa-valid"},
    "spec": {
    "targetRef": {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "name":"hamster"
    },
    "resourcePolicy": {
    "containerPolicies": [{"containerName": "*", "minAllowed":{"cpu":"50m"}}]
    }
    }
    }`)
    err := InstallRawVPA(f, validVPA)
    gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Valid VPA object rejected")
    ginkgo.By("Setting up invalid VPA object")
    // The invalid object differs by name and minAllowed - there is an invalid "requests" field.
    invalidVPA := []byte(`{
    "kind": "VerticalPodAutoscaler",
    "apiVersion": "autoscaling.k8s.io/v1",
    "metadata": {"name": "hamster-vpa-invalid"},
    "spec": {
    "targetRef": {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "name":"hamster"
    },
    "resourcePolicy": {
    "containerPolicies": [{"containerName": "*", "minAllowed":{"requests":{"cpu":"50m"}}}]
    }
    }
    }`)
    err2 := InstallRawVPA(f, invalidVPA)
    gomega.Expect(err2).To(gomega.HaveOccurred(), "Invalid VPA object accepted")
    gomega.Expect(err2.Error()).To(gomega.MatchRegexp(`.*admission webhook .*vpa.* denied the request: .*`))
    })
  2. Here is the expanded list, with some tests that require the gate to be enabled:
    ginkgo.It("accepts valid and rejects invalid VPA object", func() {
    ginkgo.By("Setting up valid VPA object")
    validVPA := []byte(`{
    "kind": "VerticalPodAutoscaler",
    "apiVersion": "autoscaling.k8s.io/v1",
    "metadata": {"name": "hamster-vpa-valid"},
    "spec": {
    "targetRef": {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "name":"hamster"
    },
    "resourcePolicy": {
    "containerPolicies": [{"containerName": "*", "minAllowed":{"cpu":"50m"}}]
    }
    }
    }`)
    err := InstallRawVPA(f, validVPA)
    gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Valid VPA object rejected")
    ginkgo.By("Setting up invalid VPA objects")
    testCases := []struct {
    name string
    vpaJSON string
    expectedErr string
    }{
    {
    name: "Invalid oomBumpUpRatio (negative value)",
    vpaJSON: `{
    "apiVersion": "autoscaling.k8s.io/v1",
    "kind": "VerticalPodAutoscaler",
    "metadata": {"name": "oom-test-vpa"},
    "spec": {
    "targetRef": {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "name": "oom-test"
    },
    "updatePolicy": {
    "updateMode": "Auto"
    },
    "resourcePolicy": {
    "containerPolicies": [{
    "containerName": "*",
    "oomBumpUpRatio": -1,
    "oomMinBumpUp": 104857600
    }]
    }
    }
    }`,
    expectedErr: "spec.resourcePolicy.containerPolicies[0].oomBumpUpRatio: Invalid value: -1: spec.resourcePolicy.containerPolicies[0].oomBumpUpRatio in body should be greater than or equal to 1",
    },
    {
    name: "Invalid oomBumpUpRatio (string value)",
    vpaJSON: `{
    "apiVersion": "autoscaling.k8s.io/v1",
    "kind": "VerticalPodAutoscaler",
    "metadata": {"name": "oom-test-vpa"},
    "spec": {
    "targetRef": {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "name": "oom-test"
    },
    "updatePolicy": {
    "updateMode": "Auto"
    },
    "resourcePolicy": {
    "containerPolicies": [{
    "containerName": "*",
    "oomBumpUpRatio": "12",
    "oomMinBumpUp": 104857600
    }]
    }
    }
    }`,
    expectedErr: "json: cannot unmarshal string into Go struct field ContainerResourcePolicy.spec.resourcePolicy.containerPolicies.oomBumpUpRatio of type float64",
    },
    {
    name: "Invalid oomBumpUpRatio (less than 1)",
    vpaJSON: `{
    "apiVersion": "autoscaling.k8s.io/v1",
    "kind": "VerticalPodAutoscaler",
    "metadata": {"name": "oom-test-vpa"},
    "spec": {
    "targetRef": {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "name": "oom-test"
    },
    "updatePolicy": {
    "updateMode": "Auto"
    },
    "resourcePolicy": {
    "containerPolicies": [{
    "containerName": "*",
    "oomBumpUpRatio": 0.5,
    "oomMinBumpUp": 104857600
    }]
    }
    }
    }`,
    expectedErr: "spec.resourcePolicy.containerPolicies[0].oomBumpUpRatio: Invalid value: 0.5: spec.resourcePolicy.containerPolicies[0].oomBumpUpRatio in body should be greater than or equal to 1",
    },
    {
    name: "Invalid oomMinBumpUp (negative value)",
    vpaJSON: `{
    "apiVersion": "autoscaling.k8s.io/v1",
    "kind": "VerticalPodAutoscaler",
    "metadata": {"name": "oom-test-vpa"},
    "spec": {
    "targetRef": {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "name": "oom-test"
    },
    "updatePolicy": {
    "updateMode": "Auto"
    },
    "resourcePolicy": {
    "containerPolicies": [{
    "containerName": "*",
    "oomBumpUpRatio": 2,
    "oomMinBumpUp": -1
    }]
    }
    }
    }`,
    expectedErr: "spec.resourcePolicy.containerPolicies[0].oomMinBumpUp: Invalid value: -1: spec.resourcePolicy.containerPolicies[0].oomMinBumpUp in body should be greater than or equal to 0",
    },
    {
    name: "Invalid minAllowed (invalid requests field)",
    vpaJSON: `{
    "apiVersion": "autoscaling.k8s.io/v1",
    "kind": "VerticalPodAutoscaler",
    "metadata": {"name": "hamster-vpa-invalid"},
    "spec": {
    "targetRef": {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "name": "hamster"
    },
    "resourcePolicy": {
    "containerPolicies": [{
    "containerName": "*",
    "minAllowed": {
    "requests": {
    "cpu": "50m"
    }
    }
    }]
    }
    }
    }`,
    expectedErr: "admission webhook .*vpa.* denied the request:",
    },
    }
    for _, tc := range testCases {
    ginkgo.By(fmt.Sprintf("Testing %s", tc.name))
    err := InstallRawVPA(f, []byte(tc.vpaJSON))
    gomega.Expect(err).To(gomega.HaveOccurred(), "Invalid VPA object accepted")
    gomega.Expect(err.Error()).To(gomega.MatchRegexp(tc.expectedErr))
    }
    })
  3. Here's the final stage (ie: this PR) where the tests that require the gate to be enabled are split out: https://github.com/adrianmoisey/autoscaler/blob/9c0332a853d944d87b31f4b1784b4d3d6878a99f/vertical-pod-autoscaler/e2e/v1/admission_controller.go#L864-L1043

This also changes a few expectedErr attributes, since they were incorrect when they were initially added (since we don't run these tests on PR, so that wasn't caught when they were added).

I hope that explains what I was aiming for.

Copy link
Member

@maxcao13 maxcao13 Oct 28, 2025

Choose a reason for hiding this comment

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

Ah, I see whats going on now. I haven't been keeping up with the changes to these tests that much, but I remember I gated only a subset of the admission-controller tests, and later I'm assuming we started InPlaceOrRecreate gating all the tests because of the beta promotion, so now this is separating what needs to be gated now.

Thanks for the explanation :-)

expectedErr: "admission webhook .*vpa.* denied the request:",
},
}
for _, tc := range testCases {
ginkgo.By(fmt.Sprintf("Testing %s", tc.name))
err := InstallRawVPA(f, []byte(tc.vpaJSON))
gomega.Expect(err).To(gomega.HaveOccurred(), "Invalid VPA object accepted")
gomega.Expect(err.Error()).To(gomega.MatchRegexp(tc.expectedErr))
}
})

f.It("accepts valid and rejects invalid VPA object with features.PerVPAConfig enabled", framework.WithFeatureGate(features.PerVPAConfig), func() {
ginkgo.By("Setting up invalid VPA objects")
testCases := []struct {
name string
vpaJSON string
expectedErr string
}{
{
name: "Invalid oomBumpUpRatio (string value)",
name: "Invalid oomBumpUpRatio (negative value)",
vpaJSON: `{
"apiVersion": "autoscaling.k8s.io/v1",
"kind": "VerticalPodAutoscaler",
Expand All @@ -921,16 +947,16 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", ginkgo.Label("FG:
"resourcePolicy": {
"containerPolicies": [{
"containerName": "*",
"oomBumpUpRatio": "12",
"oomBumpUpRatio": -1,
"oomMinBumpUp": 104857600
}]
}
}
}`,
expectedErr: "json: cannot unmarshal string into Go struct field ContainerResourcePolicy.spec.resourcePolicy.containerPolicies.oomBumpUpRatio of type float64",
expectedErr: "admission webhook \"vpa.k8s.io\" denied the request: oomBumpUpRatio must be greater than or equal to 1.0, got -1",
},
{
name: "Invalid oomBumpUpRatio (less than 1)",
name: "Invalid oomBumpUpRatio (string value)",
vpaJSON: `{
"apiVersion": "autoscaling.k8s.io/v1",
"kind": "VerticalPodAutoscaler",
Expand All @@ -947,16 +973,16 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", ginkgo.Label("FG:
"resourcePolicy": {
"containerPolicies": [{
"containerName": "*",
"oomBumpUpRatio": 0.5,
"oomBumpUpRatio": "not-a-number",
"oomMinBumpUp": 104857600
}]
}
}
}`,
expectedErr: "spec.resourcePolicy.containerPolicies[0].oomBumpUpRatio: Invalid value: 0.5: spec.resourcePolicy.containerPolicies[0].oomBumpUpRatio in body should be greater than or equal to 1",
expectedErr: "admission webhook \"vpa\\.k8s\\.io\" denied the request: quantities must match the regular expression",
},
{
name: "Invalid oomMinBumpUp (negative value)",
name: "Invalid oomBumpUpRatio (less than 1)",
vpaJSON: `{
"apiVersion": "autoscaling.k8s.io/v1",
"kind": "VerticalPodAutoscaler",
Expand All @@ -973,45 +999,45 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", ginkgo.Label("FG:
"resourcePolicy": {
"containerPolicies": [{
"containerName": "*",
"oomBumpUpRatio": 2,
"oomMinBumpUp": -1
"oomBumpUpRatio": 0.5,
"oomMinBumpUp": 104857600
}]
}
}
}`,
expectedErr: "spec.resourcePolicy.containerPolicies[0].oomMinBumpUp: Invalid value: -1: spec.resourcePolicy.containerPolicies[0].oomMinBumpUp in body should be greater than or equal to 0",
expectedErr: "admission webhook \"vpa.k8s.io\" denied the request: oomBumpUpRatio must be greater than or equal to 1.0, got 0.5",
},
{
name: "Invalid minAllowed (invalid requests field)",
name: "Invalid oomMinBumpUp (negative value)",
vpaJSON: `{
"apiVersion": "autoscaling.k8s.io/v1",
"kind": "VerticalPodAutoscaler",
"metadata": {"name": "hamster-vpa-invalid"},
"metadata": {"name": "oom-test-vpa"},
"spec": {
"targetRef": {
"apiVersion": "apps/v1",
"kind": "Deployment",
"name": "hamster"
"name": "oom-test"
},
"updatePolicy": {
"updateMode": "Auto"
},
"resourcePolicy": {
"containerPolicies": [{
"containerName": "*",
"minAllowed": {
"requests": {
"cpu": "50m"
}
}
"oomBumpUpRatio": 2,
"oomMinBumpUp": -1
}]
}
}
}`,
expectedErr: "admission webhook .*vpa.* denied the request:",
expectedErr: "admission webhook \"vpa.k8s.io\" denied the request: oomMinBumpUp must be greater than or equal to 0, got -1 bytes",
},
}
for _, tc := range testCases {
ginkgo.By(fmt.Sprintf("Testing %s", tc.name))
err := InstallRawVPA(f, []byte(tc.vpaJSON))
gomega.Expect(err).To(gomega.HaveOccurred(), "Invalid VPA object accepted")
gomega.Expect(err).To(gomega.HaveOccurred(), fmt.Sprintf("Invalid VPA object accepted, name: \"%s\"", tc.name))
gomega.Expect(err.Error()).To(gomega.MatchRegexp(tc.expectedErr))
}
})
Expand Down
25 changes: 0 additions & 25 deletions vertical-pod-autoscaler/e2e/v1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"time"

ginkgo "github.com/onsi/ginkgo/v2"
Expand All @@ -37,7 +36,6 @@ import (
"k8s.io/autoscaler/vertical-pod-autoscaler/e2e/utils"
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
vpa_clientset "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/features"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
framework_deployment "k8s.io/kubernetes/test/e2e/framework/deployment"
Expand Down Expand Up @@ -468,26 +466,3 @@ func WaitForPodsUpdatedWithoutEviction(f *framework.Framework, initialPods *apiv
framework.Logf("finished waiting for at least one pod to be updated without eviction")
return err
}

// checkPerVPAConfigTestsEnabled checks if the PerVPAConfig feature gate is enabled
// in the VPA recommender.
func checkPerVPAConfigTestsEnabled(f *framework.Framework) {
ginkgo.By("Checking PerVPAConfig feature gate is enabled for recommender")
deploy, err := f.ClientSet.AppsV1().Deployments(VpaNamespace).Get(context.TODO(), "vpa-recommender", metav1.GetOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(deploy.Spec.Template.Spec.Containers).To(gomega.HaveLen(1))
vpaRecommenderPod := deploy.Spec.Template.Spec.Containers[0]
gomega.Expect(vpaRecommenderPod.Name).To(gomega.Equal("recommender"))
if !anyContainsSubstring(vpaRecommenderPod.Args, fmt.Sprintf("%s=true", string(features.PerVPAConfig))) {
ginkgo.Skip("Skipping suite: PerVPAConfig feature gate is not enabled for the VPA recommender")
}
}

func anyContainsSubstring(arr []string, substr string) bool {
for _, s := range arr {
if strings.Contains(s, substr) {
return true
}
}
return false
}
12 changes: 11 additions & 1 deletion vertical-pod-autoscaler/e2e/v1/full_vpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/autoscaler/vertical-pod-autoscaler/e2e/utils"
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/features"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/test"
"k8s.io/kubernetes/test/e2e/framework"
podsecurity "k8s.io/pod-security-admission/api"
Expand All @@ -47,6 +49,14 @@ const (
oomTestTimeout = 8 * time.Minute
)

func init() {
// Dynamically register feature gates from the VPA's versioned feature gate configuration
// This ensures consistency with the main VPA feature gate definitions
if err := utilfeature.DefaultMutableFeatureGate.Add(features.MutableFeatureGate.GetAll()); err != nil {
panic(fmt.Sprintf("Failed to add VPA feature gates: %v", err))
}
}

var _ = FullVpaE2eDescribe("Pods under VPA", func() {
var (
rc *ResourceConsumer
Expand All @@ -62,7 +72,7 @@ var _ = FullVpaE2eDescribe("Pods under VPA", func() {
f := framework.NewDefaultFramework("vertical-pod-autoscaling")
f.NamespacePodSecurityEnforceLevel = podsecurity.LevelBaseline

ginkgo.Describe("with InPlaceOrRecreate update mode", ginkgo.Label("FG:InPlaceOrRecreate"), func() {
f.Describe("with InPlaceOrRecreate update mode", framework.WithFeatureGate(features.InPlaceOrRecreate), func() {
ginkgo.BeforeEach(func() {
ns := f.Namespace.Name
ginkgo.By("Setting up a hamster deployment")
Expand Down
35 changes: 18 additions & 17 deletions vertical-pod-autoscaler/e2e/v1/recommender.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/autoscaler/vertical-pod-autoscaler/e2e/utils"
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
vpa_clientset "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/features"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/test"
clientset "k8s.io/client-go/kubernetes"
Expand All @@ -41,6 +43,14 @@ import (
podsecurity "k8s.io/pod-security-admission/api"
)

func init() {
// Dynamically register feature gates from the VPA's versioned feature gate configuration
// This ensures consistency with the main VPA feature gate definitions
if err := utilfeature.DefaultMutableFeatureGate.Add(features.MutableFeatureGate.GetAll()); err != nil {
panic(fmt.Sprintf("Failed to add VPA feature gates: %v", err))
}
}

type resourceRecommendation struct {
target, lower, upper int64
}
Expand All @@ -51,7 +61,6 @@ func (r *resourceRecommendation) sub(other *resourceRecommendation) resourceReco
lower: r.lower - other.lower,
upper: r.upper - other.upper,
}

}

func getResourceRecommendation(containerRecommendation *vpa_types.RecommendedContainerResources, r apiv1.ResourceName) resourceRecommendation {
Expand Down Expand Up @@ -411,45 +420,37 @@ var _ = utils.RecommenderE2eDescribe("VPA CRD object", func() {
gomega.Expect(vpa.Status.Recommendation.ContainerRecommendations).Should(gomega.HaveLen(1), errMsg)
gomega.Expect(vpa.Status.Recommendation.ContainerRecommendations[0].ContainerName).To(gomega.Equal(utils.GetHamsterContainerNameByIndex(1)), errMsg)
})
})
f.It("have memory requests growing with OOMs more than the default", framework.WithFeatureGate(features.PerVPAConfig), func() {
const replicas = 1
const defaultOOMBumpUpRatio = model.DefaultOOMBumpUpRatio
const oomBumpUpRatio = 3

var _ = utils.RecommenderE2eDescribe("OOM with custom config", ginkgo.Label("FG:PerVPAConfig"), func() {
const replicas = 1
const defaultOOMBumpUpRatio = model.DefaultOOMBumpUpRatio
const oomBumpUpRatio = 3
f := framework.NewDefaultFramework("vertical-pod-autoscaling")
f.NamespacePodSecurityEnforceLevel = podsecurity.LevelBaseline
var (
vpaCRD *vpa_types.VerticalPodAutoscaler
vpaClientSet vpa_clientset.Interface
)
ginkgo.BeforeEach(func() {
checkPerVPAConfigTestsEnabled(f)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can remove this function since its not used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, yes, good callout.

ns := f.Namespace.Name
vpaClientSet = utils.GetVpaClientSet(f)

ginkgo.By("Setting up a hamster deployment")
runOomingReplicationController(
f.ClientSet,
ns,
"hamster",
replicas)

ginkgo.By("Setting up a VPA CRD")
targetRef := &autoscaling.CrossVersionObjectReference{
APIVersion: "v1",
Kind: "Deployment",
Name: "hamster",
}
containerName := utils.GetHamsterContainerNameByIndex(0)
vpaCRD = test.VerticalPodAutoscaler().
vpaCRD := test.VerticalPodAutoscaler().
WithName("hamster-vpa").
WithNamespace(f.Namespace.Name).
WithTargetRef(targetRef).
WithContainer(containerName).
WithOOMBumpUpRatio(resource.NewQuantity(oomBumpUpRatio, resource.DecimalSI)).
Get()
utils.InstallVPA(f, vpaCRD)
})
ginkgo.It("have memory requests growing with OOMs more than the default", func() {

ginkgo.By("Waiting for recommendation to be filled")
vpa, err := utils.WaitForRecommendationPresent(vpaClientSet, vpaCRD)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expand Down
8 changes: 8 additions & 0 deletions vertical-pod-autoscaler/hack/run-e2e-locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ echo " loading image into kind"
kind load docker-image localhost:5001/write-metrics:dev


export FEATURE_GATES=""
export TEST_WITH_FEATURE_GATES_ENABLED=""

if [ "${ENABLE_ALL_FEATURE_GATES:-}" == "true" ] ; then
export FEATURE_GATES='AllAlpha=true,AllBeta=true'
export TEST_WITH_FEATURE_GATES_ENABLED="true"
fi

case ${SUITE} in
recommender|recommender-externalmetrics|updater|admission-controller|actuation|full-vpa)
${SCRIPT_ROOT}/hack/vpa-down.sh
Expand Down
Loading
Loading