Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Interim save

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px

StatuscolourYellowtitleWork in Progress 

Introduction

JobScheduler can manage work flow according to the results of jobs - i.e. their return codes. It can use job return codes to:

...

Jira
serverSOS JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution,fixversions
maximumIssues20
jqlQueryissue = js-1193 or issue = js-1190
serverId6dc67751-9d67-34cd-985b-194a8cdc9602

Use Cases

  • Welche Rolle ist für den Fall verantwortlich? Wer will etwas? Engineering, Operating, Business
  • Was ist das Ziel? Was ist das Mittel? Was ist die Motivation?

Start one or multiple job chains

Assign Unique Order IDs

Parameter handling

Example Exit code range

Workflow control by job return codes allows conditional job chain execution and the representation of more dynamic and complex processes than was previously possible with JobScheduler. This feature should therefore be relevant to Engineering, Operating and Business.

The return codes from individual jobs in a job chain can be used to:

  • start one or more job chains
  • dynamically generate order IDs and assign parameters
  • extend the range of error handling possibilities.

Feature Scope

Feature Implementation

...

Code Block
languagexml
titleJobChain0 with return code parameters
<job_chain title="JobChain0">
	<job_chain_node error_state="Error" job="Job1" next_state="2" state="1"/>
	<job_chain_node error_state="Error" job="Job2" next_state="3" state="2"/>
	<job_chain_node error_state="Error" job="Job3" next_state="4" state="3">
		<on_return_codes>
			<on_return_code return_code="0">
				<add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="Chain1"/>
			</on_return_code>
		</on_return_codes>
	</job_chain_node>
	<job_chain_node error_state="Error" job="Job4" next_state="5" state="4"/>
	<job_chain_node error_state="Error" job="Job5" next_state="6" state="5"/>
	<job_chain_node error_state="Error" job="Job6" next_state="Success" state="6"/>
	<job_chain_node state="Success"/>
	<job_chain_node state="Error"/>
</job_chain>

.

Further Examples

...

The following subjects have not been covered in this article:

  • Workflow within a job chain
  • Workflow within Job Chain & Error handling
  • Setting Parameters parameters and Order order Ids

Delimitation
Status
colourYellow
title To REDO

...

 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Scope

  • Worum geht es? In einem Satz.
  • Für welches Release? (Confluence Macro display_feature_availablity)

Use Case

  • Welche Rolle ist für den Fall verantwortlich? Wer will etwas? Engineering, Operating, Business
  • Was ist das Ziel? Was ist das Mittel? Was ist die Motivation?

Implementierung

  • Wie ist die Lösung implementiert? Mit welchen Mitteln?

Delimitation

  • Abgrenzungen, was ein Feature nicht leistet, z.B. nur für bestimmten Plattformen verfügbar
  • Funktionalität, die eben nicht bereitgestellt wird
  • Limitation (technische Beschränkungen)

Example

  • Beispiel Code und Erläuterungen
    • Code Beispiel via Confluence Code Macro
  • Beispiel Objekte
    • Ganze Objekte wie jobs, orders etc nur als Anhang

References

  • Change Management References
    • JIRA Issues
  • Documentation
    •  XML Element in der Referenzdokumentation

 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

JS-1190 - Control the workflow of a job chain by exit codes

Workflow Control
This feature allows to configure the next job node in a job chain for a range of exit codes of the current job.

In addition to controlling the workflow by next_state (true) and error_state attributes the exit code of shell processes can be used directly. The return values true and false of API tasks are are mapped to the same result as exit code 0 (success) and 1 (error).

Use Cases

  • If the exit code of the current task returns 3 then the next state for the order should be the error state. Other exit codes are considered to represent the successful execution of the task.
  • If the exit code of the current task returns one of the values 3-9 then the order should be assigned a specific state and should be continued by the respective job node.

Examples

<job_chain
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://www.sos-berlin.com/repository/scheduler/1.9/scheduler.xsd">
    <job_chain_node state="100" job="/test-a"/>
    <job_chain_node state="200" job="/test-a">
        <on_return_codes>
            <on_return_code return_code="7..9 100..199 -99999..-1000">
                <to_state state="end"/>
            </on_return_code>
        </on_return_codes>
    </job_chain_node>
    <job_chain_node state="300" job="/test-a"/>
    <job_chain_node.end state="end"/>
</job_chain>

