diff --git a/internal/controller/testdata/mutable-autoscalingpolicy-add-another-horizontal/after/tortoise.yaml b/internal/controller/testdata/mutable-autoscalingpolicy-add-another-horizontal/after/tortoise.yaml index 1b8df961..526ca739 100644 --- a/internal/controller/testdata/mutable-autoscalingpolicy-add-another-horizontal/after/tortoise.yaml +++ b/internal/controller/testdata/mutable-autoscalingpolicy-add-another-horizontal/after/tortoise.yaml @@ -70,15 +70,15 @@ status: type: ScaledUpBasedOnPreferredMaxReplicas - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: HPA target utilization is updated - reason: HPATargetUtilizationUpdated + message: The recommendation is provided status: "True" - type: HPATargetUtilizationUpdated + type: VerticalRecommendationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: The recommendation is provided + message: HPA target utilization is updated + reason: HPATargetUtilizationUpdated status: "True" - type: VerticalRecommendationUpdated + type: HPATargetUtilizationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" status: "False" diff --git a/internal/controller/testdata/reconcile-for-the-istio-enabled-pod-working/after/tortoise.yaml b/internal/controller/testdata/reconcile-for-the-istio-enabled-pod-working/after/tortoise.yaml index 3be0827a..2e489027 100644 --- a/internal/controller/testdata/reconcile-for-the-istio-enabled-pod-working/after/tortoise.yaml +++ b/internal/controller/testdata/reconcile-for-the-istio-enabled-pod-working/after/tortoise.yaml @@ -70,15 +70,15 @@ status: type: ScaledUpBasedOnPreferredMaxReplicas - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: HPA target utilization is updated - reason: HPATargetUtilizationUpdated + message: The recommendation is provided status: "True" - type: HPATargetUtilizationUpdated + type: VerticalRecommendationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: The recommendation is provided + message: HPA target utilization is updated + reason: HPATargetUtilizationUpdated status: "True" - type: VerticalRecommendationUpdated + type: HPATargetUtilizationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" status: "False" diff --git a/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-one-off/after/tortoise.yaml b/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-one-off/after/tortoise.yaml index ae5d587b..7509fbeb 100644 --- a/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-one-off/after/tortoise.yaml +++ b/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-one-off/after/tortoise.yaml @@ -70,15 +70,15 @@ status: type: ScaledUpBasedOnPreferredMaxReplicas - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: HPA target utilization is updated - reason: HPATargetUtilizationUpdated + message: The recommendation is provided status: "True" - type: HPATargetUtilizationUpdated + type: VerticalRecommendationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: The recommendation is provided + message: HPA target utilization is updated + reason: HPATargetUtilizationUpdated status: "True" - type: VerticalRecommendationUpdated + type: HPATargetUtilizationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" status: "False" diff --git a/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-suggested-too-small/after/tortoise.yaml b/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-suggested-too-small/after/tortoise.yaml index d03f3ee5..7f3efce9 100644 --- a/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-suggested-too-small/after/tortoise.yaml +++ b/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-suggested-too-small/after/tortoise.yaml @@ -70,15 +70,15 @@ status: type: ScaledUpBasedOnPreferredMaxReplicas - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: HPA target utilization is updated - reason: HPATargetUtilizationUpdated + message: The recommendation is provided status: "True" - type: HPATargetUtilizationUpdated + type: VerticalRecommendationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: The recommendation is provided + message: HPA target utilization is updated + reason: HPATargetUtilizationUpdated status: "True" - type: VerticalRecommendationUpdated + type: HPATargetUtilizationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" status: "False" diff --git a/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-working/after/tortoise.yaml b/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-working/after/tortoise.yaml index 3be0827a..2e489027 100644 --- a/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-working/after/tortoise.yaml +++ b/internal/controller/testdata/reconcile-for-the-multiple-containers-pod-working/after/tortoise.yaml @@ -70,15 +70,15 @@ status: type: ScaledUpBasedOnPreferredMaxReplicas - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: HPA target utilization is updated - reason: HPATargetUtilizationUpdated + message: The recommendation is provided status: "True" - type: HPATargetUtilizationUpdated + type: VerticalRecommendationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: The recommendation is provided + message: HPA target utilization is updated + reason: HPATargetUtilizationUpdated status: "True" - type: VerticalRecommendationUpdated + type: HPATargetUtilizationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" status: "False" diff --git a/internal/controller/testdata/reconcile-for-the-single-container-pod-gathering-data-finished/after/tortoise.yaml b/internal/controller/testdata/reconcile-for-the-single-container-pod-gathering-data-finished/after/tortoise.yaml index d7d01941..7f6f5a8d 100644 --- a/internal/controller/testdata/reconcile-for-the-single-container-pod-gathering-data-finished/after/tortoise.yaml +++ b/internal/controller/testdata/reconcile-for-the-single-container-pod-gathering-data-finished/after/tortoise.yaml @@ -47,15 +47,15 @@ status: type: ScaledUpBasedOnPreferredMaxReplicas - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: HPA target utilization is updated - reason: HPATargetUtilizationUpdated + message: The recommendation is provided status: "True" - type: HPATargetUtilizationUpdated + type: VerticalRecommendationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: The recommendation is provided + message: HPA target utilization is updated + reason: HPATargetUtilizationUpdated status: "True" - type: VerticalRecommendationUpdated + type: HPATargetUtilizationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" status: "False" diff --git a/internal/controller/testdata/reconcile-for-the-single-container-pod-too-big/after/tortoise.yaml b/internal/controller/testdata/reconcile-for-the-single-container-pod-too-big/after/tortoise.yaml index a8e2611a..05f63755 100644 --- a/internal/controller/testdata/reconcile-for-the-single-container-pod-too-big/after/tortoise.yaml +++ b/internal/controller/testdata/reconcile-for-the-single-container-pod-too-big/after/tortoise.yaml @@ -53,15 +53,15 @@ status: type: ScaledUpBasedOnPreferredMaxReplicas - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: HPA target utilization is updated - reason: HPATargetUtilizationUpdated + message: The recommendation is provided status: "True" - type: HPATargetUtilizationUpdated + type: VerticalRecommendationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: The recommendation is provided + message: HPA target utilization is updated + reason: HPATargetUtilizationUpdated status: "True" - type: VerticalRecommendationUpdated + type: HPATargetUtilizationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" status: "False" diff --git a/internal/controller/testdata/reconcile-for-the-single-container-pod-working/after/tortoise.yaml b/internal/controller/testdata/reconcile-for-the-single-container-pod-working/after/tortoise.yaml index 9a5cd103..d87c9651 100644 --- a/internal/controller/testdata/reconcile-for-the-single-container-pod-working/after/tortoise.yaml +++ b/internal/controller/testdata/reconcile-for-the-single-container-pod-working/after/tortoise.yaml @@ -47,15 +47,15 @@ status: type: ScaledUpBasedOnPreferredMaxReplicas - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: HPA target utilization is updated - reason: HPATargetUtilizationUpdated + message: The recommendation is provided status: "True" - type: HPATargetUtilizationUpdated + type: VerticalRecommendationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" - message: The recommendation is provided + message: HPA target utilization is updated + reason: HPATargetUtilizationUpdated status: "True" - type: VerticalRecommendationUpdated + type: HPATargetUtilizationUpdated - lastTransitionTime: "2023-01-01T00:00:00Z" lastUpdateTime: "2023-01-01T00:00:00Z" status: "False" diff --git a/internal/controller/tortoise_controller.go b/internal/controller/tortoise_controller.go index f08fe9f6..b8bb8c96 100644 --- a/internal/controller/tortoise_controller.go +++ b/internal/controller/tortoise_controller.go @@ -258,15 +258,15 @@ func (r *TortoiseReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ return ctrl.Result{RequeueAfter: r.Interval}, nil } - _, tortoise, err = r.HpaService.UpdateHPAFromTortoiseRecommendation(ctx, tortoise, now) + tortoise, err = r.TortoiseService.UpdateResourceRequest(ctx, tortoise, currentDesiredReplicaNum, now) if err != nil { - logger.Error(err, "update HPA based on the recommendation in tortoise", "tortoise", req.NamespacedName) + logger.Error(err, "update VPA based on the recommendation in tortoise", "tortoise", req.NamespacedName) return ctrl.Result{}, err } - tortoise, err = r.TortoiseService.UpdateResourceRequest(ctx, tortoise, currentDesiredReplicaNum, now) + _, tortoise, err = r.HpaService.UpdateHPAFromTortoiseRecommendation(ctx, tortoise, now) if err != nil { - logger.Error(err, "update VPA based on the recommendation in tortoise", "tortoise", req.NamespacedName) + logger.Error(err, "update HPA based on the recommendation in tortoise", "tortoise", req.NamespacedName) return ctrl.Result{}, err } diff --git a/pkg/hpa/service.go b/pkg/hpa/service.go index cc3e9f22..a53e2d42 100644 --- a/pkg/hpa/service.go +++ b/pkg/hpa/service.go @@ -456,7 +456,7 @@ func (c *Service) ChangeHPAFromTortoiseRecommendation(tortoise *autoscalingv1bet cpu += value.AsApproximateFloat64() } if resourcename == corev1.ResourceMemory { - cpu += value.AsApproximateFloat64() + mem += value.AsApproximateFloat64() } } }