Repository: mercari/tortoise
Pull request #291 (2024-01-19 08:17:29)

remove MinReplica from Updater VPA
<!--  
Thanks for sending a pull request!  
Please read the CLA carefully before submitting your contribution to Mercari. 
Under any circumstances, by submitting your contribution, you are deemed to accept and agree to be bound by the terms and conditions of the CLA.
https://www.mercari.com/cla/

Also, please read the contributor guide, which contains some general rules and suggestions:
https://github.com/mercari/tortoise/blob/main/docs/contributor-guide.md
-->

#### What this PR does / why we need it:

ssia

#### Which issue(s) this PR fixes:

<!--
Before implementing any feature changes, please raise the issue and discuss what you propose with maintainers.
-->

Fixes #

#### Special notes for your reviewer:



Patch:
diff --git a/pkg/vpa/service.go b/pkg/vpa/service.go
index b272aba..d1e0888 100644
--- a/pkg/vpa/service.go
+++ b/pkg/vpa/service.go
@@ -286,12 +286,9 @@ func (c *Service) UpdateVPAFromTortoiseRecommendation(ctx context.Context, torto
 		updated = !equality.Semantic.DeepEqual(newRecommendations, vpa.Status.Recommendation.ContainerRecommendations)
 
 		vpa.Spec.UpdatePolicy = &v1.PodUpdatePolicy{
-			// Make it very conservative. We don't want to replace many Pods at the same time.
-			MinReplicas: ptr.To(replica - 1),
-			UpdateMode:  ptr.To(v1.UpdateModeInitial),
+			UpdateMode: ptr.To(v1.UpdateModeInitial),
 		}
 		vpa.Status.Recommendation.ContainerRecommendations = newRecommendations
-		// First, we update VPA spec (MinReplicas).
 		// If VPA CRD in the cluster hasn't got the status subresource yet, this will update the status as well.
 		retVPA, err = c.c.AutoscalingV1().VerticalPodAutoscalers(vpa.Namespace).Update(ctx, vpa, metav1.UpdateOptions{})
 		if err != nil {


Test patch:
diff --git a/controllers/testdata/mutable-autoscalingpolicy-add-another-horizontal/after/vpa-Updater.yaml b/controllers/testdata/mutable-autoscalingpolicy-add-another-horizontal/after/vpa-Updater.yaml
index 01f2815..0ec59d2 100644
--- a/controllers/testdata/mutable-autoscalingpolicy-add-another-horizontal/after/vpa-Updater.yaml
+++ b/controllers/testdata/mutable-autoscalingpolicy-add-another-horizontal/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/mutable-autoscalingpolicy-no-hpa-and-add-horizontal/after/vpa-Updater.yaml b/controllers/testdata/mutable-autoscalingpolicy-no-hpa-and-add-horizontal/after/vpa-Updater.yaml
index cafe799..b930d7b 100644
--- a/controllers/testdata/mutable-autoscalingpolicy-no-hpa-and-add-horizontal/after/vpa-Updater.yaml
+++ b/controllers/testdata/mutable-autoscalingpolicy-no-hpa-and-add-horizontal/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/mutable-autoscalingpolicy-remove-horizontal/after/vpa-Updater.yaml b/controllers/testdata/mutable-autoscalingpolicy-remove-horizontal/after/vpa-Updater.yaml
index 31d7cf2..6520cfe 100644
--- a/controllers/testdata/mutable-autoscalingpolicy-remove-horizontal/after/vpa-Updater.yaml
+++ b/controllers/testdata/mutable-autoscalingpolicy-remove-horizontal/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-istio-enabled-pod-working/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-istio-enabled-pod-working/after/vpa-Updater.yaml
index 3c61536..127c854 100644
--- a/controllers/testdata/reconcile-for-the-istio-enabled-pod-working/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-istio-enabled-pod-working/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-multiple-containers-pod-all-off/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-multiple-containers-pod-all-off/after/vpa-Updater.yaml
index 87f05e1..4a8acb7 100644
--- a/controllers/testdata/reconcile-for-the-multiple-containers-pod-all-off/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-multiple-containers-pod-all-off/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-multiple-containers-pod-all-vertical/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-multiple-containers-pod-all-vertical/after/vpa-Updater.yaml
index 31d7cf2..6520cfe 100644
--- a/controllers/testdata/reconcile-for-the-multiple-containers-pod-all-vertical/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-multiple-containers-pod-all-vertical/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-multiple-containers-pod-during-emergency/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-multiple-containers-pod-during-emergency/after/vpa-Updater.yaml
index 3c61536..127c854 100644
--- a/controllers/testdata/reconcile-for-the-multiple-containers-pod-during-emergency/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-multiple-containers-pod-during-emergency/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-multiple-containers-pod-emergency-started/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-multiple-containers-pod-emergency-started/after/vpa-Updater.yaml
index 3c61536..127c854 100644
--- a/controllers/testdata/reconcile-for-the-multiple-containers-pod-emergency-started/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-multiple-containers-pod-emergency-started/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-multiple-containers-pod-one-off/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-multiple-containers-pod-one-off/after/vpa-Updater.yaml
index 01f2815..0ec59d2 100644
--- a/controllers/testdata/reconcile-for-the-multiple-containers-pod-one-off/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-multiple-containers-pod-one-off/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-multiple-containers-pod-working/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-multiple-containers-pod-working/after/vpa-Updater.yaml
index 3c61536..127c854 100644
--- a/controllers/testdata/reconcile-for-the-multiple-containers-pod-working/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-multiple-containers-pod-working/after/vpa-Updater.yaml
@@ -17,7 +17,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-single-container-pod-backtonormal/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-single-container-pod-backtonormal/after/vpa-Updater.yaml
index baaa752..e836c6d 100644
--- a/controllers/testdata/reconcile-for-the-single-container-pod-backtonormal/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-single-container-pod-backtonormal/after/vpa-Updater.yaml
@@ -16,7 +16,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-single-container-pod-dryrun/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-single-container-pod-dryrun/after/vpa-Updater.yaml
index 08e993a..980e678 100644
--- a/controllers/testdata/reconcile-for-the-single-container-pod-dryrun/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-single-container-pod-dryrun/after/vpa-Updater.yaml
@@ -16,6 +16,5 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status: 
   recommendation: {}
diff --git a/controllers/testdata/reconcile-for-the-single-container-pod-during-emergency/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-single-container-pod-during-emergency/after/vpa-Updater.yaml
index 747c0c5..e836c6d 100644
--- a/controllers/testdata/reconcile-for-the-single-container-pod-during-emergency/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-single-container-pod-during-emergency/after/vpa-Updater.yaml
@@ -16,7 +16,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 19
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-single-container-pod-emergency-started/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-single-container-pod-emergency-started/after/vpa-Updater.yaml
index baaa752..e836c6d 100644
--- a/controllers/testdata/reconcile-for-the-single-container-pod-emergency-started/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-single-container-pod-emergency-started/after/vpa-Updater.yaml
@@ -16,7 +16,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-single-container-pod-gathering-data-finished/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-single-container-pod-gathering-data-finished/after/vpa-Updater.yaml
index baaa752..e836c6d 100644
--- a/controllers/testdata/reconcile-for-the-single-container-pod-gathering-data-finished/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-single-container-pod-gathering-data-finished/after/vpa-Updater.yaml
@@ -16,7 +16,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-single-container-pod-hpa-changed/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-single-container-pod-hpa-changed/after/vpa-Updater.yaml
index b738e0e..b99eed5 100644
--- a/controllers/testdata/reconcile-for-the-single-container-pod-hpa-changed/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-single-container-pod-hpa-changed/after/vpa-Updater.yaml
@@ -16,7 +16,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-single-container-pod-partly-working/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-single-container-pod-partly-working/after/vpa-Updater.yaml
index baaa752..e836c6d 100644
--- a/controllers/testdata/reconcile-for-the-single-container-pod-partly-working/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-single-container-pod-partly-working/after/vpa-Updater.yaml
@@ -16,7 +16,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-single-container-pod-suggested-too-small/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-single-container-pod-suggested-too-small/after/vpa-Updater.yaml
index 8a74509..e3b36c8 100644
--- a/controllers/testdata/reconcile-for-the-single-container-pod-suggested-too-small/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-single-container-pod-suggested-too-small/after/vpa-Updater.yaml
@@ -16,7 +16,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/controllers/testdata/reconcile-for-the-single-container-pod-working/after/vpa-Updater.yaml b/controllers/testdata/reconcile-for-the-single-container-pod-working/after/vpa-Updater.yaml
index baaa752..e836c6d 100644
--- a/controllers/testdata/reconcile-for-the-single-container-pod-working/after/vpa-Updater.yaml
+++ b/controllers/testdata/reconcile-for-the-single-container-pod-working/after/vpa-Updater.yaml
@@ -16,7 +16,6 @@ spec:
     name: mercari-app
   updatePolicy:
     updateMode: Initial
-    minReplicas: 9
 status:
   recommendation:
     containerRecommendations:
diff --git a/pkg/vpa/service_test.go b/pkg/vpa/service_test.go
index 84ef9d6..1097eb3 100644
--- a/pkg/vpa/service_test.go
+++ b/pkg/vpa/service_test.go
@@ -420,8 +420,7 @@ func TestService_UpdateVPAFromTortoiseRecommendation(t *testing.T) {
 				},
 				Spec: vpav1.VerticalPodAutoscalerSpec{
 					UpdatePolicy: &vpav1.PodUpdatePolicy{
-						UpdateMode:  ptr.To(vpav1.UpdateModeInitial),
-						MinReplicas: ptr.To[int32](9),
+						UpdateMode: ptr.To(vpav1.UpdateModeInitial),
 					},
 				},
 				Status: vpav1.VerticalPodAutoscalerStatus{},
@@ -434,8 +433,7 @@ func TestService_UpdateVPAFromTortoiseRecommendation(t *testing.T) {
 				},
 				Spec: vpav1.VerticalPodAutoscalerSpec{
 					UpdatePolicy: &vpav1.PodUpdatePolicy{
-						UpdateMode:  ptr.To(vpav1.UpdateModeInitial),
-						MinReplicas: ptr.To[int32](9),
+						UpdateMode: ptr.To(vpav1.UpdateModeInitial),
 					},
 				},
 				Status: vpav1.VerticalPodAutoscalerStatus{
@@ -524,8 +522,7 @@ func TestService_UpdateVPAFromTortoiseRecommendation(t *testing.T) {
 				},
 				Spec: vpav1.VerticalPodAutoscalerSpec{
 					UpdatePolicy: &vpav1.PodUpdatePolicy{
-						UpdateMode:  ptr.To(vpav1.UpdateModeInitial),
-						MinReplicas: ptr.To[int32](9),
+						UpdateMode: ptr.To(vpav1.UpdateModeInitial),
 					},
 				},
 				Status: vpav1.VerticalPodAutoscalerStatus{
@@ -581,8 +578,7 @@ func TestService_UpdateVPAFromTortoiseRecommendation(t *testing.T) {
 				},
 				Spec: vpav1.VerticalPodAutoscalerSpec{
 					UpdatePolicy: &vpav1.PodUpdatePolicy{
-						UpdateMode:  ptr.To(vpav1.UpdateModeInitial),
-						MinReplicas: ptr.To[int32](9),
+						UpdateMode: ptr.To(vpav1.UpdateModeInitial),
 					},
 				},
 				Status: vpav1.VerticalPodAutoscalerStatus{
@@ -678,8 +674,7 @@ func TestService_UpdateVPAFromTortoiseRecommendation(t *testing.T) {
 				},
 				Spec: vpav1.VerticalPodAutoscalerSpec{
 					UpdatePolicy: &vpav1.PodUpdatePolicy{
-						UpdateMode:  ptr.To(vpav1.UpdateModeInitial),
-						MinReplicas: ptr.To[int32](9),
+						UpdateMode: ptr.To(vpav1.UpdateModeInitial),
 					},
 				},
 				Status: vpav1.VerticalPodAutoscalerStatus{
@@ -747,8 +742,7 @@ func TestService_UpdateVPAFromTortoiseRecommendation(t *testing.T) {
 				},
 				Spec: vpav1.VerticalPodAutoscalerSpec{
 					UpdatePolicy: &vpav1.PodUpdatePolicy{
-						UpdateMode:  ptr.To(vpav1.UpdateModeInitial),
-						MinReplicas: ptr.To[int32](9),
+						UpdateMode: ptr.To(vpav1.UpdateModeInitial),
 					},
 				},
 				Status: vpav1.VerticalPodAutoscalerStatus{