Core concepts
Jobs
In Tork, a Job is a series of tasks running in the order they appear on the job description from top to bottom.
Super simple example
name: hello job
tasks:
- name: say hello
var: task1
image: ubuntu:mantic
run: |
echo -n hello world > $TORK_OUTPUT
- name: say goodbye
image: ubuntu:mantic
run: |
echo -n bye world
What will happen:
The Coordinator will schedule the first task (
say hello
) for execution by inserting it into thedefault
queue.One of the worker nodes that is subscribed to the
default
queue will pick up the task.The worker node will inspect the
image
property to find out what Docker image is needed to execute the task.If the
ubuntu:mantic
image doesn't exist locally the worker node will pull it from Docker Hub.The worker node will start a container in order to execute the task.
The worker node will execute the
run
script on the container.The worker node will collect the output from the
$TORK_OUTPUT
file assigned to the container for any optional task output.The worker will terminate the container.
The worker will insert the task to the
completions
queue.The Coordinator will pick up the task from the
completions
queue and mark it as completed in theDatastore
.The Coordinator will insert the output of the task to the Job's context under the key specified in the
var
property (task1
).The Coordinator will check if there are any additional tasks to be executed on the job.
Since there is another task, the Coordinator will be repeat the above steps for this task.
Once all tasks are completed, the job state will be marked as
COMPLETED
.
Inputs
Jobs may specify inputs
which can be used by any of the job's tasks. Example:
name: mov to mp4
inputs:
source: https://example.com/path/to/video.mov
tasks:
- name: convert the video to mp4
image: jrottenberg/ffmpeg:3.4-alpine
env:
SOURCE_URL: '{{ inputs.source }}'
run: |
ffmpeg -i $SOURCE_URL /tmp/output.mp4