Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
randytqwjp committed Dec 25, 2024
1 parent 8802f3b commit d634c79
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/hpa/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ func (c *Service) ChangeHPAFromTortoiseRecommendation(tortoise *autoscalingv1bet
recommendMax = c.maximumMaxReplica
}

oldMax := hpa.Spec.MaxReplicas
hpa.Spec.MaxReplicas = recommendMax

recommendMin, err := GetReplicasRecommendation(tortoise.Status.Recommendations.Horizontal.MinReplicas, now)
Expand Down Expand Up @@ -443,11 +444,12 @@ func (c *Service) ChangeHPAFromTortoiseRecommendation(tortoise *autoscalingv1bet
minToActuallyApply = recommendMin
}

oldMin := *hpa.Spec.MinReplicas
hpa.Spec.MinReplicas = &minToActuallyApply
if tortoise.Spec.UpdateMode != autoscalingv1beta3.UpdateModeOff && recordMetrics {
// We don't want to record applied* metric when UpdateMode is Off.
netChangeMaxReplicas := float64(recommendMax - hpa.Spec.MaxReplicas)
netChangeMinReplicas := float64(recommendMin) - float64(*hpa.Spec.MinReplicas)
netChangeMaxReplicas := float64(recommendMax - oldMax)
netChangeMinReplicas := float64(recommendMin - oldMin)
cpu := float64(0)
mem := float64(0)
for _, r := range tortoise.Status.Conditions.ContainerResourceRequests {
Expand Down

0 comments on commit d634c79

Please sign in to comment.