Skip to content

Commit

Permalink
fix: Fixing env request source
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
  • Loading branch information
ViBiOh committed Jan 16, 2024
1 parent ed582c5 commit 32ad008
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ func getEnvResourceRef(container v1.Container, node v1.Node, resource v1.Resourc
return getResourceLimit(*container.Resources.Limits.StorageEphemeral(), *node.Status.Capacity.StorageEphemeral(), resource.Divisor)

case "requests.cpu":
return getResourceRequest(*container.Resources.Limits.Cpu(), resource.Divisor)
return getResourceRequest(*container.Resources.Requests.Cpu(), resource.Divisor)

case "requests.memory":
return getResourceRequest(*container.Resources.Limits.Memory(), resource.Divisor)
return getResourceRequest(*container.Resources.Requests.Memory(), resource.Divisor)

case "requests.ephemeral-storage":
return getResourceRequest(*container.Resources.Limits.StorageEphemeral(), resource.Divisor)
return getResourceRequest(*container.Resources.Requests.StorageEphemeral(), resource.Divisor)

default:
return ""
Expand All @@ -394,7 +394,12 @@ func getResourceRequest(defined, divisor kubeResource.Quantity) string {
return "0"
}

value := limit / divisor.MilliValue()
divider := divisor.MilliValue()
if divider == 0 {
divider = 1000
}

value := limit / divider
if value == 0 {
return "1"
}
Expand Down

0 comments on commit 32ad008

Please sign in to comment.