Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
randytqwjp committed Dec 23, 2024
1 parent e3547a6 commit c076cc4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/hpa/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,14 @@ func (c *Service) ChangeHPAFromTortoiseRecommendation(tortoise *autoscalingv1bet
netChangeMinReplicas := float64(recommendMin) - float64(*hpa.Spec.MinReplicas)
cpu := float64(0)
mem := float64(0)
if len(tortoise.Status.Conditions.ContainerResourceRequests) > 0 {
for _, requests := range tortoise.Status.Conditions.ContainerResourceRequests {
cpu += float64(requests.Resource.Cpu().Value())
mem += float64(requests.Resource.Memory().Value())
for _, r := range tortoise.Status.Conditions.ContainerResourceRequests {
for resourcename, value := range r.Resource {
if resourcename == corev1.ResourceCPU {
cpu += value.AsApproximateFloat64()
}
if resourcename == corev1.ResourceMemory {
cpu += value.AsApproximateFloat64()
}
}
}
netChangeMaxReplicasCpu := netChangeMaxReplicas * cpu
Expand Down

0 comments on commit c076cc4

Please sign in to comment.