Explanations

  • Should the element <to_state> be missing, then JobScheduler will apply the job_chain_node/@next_state or job_chain_node/@error_state attribute.
  • For return_code single values can be specified and closed intervals [i, j] separated by spaces, e.g. "1..5 7 12..15".
  • Each return code can only be used once..
  • The attributes next_state and error_state are applied if no on_return_code element is used.
  • Should no <on_return_code> element match the current return code then JobScheduler will apply the job_chain_node/@next_state (return code 0) or job_chain_node/@error_state (other return codes) attribute.

 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

JS-1193 -Start of an order should be possible depending on the result of a task of a job chain node

Plugin

  • A Plugin is provided that handles the return code of a previous job node:
    <NodeOrderPlugin:add_order NodeOrderPlugin:job_chain="/test-b"/>
    
  • The following modes are available for the handling of the Order ID when adding orders:
    • If no Order ID is specified then the order receives the Order ID of the current order. A different job chain has to be specified and that job chain must not contain an order with same Order ID.
    • The order is assigned an individual Order ID and job chain (which includes assigning the current job chain). The Order ID of the current order can be referenced by using the variable $ {ORDER_ID}

      .

    • Examples
      • <add_order job_chain="..."/> adds an order with the same Order ID as the current order to a different job chain.
      • <add_order id=“${ORDER_ID}.1” job_chain="..."/> adds an order with parts of the Order ID being created from a reference to the Order ID of the current order. The current job chain or a different job chain can be used.
  • The handling of parameters is applied as follows:
    • A newly added order receives a copy of the parameters of the current order.
    • Additional parameters can be added by using the elements <add_order><params><param name="..." value="..."/>.... Additional parameters have precedence to parameters of the current order.
  • Any errors when adding the order to the job chain are logged and ignored.

Configuration
Following configuration has to be applied to scheduler.xml to enable the corresponding plugin:

<?xml version="1.0" encoding="utf-8"?>
<spooler xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.sos-berlin.com/repository/scheduler/1.7/scheduler.xsd">
    <config>
        <plugins>
            <plugin java_class="com.sos.scheduler.engine.plugins.nodeorder.NodeOrderPlugin"/>
        </plugins>
    </config>
</spooler>

Complete sample job chain

<?xml version="1.0" encoding="utf-8"?>
<job_chain
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://www.sos-berlin.com/repository/scheduler/1.9/scheduler.xsd"
        xsi:schemaLocation="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin NodeOrderPlugin.xsd"
        xmlns:NodeOrderPlugin="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin">
    <job_chain_node state="200" job="/test-exit-7">
        <on_return_codes>
            <on_return_code return_code="7">
                <NodeOrderPlugin:add_order NodeOrderPlugin:job_chain="test-a"/>
            </on_return_code>
            <on_return_code return_code="5">
                <NodeOrderPlugin:add_order NodeOrderPlugin:job_chain="./test-b"/>
                <NodeOrderPlugin:add_order NodeOrderPlugin:job_chain="/other-folder/test-c" NodeOrderPlugin:id="${ORDER_ID\u0022}-copy"/>
            </on_return_code>
            <on_return_code return_code="9">
                <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="/x">
                    <params>
                        <param name="a" value="AAA"/>
                        <param name="b" value="BBB"/>
                    </params>
                </add_order>
                <to_state state="end"/>
            </on_return_code>
        </on_return_codes>
    </job_chain_node>
    <job_chain_node.end state="end"/>
</job_chain>

Explanations

  • The NodeOrderPlugin allows to specify absolute and relative paths for job chains. Relative paths are based on the location of the current job chain.
  • Multiple orders (in different job chains) can be started for the same return code.
  • The job chain path of the new order can be used relative to the current job chain. Just let the path start with "./".
  • Mixed usage for orders that should be added and for the job node state that an order should move to is possible.

To use the plugin, it has to be included in the JobScheduler configuration file scheduler.xml:

<?xml version="1.0" encoding="utf-8"?>
<spooler xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://www.sos-berlin.com/repository/scheduler/1.9/scheduler.xsd">
    <config>
        <plugins>
            <plugin java_class="com.sos.scheduler.engine.plugins.nodeorder.NodeOrderPlugin"/>
        </plugins>
    </config>
</spooler>

Restriction

...

<add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" 
                    job_chain="03_JobChainB"/>

...