Skip to content

Commit

Permalink
fix: containerset does not stop container when pod removed. Fixes: ar…
Browse files Browse the repository at this point in the history
…goproj#12210

Signed-off-by: shuangkun <tsk2013uestc@163.com>
  • Loading branch information
shuangkun committed Mar 22, 2024
1 parent e547b2d commit 7c8f6d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion workflow/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ func makePodsPhase(ctx context.Context, woc *wfOperationCtx, phase apiv1.PodPhas
func deletePods(ctx context.Context, woc *wfOperationCtx) {
for _, obj := range woc.controller.podInformer.GetStore().List() {
pod := obj.(*apiv1.Pod)
err := woc.controller.kubeclientset.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{})
err := woc.controller.kubeclientset.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{GracePeriodSeconds: pointer.Int64Ptr(0)})
if err != nil {
panic(err)
}
Expand Down
11 changes: 11 additions & 0 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,17 @@ func (woc *wfOperationCtx) podReconciliation(ctx context.Context) (error, bool)
woc.updated = true
}
woc.markNodePhase(node.Name, wfv1.NodeError, "pod deleted")
// Set pod's child(container) error if pod deleted
for _, childNodeID := range node.Children {
childNode, err := woc.wf.Status.Nodes.Get(childNodeID)
if err != nil {
woc.log.Errorf("was unable to obtain node for %s", childNodeID)
continue
}
if childNode.Type == wfv1.NodeTypeContainer {
woc.markNodeError(childNode.Name, errors.New("","container deleted"))
}
}
}
}
return nil, !taskResultIncomplete
Expand Down

0 comments on commit 7c8f6d7

Please sign in to comment.