Skip to content

Commit

Permalink
fix(all): disambiguate components and actions
Browse files Browse the repository at this point in the history
* Introduces the notion of operation --> triplet `service-name_component-name_action-name`.
  - An operation is the target of deployments.
  - Playbooks names are operation names.
  - Dag files define operations with their dependencies
* A component is only a part of a service (such as `namenode` is a component of the service `hdfs`)
* An action is the keywork defining what's being done i.e. `install`, `config`...

fix #169
  • Loading branch information
gboutry committed Jun 17, 2022
1 parent ff03357 commit b777a8a
Show file tree
Hide file tree
Showing 30 changed files with 408 additions and 395 deletions.
16 changes: 8 additions & 8 deletions docs/developer/cli/developer_quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Developer Quick Start (sqlite backend)
user@yourmachine:tdp init
2022-03-16 16:01:10,610 - DEBUG - tdp.<module> - Logger initialized
2022-03-16 16:01:11,070 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2022-03-16 16:01:11,070 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("action_log")
2022-03-16 16:01:11,070 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("operation_log")
2022-03-16 16:01:11,070 INFO sqlalchemy.engine.Engine [raw sql] ()
2022-03-16 16:01:11,070 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("deployment_log")
2022-03-16 16:01:11,071 INFO sqlalchemy.engine.Engine [raw sql] ()
Expand Down Expand Up @@ -108,15 +108,15 @@ Developer Quick Start (sqlite backend)
2022-03-16 16:50:21,379 - DEBUG - tdp.<module> - Logger initialized
2022-03-16 16:50:21,838 - WARNING - tdp.dag.validate - playbooks_dir is not defined, skip playbooks validations
Deploying zookeeper_install
2022-03-16 16:50:21,918 - DEBUG - tdp.action_runner.run - Running action zookeeper_client_install
2022-03-16 16:50:21,918 - DEBUG - tdp.operation_runner.run - Running operation zookeeper_client_install
2022-03-16 16:50:21,918 - INFO - tdp.ansible_executor.execute - [DRY MODE] Ansible command: ansible-playbook /home/diode-xue01/workspace/tdp-ops/tdp/ansible/collections/ansible_collections/tosit/tdp/playbooks/zookeeper_client_install.yml
2022-03-16 16:50:21,924 - INFO - tdp.action_runner._run_actions - Action zookeeper_client_install success
2022-03-16 16:50:21,924 - DEBUG - tdp.action_runner.run - Running action zookeeper_server_install
2022-03-16 16:50:21,924 - INFO - tdp.operation_runner._run_operations - Operation zookeeper_client_install success
2022-03-16 16:50:21,924 - DEBUG - tdp.operation_runner.run - Running operation zookeeper_server_install
2022-03-16 16:50:21,924 - INFO - tdp.ansible_executor.execute - [DRY MODE] Ansible command: ansible-playbook /home/diode-xue01/workspace/tdp-ops/tdp/ansible/collections/ansible_collections/tosit/tdp/playbooks/zookeeper_server_install.yml
2022-03-16 16:50:21,924 - INFO - tdp.action_runner._run_actions - Action zookeeper_server_install success
2022-03-16 16:50:21,924 - DEBUG - tdp.action_runner.run - Running action zookeeper_kerberos_install
2022-03-16 16:50:21,924 - INFO - tdp.operation_runner._run_operations - Operation zookeeper_server_install success
2022-03-16 16:50:21,924 - DEBUG - tdp.operation_runner.run - Running operation zookeeper_kerberos_install
2022-03-16 16:50:21,924 - INFO - tdp.ansible_executor.execute - [DRY MODE] Ansible command: ansible-playbook /home/diode-xue01/workspace/tdp-ops/tdp/ansible/collections/ansible_collections/tosit/tdp/playbooks/zookeeper_kerberos_install.yml
2022-03-16 16:50:21,924 - INFO - tdp.action_runner._run_actions - Action zookeeper_kerberos_install success
2022-03-16 16:50:21,924 - INFO - tdp.operation_runner._run_operations - Operation zookeeper_kerberos_install success
#. check deployment
Expand All @@ -125,7 +125,7 @@ Developer Quick Start (sqlite backend)
user@yourmachine:tdp browse
2022-03-16 17:22:43,295 - DEBUG - tdp.<module> - Logger initialized
Deployments:
id target filter start end state actions services
id target filter start end state operations services
---- ----------------- -------- -------------------------- -------------------------- ------- ------------------------------------------------------- ----------
1 zookeeper_install None 2022-03-16 16:50:21.918121 2022-03-16 16:50:21.925006 Success zookeeper_client_install,...,zookeeper_kerberos_install zookeeper
2 zookeeper_install None 2022-03-16 16:54:42.950678 2022-03-16 16:54:42.957124 Success zookeeper_client_install,...,zookeeper_kerberos_install zookeeper
6 changes: 3 additions & 3 deletions docs/developer/cli/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Command Line Interface
======================

