Skip to content

Commit

Permalink
fix: change fatal to panic. (#12931)
Browse files Browse the repository at this point in the history
Co-authored-by: agilgur5 <agilgur5@gmail.com>
Signed-off-by: shuangkun <tsk2013uestc@163.com>
  • Loading branch information
shuangkun and agilgur5 committed Apr 12, 2024
1 parent 7eaf305 commit ec5b5d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
6 changes: 2 additions & 4 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2824,8 +2824,7 @@ func (woc *wfOperationCtx) executeContainer(ctx context.Context, nodeName string
func (woc *wfOperationCtx) getOutboundNodes(nodeID string) []string {
node, err := woc.wf.Status.Nodes.Get(nodeID)
if err != nil {
woc.log.Fatalf("was unable to obtain node for %s", nodeID)
panic(fmt.Sprintf("Expected node for %s", nodeID))
woc.log.Panicf("was unable to obtain node for %s", nodeID)
}
switch node.Type {
case wfv1.NodeTypeSkipped, wfv1.NodeTypeSuspend, wfv1.NodeTypeHTTP, wfv1.NodeTypePlugin:
Expand Down Expand Up @@ -3267,8 +3266,7 @@ func (woc *wfOperationCtx) addChildNode(parent string, child string) {
childID := woc.wf.NodeID(child)
node, err := woc.wf.Status.Nodes.Get(parentID)
if err != nil {
woc.log.Fatalf("was unable to obtain node for %s", parentID)
panic(fmt.Sprintf("parent node %s not initialized", parent))
woc.log.Panicf("was unable to obtain node for %s", parentID)
}
for _, nodeID := range node.Children {
if childID == nodeID {
Expand Down
3 changes: 1 addition & 2 deletions workflow/controller/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ func (woc *wfOperationCtx) executeStepGroup(ctx context.Context, stepGroup []wfv
for _, childNodeID := range node.Children {
childNode, err := woc.wf.Status.Nodes.Get(childNodeID)
if err != nil {
woc.log.Fatalf("was unable to obtain node for %s", childNodeID)
panic(fmt.Sprintf("unable to get childNode for %s", childNodeID))
woc.log.Panicf("Coudn't obtain child for %s, panicking", childNodeID)
}
step := nodeSteps[childNode.Name]
if childNode.FailedOrError() && !step.ContinuesOn(childNode.Phase) {
Expand Down
18 changes: 7 additions & 11 deletions workflow/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ func FormulateResubmitWorkflow(ctx context.Context, wf *wfv1.Workflow, memoized
onExitNodeName := wf.ObjectMeta.Name + ".onExit"
err := packer.DecompressWorkflow(wf)
if err != nil {
log.Fatal(err)
log.Panic(err)
}
for _, node := range wf.Status.Nodes {
newNode := node.DeepCopy()
Expand Down Expand Up @@ -764,8 +764,7 @@ func getDescendantNodeIDs(wf *wfv1.Workflow, node wfv1.NodeStatus) []string {
for _, child := range node.Children {
childStatus, err := wf.Status.Nodes.Get(child)
if err != nil {
log.Fatalf("Couldn't get child, panicking")
panic("Was not able to obtain child")
log.Panicf("Coudn't obtain child for %s, panicking", child)
}
descendantNodeIDs = append(descendantNodeIDs, getDescendantNodeIDs(wf, *childStatus)...)
}
Expand All @@ -776,8 +775,7 @@ func isDescendantNodeSucceeded(wf *wfv1.Workflow, node wfv1.NodeStatus, nodeIDsT
for _, child := range node.Children {
childStatus, err := wf.Status.Nodes.Get(child)
if err != nil {
log.Fatalf("Couldn't get child, panicking")
panic("Was not able to obtain child")
log.Panicf("Coudn't obtain child for %s, panicking", child)
}
_, present := nodeIDsToReset[child]
if (!present && childStatus.Phase == wfv1.NodeSucceeded) || isDescendantNodeSucceeded(wf, *childStatus, nodeIDsToReset) {
Expand Down Expand Up @@ -816,8 +814,7 @@ func resetConnectedParentGroupNodes(oldWF *wfv1.Workflow, newWF *wfv1.Workflow,
for {
currentNode, err := oldWF.Status.Nodes.Get(currentNodeID)
if err != nil {
log.Fatalf("dying due to inability to obtain node for %s", currentNodeID)
panic("was not able to get node, panicking")
log.Panicf("dying due to inability to obtain node for %s, panicking", currentNodeID)
}
if !containsNode(resetParentGroupNodes, currentNodeID) {
newWF.Status.Nodes.Set(currentNodeID, resetNode(*currentNode.DeepCopy()))
Expand All @@ -827,8 +824,7 @@ func resetConnectedParentGroupNodes(oldWF *wfv1.Workflow, newWF *wfv1.Workflow,
if currentNode.BoundaryID != "" && currentNode.BoundaryID != oldWF.ObjectMeta.Name {
parentNode, err := oldWF.Status.Nodes.Get(currentNode.BoundaryID)
if err != nil {
log.Fatalf("panicking unable to obtain node for %s", currentNode.BoundaryID)
panic("was not able to get node")
log.Panicf("unable to obtain node for %s, panicking", currentNode.BoundaryID)
}
if isGroupNode(*parentNode) {
currentNodeID = parentNode.ID
Expand Down Expand Up @@ -917,7 +913,7 @@ func FormulateRetryWorkflow(ctx context.Context, wf *wfv1.Workflow, restartSucce
for _, child := range descendantNodeIDs {
childNode, err := wf.Status.Nodes.Get(child)
if err != nil {
log.Fatalf("was unable to obtain node for %s due to %s", child, err)
log.Warnf("was unable to obtain node for %s due to %s", child, err)
return nil, nil, fmt.Errorf("Was unable to obtain node for %s due to %s", child, err)
}
if _, present := nodeIDsToReset[child]; present {
Expand Down Expand Up @@ -947,7 +943,7 @@ func FormulateRetryWorkflow(ctx context.Context, wf *wfv1.Workflow, restartSucce
deletedNodes[descendantNodeID] = true
descendantNode, err := wf.Status.Nodes.Get(descendantNodeID)
if err != nil {
log.Fatalf("Was unable to obtain node for %s due to %s", descendantNodeID, err)
log.Warnf("Was unable to obtain node for %s due to %s", descendantNodeID, err)
return nil, nil, fmt.Errorf("Was unable to obtain node for %s due to %s", descendantNodeID, err)
}
if descendantNode.Type == wfv1.NodeTypePod {
Expand Down

0 comments on commit ec5b5d5

Please sign in to comment.