Skip to content

Commit

Permalink
Merge pull request #352 from wangyizhi1/release-0.2.0
Browse files Browse the repository at this point in the history
fix: exclude non-Running pods when calculating node resources
  • Loading branch information
wuyingjun-lucky authored Dec 27, 2023
2 parents 6b157c0 + 3920848 commit 8a2c69f
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 8a2c69f

Please sign in to comment.