Skip to content

Commit

Permalink
fix: exclude non-Running pods when calculating node resources
Browse files Browse the repository at this point in the history
Signed-off-by: wangyizhi1 <[email protected]>
  • Loading branch information
wangyizhi1 committed Dec 27, 2023
1 parent b68ef41 commit 3920848
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ func (r *RootPodReconciler) UpdatePodInLeafCluster(ctx context.Context, lr *leaf
r.changeToMasterCoreDNS(ctx, podCopy, r.Options)
}

klog.V(4).Infof("Updating pod %+v", podCopy)
klog.V(5).Infof("Updating pod %+v", podCopy)

err := lr.Client.Update(ctx, podCopy)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions pkg/utils/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ func GetPodsTotalRequestsAndLimits(podList *corev1.PodList) (reqs corev1.Resourc
if IsVirtualPod(&pod) {
continue
}
if pod.Status.Phase != corev1.PodRunning {
continue
}
podReqs, podLimits := v1resource.PodRequestsAndLimits(&pod)
for podReqName, podReqValue := range podReqs {
if value, ok := reqs[podReqName]; !ok {
Expand Down Expand Up @@ -90,6 +93,9 @@ func GetUsedPodNums(podList *corev1.PodList, nodes *corev1.NodeList) (res corev1
if IsVirtualPod(&pod) {
continue
}
if pod.Status.Phase != corev1.PodRunning {
continue
}
node, exists := nodeMap[pod.Spec.NodeName]
if !exists || node.Spec.Unschedulable || !NodeReady(&node) {
continue
Expand Down

0 comments on commit 3920848

Please sign in to comment.