From e885474429c539396d498b69b8aef5dc40414b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Gonz=C3=A1lez?= Date: Mon, 23 Sep 2024 01:26:07 -0300 Subject: [PATCH 1/2] use isSuperset for comparison in isMonitorVPAReady instead of Equals isMonitorVPAReady now correctly checks that the VPA has recommendations for at least Tortoise defined containers, extra containers doesn't result in a false not ready. --- pkg/vpa/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/vpa/service.go b/pkg/vpa/service.go index 8a6aaada..b5cb7067 100644 --- a/pkg/vpa/service.go +++ b/pkg/vpa/service.go @@ -166,7 +166,7 @@ func isMonitorVPAReady(vpa *v1.VerticalPodAutoscaler, tortoise *autoscalingv1bet } } - return containerInTortoise.Equal(containerInVPA) + return containerInVPA.IsSuperset(containerInTortoise) } func SetAllVerticalContainerResourcePhaseWorking(tortoise *autoscalingv1beta3.Tortoise, now time.Time) *autoscalingv1beta3.Tortoise { From 1c5a04bfd505385aa5888798ba9160db10e36a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Gonz=C3=A1lez?= Date: Mon, 23 Sep 2024 01:36:04 -0300 Subject: [PATCH 2/2] service_test: added test for defining a subset on Tortoise --- pkg/vpa/service_test.go | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pkg/vpa/service_test.go b/pkg/vpa/service_test.go index 36904a1b..5ef9e561 100644 --- a/pkg/vpa/service_test.go +++ b/pkg/vpa/service_test.go @@ -628,6 +628,48 @@ func Test_isMonitorVPAReady(t *testing.T) { }, }, }, + { + name: "Tortoise defines less containers than VPA, VPA is Ready", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Conditions: []vpav1.VerticalPodAutoscalerCondition{ + { + Type: vpav1.RecommendationProvided, + Status: v1.ConditionFalse, + }, + }, + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + ContainerName: "app", + Target: v1.ResourceList{ + v1.ResourceMemory: resource.MustParse("1Gi"), + v1.ResourceCPU: resource.MustParse("1"), // wrong + }, + }, + { + ContainerName: "istio", + Target: v1.ResourceList{ + v1.ResourceMemory: resource.MustParse("1Gi"), + v1.ResourceCPU: resource.MustParse("1"), + }, + }, + }, + }, + }, + }, + tortoise: &autoscalingv1beta3.Tortoise{ + Status: autoscalingv1beta3.TortoiseStatus{ + AutoscalingPolicy: []autoscalingv1beta3.ContainerAutoscalingPolicy{ + { + ContainerName: "app", + }, + }, + }, + }, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {