Skip to content

Commit

Permalink
Merge pull request #2326 from neogopher/bugfix-allocatable-resources-…
Browse files Browse the repository at this point in the history
…main

bugfix: set allocatable resources to 0 when free capacity goes negative
  • Loading branch information
FabianKramm authored Dec 11, 2024
2 parents 1484731 + 833833d commit fa41bde
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/controllers/resources/nodes/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,23 @@ func (s *nodeSyncer) translateUpdateStatus(ctx *synccontext.SyncContext, pNode *
pods -= nonVClusterPods
if pods > 0 {
translatedStatus.Allocatable[corev1.ResourcePods] = *resource.NewQuantity(pods, resource.DecimalSI)
} else {
translatedStatus.Allocatable[corev1.ResourcePods] = *resource.NewQuantity(0, resource.DecimalSI)
}
if cpu > 0 {
translatedStatus.Allocatable[corev1.ResourceCPU] = *resource.NewMilliQuantity(cpu, resource.DecimalSI)
} else {
translatedStatus.Allocatable[corev1.ResourceCPU] = *resource.NewMilliQuantity(0, resource.DecimalSI)
}
if memory > 0 {
translatedStatus.Allocatable[corev1.ResourceMemory] = *resource.NewQuantity(memory, resource.BinarySI)
} else {
translatedStatus.Allocatable[corev1.ResourceMemory] = *resource.NewQuantity(0, resource.BinarySI)
}
if storageEphemeral > 0 {
translatedStatus.Allocatable[corev1.ResourceEphemeralStorage] = *resource.NewQuantity(storageEphemeral, resource.BinarySI)
} else {
translatedStatus.Allocatable[corev1.ResourceEphemeralStorage] = *resource.NewQuantity(0, resource.BinarySI)
}
}

Expand Down

0 comments on commit fa41bde

Please sign in to comment.