runStep - noetl/noetl GitHub Wiki

E.g. exitCode = runStep(taskInstance, stepInstance, branchInstance)

Parameters

  • task: task object that includes the current step
  • step: step object containing the fields associated with the current step
  • branch: branch object that includes the current step

Key Variables

  • exitCode: initialized as 0; the return value as a result of running the step
  • stepStartDate: current date and time when the step is run
  • cursorQueue: stores the cursors to be run
  • THREAD: number of cursors to run in parallel
  • thid: thread ID; only used if the step's cursor is a list to keep track of current cursor element

Functionality

RunStep initializes the exitCode to 0, and the stepStartDate to the current time. The cursorQueue is instantiated.

If the step.cursor is a list, then the thid is initialized to 0 to keep track of the number of cursors in the queue. Looping through the cursors in step.cursor, cursors are put into the cursorQueue until the thid equals the THREAD amount. When the two values are equal, thid is reset to 0, and exitCode is set to the return value of calling runThreads on the step and cursorQueue. After iterating through all the cursors, if the cursorQueue isn't empty, the remaining cursors in the queue are run with runThreads.

Else if the cursor isn't a list, then runStep checks if the step's action exists (CONF_NOT_FOUND is not in step.action). If so, eval is called on the step's action (runshell), passing in the appropriate parameters for the action function. After running all the cursors for the step, if the length of the cursorFail list is not 0, then the exitCode is set to -1 and the step's cursor is reset to just the failed cursors. The number of step failures is incremented. If the number of step failures is less than the number of max failures, then the cursorFail list resets to empty, and the step waits its waittime until re-running the step by calling runStep again.

Except Statement

If an error arises, the except block writes to the log file, recording the time, current step where the failure occurred, and the error message.

The exitCode is set equal to -1, indicating a failure.

Return Value

Returns the exitCode.