Skip to content

Commit

Permalink
fix bcj doesn't make pod on node that has erased taint (openkruise#1204)
Browse files Browse the repository at this point in the history
Co-authored-by: weldonli <[email protected]>
  • Loading branch information
weldonlwz and weldonli authored Mar 23, 2023
1 parent f254871 commit f0386a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
17 changes: 4 additions & 13 deletions pkg/controller/broadcastjob/broadcastjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,9 @@ func getNodesToRunPod(nodes *corev1.NodeList, job *appsv1alpha1.BroadcastJob,
// there's pod existing on the node
if pod, ok := existingNodeToPodMap[node.Name]; ok {
canFit, err = checkNodeFitness(pod, &node)
if err != nil {
klog.Errorf("pod %s failed to checkNodeFitness for node %s, %v", pod.Name, node.Name, err)
continue
}
if !canFit {
if pod.DeletionTimestamp == nil {
podsToDelete = append(podsToDelete, pod)
}
if !canFit && pod.DeletionTimestamp == nil {
klog.Infof("Pod %s does not fit on node %s due to %v", pod.Name, node.Name, err)
podsToDelete = append(podsToDelete, pod)
continue
}
desiredNodes[node.Name] = pod
Expand All @@ -540,12 +535,8 @@ func getNodesToRunPod(nodes *corev1.NodeList, job *appsv1alpha1.BroadcastJob,
// considering nodeName, label affinity and taints
mockPod := NewMockPod(job, node.Name)
canFit, err = checkNodeFitness(mockPod, &node)
if err != nil {
klog.Errorf("failed to checkNodeFitness for node %s, %v", node.Name, err)
continue
}
if !canFit {
klog.Infof("Pod does not fit on node %s", node.Name)
klog.Infof("Pod does not fit on node %s due to %v", node.Name, err)
continue
}
restNodesToRunPod = append(restNodesToRunPod, &nodes.Items[i])
Expand Down
19 changes: 3 additions & 16 deletions pkg/controller/broadcastjob/broadcastjob_event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,8 @@ func (p *enqueueBroadcastJobForNode) addNode(q workqueue.RateLimitingInterface,
for _, bcj := range jobList.Items {
mockPod := NewMockPod(&bcj, node.Name)
canFit, err := checkNodeFitness(mockPod, node)
if err != nil {
klog.Errorf("failed to checkNodeFitness for job %s/%s, on node %s, %v", bcj.Namespace, bcj.Name, node.Name, err)
continue
}
if !canFit {
klog.Infof("Job %s/%s does not fit on node %s", bcj.Namespace, bcj.Name, node.Name)
klog.Infof("Job %s/%s does not fit on node %s due to %v", bcj.Namespace, bcj.Name, node.Name, err)
continue
}

Expand All @@ -138,17 +134,8 @@ func (p *enqueueBroadcastJobForNode) updateNode(q workqueue.RateLimitingInterfac
}
for _, bcj := range jobList.Items {
mockPod := NewMockPod(&bcj, oldNode.Name)
canOldNodeFit, err := checkNodeFitness(mockPod, oldNode)
if err != nil {
klog.Errorf("failed to checkNodeFitness for job %s/%s, on old node %s, %v", bcj.Namespace, bcj.Name, oldNode.Name, err)
continue
}

canCurNodeFit, err := checkNodeFitness(mockPod, curNode)
if err != nil {
klog.Errorf("failed to checkNodeFitness for job %s/%s, on cur node %s, %v", bcj.Namespace, bcj.Name, curNode.Name, err)
continue
}
canOldNodeFit, _ := checkNodeFitness(mockPod, oldNode)
canCurNodeFit, _ := checkNodeFitness(mockPod, curNode)

if canOldNodeFit != canCurNodeFit {
// enqueue the broadcast job for matching node
Expand Down

0 comments on commit f0386a7

Please sign in to comment.