From 4239750c221813ca923b2abf64e6553cb754d2e4 Mon Sep 17 00:00:00 2001 From: Marco Voelz Date: Wed, 20 Dec 2023 12:38:22 +0100 Subject: [PATCH 1/3] Add recommendation for single container only if no other recommendations are given --- vertical-pod-autoscaler/pkg/utils/test/test_vpa.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vertical-pod-autoscaler/pkg/utils/test/test_vpa.go b/vertical-pod-autoscaler/pkg/utils/test/test_vpa.go index 3767e0685853..459aed757bdd 100644 --- a/vertical-pod-autoscaler/pkg/utils/test/test_vpa.go +++ b/vertical-pod-autoscaler/pkg/utils/test/test_vpa.go @@ -248,7 +248,12 @@ func (b *verticalPodAutoscalerBuilder) Get() *vpa_types.VerticalPodAutoscaler { Mode: b.scalingMode[containerName], }) } - recommendation = b.recommendation.WithContainer(b.containerNames[0]).Get() + // VPAs with a single container may still use the old/implicit way of adding recommendations + r := b.recommendation.WithContainer(b.containerNames[0]).Get() + if r.ContainerRecommendations[0].Target != nil { + recommendation = r + } + recommendation.ContainerRecommendations = append(recommendation.ContainerRecommendations, b.appendedRecommendations...) return &vpa_types.VerticalPodAutoscaler{ From 38ab33aed727dea1c62e553b2fbe7ed161c1b0e2 Mon Sep 17 00:00:00 2001 From: Marco Voelz Date: Wed, 20 Dec 2023 12:37:25 +0100 Subject: [PATCH 2/3] Add custom recommender name back to test --- vertical-pod-autoscaler/e2e/v1/full_vpa.go | 1 + 1 file changed, 1 insertion(+) diff --git a/vertical-pod-autoscaler/e2e/v1/full_vpa.go b/vertical-pod-autoscaler/e2e/v1/full_vpa.go index 230a3e9b1d32..7ced7c0a49d7 100644 --- a/vertical-pod-autoscaler/e2e/v1/full_vpa.go +++ b/vertical-pod-autoscaler/e2e/v1/full_vpa.go @@ -238,6 +238,7 @@ var _ = FullVpaE2eDescribe("Pods under VPA with non-recognized recommender expli containerName := GetHamsterContainerNameByIndex(0) vpaCRD := test.VerticalPodAutoscaler(). WithName("hamster-vpa"). + WithRecommender("non-recognized"). WithNamespace(f.Namespace.Name). WithTargetRef(targetRef). WithContainer(containerName). From 1740647f9060b375c848527aa7d9b7b69b008a42 Mon Sep 17 00:00:00 2001 From: Marco Voelz Date: Wed, 20 Dec 2023 12:37:46 +0100 Subject: [PATCH 3/3] go mod vendor for e2e tests --- .../pkg/apis/autoscaling.k8s.io/v1/types.go | 2 +- .../vertical-pod-autoscaler/pkg/utils/test/test_vpa.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go index cd3eba2ea125..5e9b6adb739a 100644 --- a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go @@ -126,7 +126,7 @@ type EvictionRequirement struct { // Resources is a list of one or more resources that the condition applies // to. If more than one resource is given, the EvictionRequirement is fulfilled // if at least one resource meets `changeRequirement`. - Resources []v1.ResourceName `json:"resource" protobuf:"bytes,1,name=resources"` + Resources []v1.ResourceName `json:"resources" protobuf:"bytes,1,name=resources"` ChangeRequirement EvictionChangeRequirement `json:"changeRequirement" protobuf:"bytes,2,name=changeRequirement"` } diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/test/test_vpa.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/test/test_vpa.go index 3767e0685853..459aed757bdd 100644 --- a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/test/test_vpa.go +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/test/test_vpa.go @@ -248,7 +248,12 @@ func (b *verticalPodAutoscalerBuilder) Get() *vpa_types.VerticalPodAutoscaler { Mode: b.scalingMode[containerName], }) } - recommendation = b.recommendation.WithContainer(b.containerNames[0]).Get() + // VPAs with a single container may still use the old/implicit way of adding recommendations + r := b.recommendation.WithContainer(b.containerNames[0]).Get() + if r.ContainerRecommendations[0].Target != nil { + recommendation = r + } + recommendation.ContainerRecommendations = append(recommendation.ContainerRecommendations, b.appendedRecommendations...) return &vpa_types.VerticalPodAutoscaler{