-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b32a0a1
commit b3f7d20
Showing
6 changed files
with
179 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
sequenceDiagram | ||
SmartProxyAPI->>SmartProxyAPI: /tasks/launch | ||
SmartProxyAPI->>SmartProxyAPI: TaskLauncherRegistry.fetch(params['operation']) | ||
SmartProxyAPI->>+BatchTaskLauncher: launch!(input = params['input']) | ||
participant SingleLauncher | ||
BatchTaskLauncher->>dynflow: trigger(action=BatchAction, input) | ||
dynflow->>+BatchAction: plan(launcher, input) | ||
BatchAction->>BatchTaskLauncher: launch_children(parent_action = self, input) | ||
loop Every child in the input [{child_id => child_input}] | ||
BatchTaskLauncher->>BatchTaskLauncher: SingleLauncher = child_launcher(parent_action) | ||
BatchTaskLauncher->>+SingleLauncher: launch!(child_input = input[foreman_child_plan_id]) | ||
SingleLauncher->>dynflow: results = trigger(parent, child_input) | ||
SingleLauncher->>-BatchTaskLauncher: results[foreman_child_plan_id] = results | ||
end | ||
BatchTaskLauncher->>-SmartProxyAPI: results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
sequenceDiagram | ||
SmartProxyAPI->>SmartProxyAPI: /tasks/launch | ||
SmartProxyAPI->>SmartProxyAPI: CustomGroupLauncher = TaskLauncherRegistry.fetch(params['operation']) | ||
SmartProxyAPI->>+CustomGroupLauncher: launch!(input = params['input']) | ||
participant SingleLauncher | ||
CustomGroupLauncher->>dynflow: trigger(action=SingleRunnerBatch, input) | ||
dynflow->>+SingleRunnerBatch: plan(launcher, input) | ||
SingleRunnerBatch->>CustomGroupLauncher: launch_children(parent_action = self, input) | ||
loop OutputCollector for every child | ||
CustomGroupLauncher->>CustomGroupLauncher: SingleLauncher = child_launcher(parent_action) | ||
CustomGroupLauncher->>+SingleLauncher: launch!(child_input = input[foreman_child_plan_id]) | ||
SingleLauncher->>dynflow: results = trigger(action=OutputCollector, parent, child_input) | ||
SingleLauncher->>-CustomGroupLauncher: results[foreman_child_plan_id] = results | ||
end | ||
CustomGroupLauncher->>dynflow: trigger(action=BatchRunner, parent, input) | ||
dynflow->>+BatchRunner: plan(launcher, input) | ||
BatchRunner->>-BatchRunner: initiate_runner() | ||
dynflow->>+BatchRunner: run() | ||
BatchRunner->>BatchRunner: init_run() | ||
BatchRunner->>CustomRunner: start | ||
BatchRunner-->>-dynflow: triggered | ||
dynflow-->CustomGroupLauncher: triggered | ||
CustomGroupLauncher->>-SmartProxyAPI: results |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
[[task-launching]] | ||
= How the tasks are launched | ||
:imagesdir: architecture/ | ||
|
||
Launching of the tasks done through `POST /tasks/launch` endpoint. | ||
The previously used endpoint `POST /tasks` is being decomisioned so it is not documented. | ||
|
||
For the launch to be succesful, you have to specify `operation` which has a defined launcher | ||
in the `TaskLauncherRegistry`. | ||
|
||
There are default launchers registered that can be utilized. | ||
It is useful to understand concepts of these as those are just slighly changed in actuall launchers used. | ||
For simle Tasks these can be used by themself. | ||
|
||
[single-launcher] | ||
== Single task triggering | ||
|
||
Sample input for single task triggering: | ||
|
||
[source, json] | ||
---- | ||
{ | ||
"operation": "single", | ||
"input": { | ||
"action_class": "MyDynflowActionClass", | ||
"action_input": { "some": "action data" } | ||
} | ||
} | ||
---- | ||
|
||
[batch-launcher] | ||
== Batch triggering | ||
|
||
Batch triggering allows running multiple actions while making only one HTTP API call to the Proxy. | ||
|
||
Sample input for batch triggering would be: | ||
|
||
[source, json] | ||
---- | ||
{ | ||
"operation": "batch", | ||
"input": { | ||
"<child_task_caller_ID>": { | ||
"action_class": "MyDynflowActionClass", | ||
"action_input": { "some": "childaction data" } | ||
}, | ||
"<child2_task_caller_ID": { | ||
"action_class": "MyDynflowActionClass", | ||
"action_input": { "some": "childaction2 data" } | ||
} | ||
} | ||
} | ||
---- | ||
|
||
This allows running multiple independent actions, that share same parent action in the underlying dynflow, | ||
but nothing much apart of that. | ||
|
||
Following diagram tries to show how this gets processed internally. | ||
|
||
[caption="Diagram: batch launching"] | ||
image::batch_launching.svg[Batch launching] | ||
|
||
|
||
[group-launcher] | ||
== Group triggering | ||
|
||
Group triggering is there to run single action on multiple nodes (Hosts). | ||
This has the advantage of having only one runner and safe resources, if the runner actually support running for multiple nodes. | ||
|
||
Best example is probably Ansible, but there would be more like that. | ||
|
||
First we need to implement and register the actual group launcher as we need to define what runner to use for the group. | ||
|
||
[source, ruby] | ||
---- | ||
class Runner::CoolRunner < ::Proxy::Dynflow::Runner::Parent | ||
def initialize(input, suspended_action:) | ||
super input, suspended_action: suspended_action | ||
# prepare the stuff from input you need to perform cool things | ||
end | ||
def start | ||
# start doing the cool stuff for the nodes | ||
end | ||
def kill | ||
# stop doing the cool stuff prematurely | ||
end | ||
end | ||
class TaskLauncher::MyCoolLauncher < Proxy::Dynflow::TaskLauncher::AbstractGroup | ||
def operation | ||
'cool-operation' | ||
end | ||
def self.runner_class | ||
Runner::CoolRunner | ||
end | ||
end | ||
Proxy::Dynflow::TaskLauncherRegistry.register('cool-operation', | ||
TaskLauncher::MyCoolLauncher) | ||
---- | ||
|
||
Then the input for launching our cool-operation would be: | ||
|
||
---- | ||
{ | ||
"operation": "cool-operation", | ||
"input": { | ||
"<child_task_caller_ID>": { | ||
"action_input": { "some": "childaction data" } | ||
}, | ||
"<child2_task_caller_ID": { | ||
"action_input": { "some": "childaction2 data" } | ||
} | ||
} | ||
} | ||
---- | ||
|
||
You can notice that you do not need to define the action, as our Runner defines how to run stuff for every node. | ||
|
||
The following diagram can be used to compare the launch with the Batch launching. | ||
|
||
[caption="Diagram: group launching"] | ||
image::group_launching.svg[Group launching] |