TDP is a cli implemented to run actions easily
TDP is a cli implemented to run operations easily

.. toctree::

Expand All @@ -23,9 +23,9 @@ Usage
default-diff Difference between tdp_vars and defaults
deploy Deploy TDP
init Init database / services in tdp vars
nodes List nodes from components DAG
nodes List nodes from operations DAG
playbooks Generate meta playbooks in order to use tdp-collection
without tdp-lib
run Run single TDP action
run Run single TDP operation
service-versions Get the version of deployed services.(If a service has
never been deployed, does not show it)
4 changes: 2 additions & 2 deletions docs/developer/core/dag.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
DAG
===

The `Dag` class reads YAML :doc:`../components` files
and validate it according to components rules(cf. components' rules section)
The `Dag` class reads YAML :doc:`../operations` files
and validate it according to operations rules(cf. operations' rules section)
to build the DAG.

It is used to get a list of actions by performing a topological sort on the DAG
Expand Down
8 changes: 4 additions & 4 deletions docs/developer/core/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Models store classes which define the database schema.

.. _action_log:

ActionLog
---------
OperationLog
------------

Each DAG node is a component with an action. When an action is launched and finished the results are stored.
Each DAG node is an operation with an action. When an operation is performed and finished the results are stored.

.. _deployment_log:

DeploymentLog
-------------

A `DeploymentLog` is the result of running multiple actions and for each service the version deployed.
A `DeploymentLog` is the result of running multiple operations and for each service the version deployed.

ServiceLog
----------
Expand Down
20 changes: 9 additions & 11 deletions docs/developer/core/runner.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
Runners
=======

Runners are used to run actions with the DAG ordering constraints.
Runners are used to run operations with the DAG ordering constraints.

To use a runner, an :py:class:`~tdp.core.runner.action_runner.ActionRunner` must be instanciated.
To use a runner, an :py:class:`~tdp.core.runner.operation_runner.OperationRunner` must be instanciated.
In order to work, it needs a :py:class:`~tdp.core.dag.Dag` instance to run
actions with the DAG ordering constraints,an implementation of `Executor` to run each actions,
operations with the DAG ordering constraints, an implementation of `Executor` to run each operation,
a `ServiceManager` `dict` to know the service version
to deploy needed to build a :ref:`deployment_log`.

Executor
--------

:py:class:`~tdp.core.runner.executor.Executor` define the interface to run an action.
:py:class:`~tdp.core.runner.executor.Executor` define the interface to run an operation.

AnsibleExecutor
---------------

:py:class:`~tdp.core.runner.ansible_executor.AnsibleExecutor` is an implementation for :py:class:`~tdp.core.runner.executor.Executor`
in order to run action with Ansible. The action name is the Ansible playbook to execute with `ansible-playbook` command.
in order to run operations with Ansible. The operation name is the Ansible playbook to execute with `ansible-playbook` command.

ActionRunner
------------

:py:class:`~tdp.core.runner.action_runner.ActionRunner` uses :py:class:`~tdp.core.runner.executor.Executor` implementations to run one action
or run multiple action with the DAG ordering constraints.
OperationRunner
---------------

If one action is run, only an :ref:`action_log` is returned, if multiple actions are run, a :ref:`deployment_log` is returned.
:py:class:`~tdp.core.runner.operation_runner.OperationRunner` uses :py:class:`~tdp.core.runner.executor.Executor` implementations to run one operation
or run multiple opertaions with the DAG ordering constraints.
4 changes: 2 additions & 2 deletions docs/developer/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ TDP Lib documentation
.. toctree::

cli/index
components
operations
core/index


The lib code is inside `tdp` folder.

* :doc:`cli/index` for documentation which uses the code inside `core` folder.
* :doc:`components` for documentation about TDP components definition and dependencies.
* :doc:`operations` for documentation about TDP operations definition and dependencies.
* :doc:`core/index` is the lib main code folder.


Expand Down
26 changes: 13 additions & 13 deletions docs/developer/components.rst → docs/developer/operations.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Components
Operations
==========

Definition
----------

A component is composed of 3 parts: service name, component name, action.
An operation is composed of 3 parts: service name, component name, action.

Each service has components and each component has actions.

Expand All @@ -29,24 +29,24 @@ Directed acyclic graph (DAG)

This type of graph can be used to schedule the deployment and the configuration of components with ordering constraints by using a topological sort (or topological ordering) to produce a list of nodes which respect the ordering constraints.

Inside TDP, we use a DAG to deploy a component before another and determine which components should be restarted if a component configuration is updated.
Inside TDP, we use a DAG to execute an operation before another and determine which components should be restarted if a component configuration is updated.

Each node (or vertex) is a component and edges are dependencies constraints.
Each node (or vertex) is an operation and edges are dependencies constraints.

Dependency
----------

To build the DAG, each component define a list of dependencies, for example, before running `config`, we must perform `install` in order to have binaires and users.
To build the DAG, each operation defines a list of dependencies, for example, before running `config`, we must perform `install` in order to have binaires and users.

Noop flag
---------

A component can have a `noop` flag to indicate that this component should be in the DAG but nothing is executed.
An operation can have a `noop` flag to indicate that this operation should be in the DAG but nothing is executed.

YAML format
-----------

YAML is used to defined components and dependencies, for example:
YAML is used to defined operations and dependencies, for example:

.. code-block:: yaml
Expand All @@ -62,10 +62,10 @@ YAML is used to defined components and dependencies, for example:
Rules
-----

The components DAG follow rules:
The operations DAG follow rules:

* ``*_start`` actions can only be required from within its own service
* ``*_install`` actions should only depend on other `*_install` actions
* Each service (HDFS, HBase, Hive, etc) should have ``*_install``, ``*_config``, ``*_init`` and ``*_start`` actions even if they are "empty" (tagged with `noop`)
* Actions tagged with the `noop` flag should not have a playbook defined in the collection
* Each service action (`config`, `start`, `init`) except the first (`install`) must have an explicit dependency with the previous service action within the same service
* ``*_start`` operations can only be required from within its own service
* ``*_install`` operations should only depend on other ``*_install`` operations
* Each service (HDFS, HBase, Hive, etc) should have ``*_install``, ``*_config``, ``*_init`` and ``*_start`` operations even if they are "empty" (tagged with noop)
* Operations tagged with the noop flag should not have a playbook defined in its collection
* Each service action (config, start, init) except the first (install) must have an explicit dependency with the previous service operation within the same service
6 changes: 3 additions & 3 deletions docs/tdp.core.models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ tdp.core.models package
Submodules
----------

tdp.core.models.action\_log module
----------------------------------
tdp.core.models.operation\_log module
-------------------------------------

.. automodule:: tdp.core.models.action_log
.. automodule:: tdp.core.models.operation_log
:members:
:undoc-members:
:show-inheritance:
Expand Down
4 changes: 2 additions & 2 deletions docs/tdp.core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Subpackages
Submodules
----------

tdp.core.component module
tdp.core.operation module
-------------------------

.. automodule:: tdp.core.component
.. automodule:: tdp.core.operation
:members:
:undoc-members:
:show-inheritance:
Expand Down
6 changes: 3 additions & 3 deletions docs/tdp.core.runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ tdp.core.runner package
Submodules
----------

tdp.core.runner.action\_runner module
-------------------------------------
tdp.core.runner.operation\_runner module
----------------------------------------

.. automodule:: tdp.core.runner.action_runner
.. automodule:: tdp.core.runner.operation_runner
:members:
:undoc-members:
:show-inheritance:
Expand Down
Loading

0 comments on commit b777a8a

Please sign in to comment.