MCPcopy
hub / github.com/argoproj/argo-workflows / executeSuspend

Method executeSuspend

workflow/controller/operator.go:3786–3835  ·  view source on GitHub ↗
(ctx context.Context, nodeName string, templateScope string, tmpl *wfv1.Template, orgTmpl wfv1.TemplateReferenceHolder, opts *executeTemplateOpts)

Source from the content-addressed store, hash-verified

3784}
3785
3786func (woc *wfOperationCtx) executeSuspend(ctx context.Context, nodeName string, templateScope string, tmpl *wfv1.Template, orgTmpl wfv1.TemplateReferenceHolder, opts *executeTemplateOpts) (*wfv1.NodeStatus, error) {
3787 node, err := woc.wf.GetNodeByName(nodeName)
3788 if err != nil {
3789 node = woc.initializeExecutableNode(ctx, nodeName, wfv1.NodeTypeSuspend, templateScope, tmpl, orgTmpl, opts.boundaryID, wfv1.NodePending, opts.nodeFlag, true)
3790 woc.resolveInputFieldsForSuspendNode(ctx, node)
3791 }
3792 woc.log.WithField("nodeName", nodeName).Info(ctx, "node suspended")
3793
3794 // If there is either an active workflow deadline, or if this node is suspended with a duration, then the workflow
3795 // will need to be requeued after a certain amount of time
3796 var requeueTime *time.Time
3797
3798 if tmpl.Suspend.Duration != "" {
3799 node, err := woc.wf.GetNodeByName(nodeName)
3800 if err != nil {
3801 return nil, err
3802 }
3803 suspendDuration, err := wfv1.ParseStringToDuration(tmpl.Suspend.Duration)
3804 if err != nil {
3805 return node, err
3806 }
3807 suspendDeadline := node.StartedAt.Add(suspendDuration)
3808 requeueTime = &suspendDeadline
3809 if time.Now().UTC().After(suspendDeadline) {
3810 // Suspension is expired, node can be resumed
3811 woc.log.WithField("nodeName", nodeName).Info(ctx, "auto resuming node")
3812 if err := wfutil.OverrideOutputParametersWithDefault(node.Outputs); err != nil {
3813 return node, err
3814 }
3815 _ = woc.markNodePhase(ctx, nodeName, wfv1.NodeSucceeded)
3816 return node, nil
3817 }
3818 }
3819
3820 // workflowDeadline is the time when the workflow will be timed out, if any
3821 if workflowDeadline := woc.getWorkflowDeadline(); workflowDeadline != nil {
3822 // There is an active workflow deadline. If this node is suspended with a duration, choose the earlier time
3823 // between the two, otherwise choose the deadline time.
3824 if requeueTime == nil || workflowDeadline.Before(*requeueTime) {
3825 requeueTime = workflowDeadline
3826 }
3827 }
3828
3829 if requeueTime != nil {
3830 woc.requeueAfter(time.Until(*requeueTime))
3831 }
3832
3833 _ = woc.markNodePhase(ctx, nodeName, wfv1.NodeRunning)
3834 return node, nil
3835}
3836
3837func (woc *wfOperationCtx) resolveInputFieldsForSuspendNode(ctx context.Context, node *wfv1.NodeStatus) {
3838 if node.Inputs == nil {

Callers 1

executeTemplateMethod · 0.95

Calls 9

markNodePhaseMethod · 0.95
getWorkflowDeadlineMethod · 0.95
requeueAfterMethod · 0.95
GetNodeByNameMethod · 0.80
InfoMethod · 0.65
WithFieldMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected