]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commit
Refactoring of create_volume to use taskflow.
authorJoshua Harlow <harlowja@yahoo-inc.com>
Thu, 1 Aug 2013 19:08:04 +0000 (12:08 -0700)
committerJoshua Harlow <harlowja@yahoo-inc.com>
Thu, 8 Aug 2013 02:08:21 +0000 (19:08 -0700)
commite78ba969494560f99b75524304ed8ffea59db560
tree07a193674edd309b2044f16ee42ce6c6b386e111
parent568e75c511c4ca831d49b1b1294b2d8ba5bcac8e
Refactoring of create_volume to use taskflow.

Move the create_volume workflow to using taskflow and
split that workflow into three major pieces (each with
there own workflow) and create tasks that perform the
individual required actions to accomplish the pieces
desired outcome.

1. An api workflow composed of the following tasks:
  - Extracting volume request (which checks types, values) and creates a
    standard output for other tasks to work on (allowing further tasks to be
    plugged in the chain without having to worry about other tasks output
    formats).
  - Quota reservation (rolled back on failure).
  - Database entry creation.
  - Quota committing.
  - Volume RPC casting to volume scheduler or to targeted volume manager.
2. A scheduler workflow composed of the following tasks:
  - Extracting scheduler request specification for further tasks to use.
  - Change status & notify (activated only on failure).
  - Create volume scheduler driver call (which will itself RPC cast to a
    targeted volume manager).
3. A manager workflow composed of the following tasks:
  - Extract volume request specification from incoming request for
    further tasks to use. This also breaks up the incoming request into the 4
    volume types that can be created later.
  - Change status & notify on failure or reschedule on failure, this is
    dependent on if rescheduling is enabled *and* which exception types are
    thrown from the volume creation code.
  - Create volume from specification
    - This contains the code to create from image, create raw volume, create
      from source volume, create from snapshot using the extracted volume
      specification.
  - Change status & notify success.

Key benefits:
  - Handled exceptions in a easier to understand, easier to review and more
    reliable way than they are currently being handled.
  - Rescheduling is now easier to understand.
  - Easier to understand structure with tasks that consume inputs, take some
    action on them and produce outputs and revert on subsequent failure using
    whatever they produced to know how to revert.
  - Ability to add new unit tests that can test individual task actions by
    providing mock task inputs and validating expected task outputs.

Future additions:
  - Eventual addition of resumption logic to recover from operations stopped
    halfway through.
  - Ability to centrally orchestrate the tasks and pick and choice how
    reconciliation of failures based on code or policies.

Part of bp: cinder-state-machine

Change-Id: I96b688511b35014a8c006e4d30b875dcaf409d93
19 files changed:
cinder/exception.py
cinder/policy.py
cinder/scheduler/manager.py
cinder/taskflow/__init__.py [new file with mode: 0644]
cinder/taskflow/decorators.py [new file with mode: 0644]
cinder/taskflow/exceptions.py [new file with mode: 0644]
cinder/taskflow/patterns/__init__.py [new file with mode: 0644]
cinder/taskflow/patterns/base.py [new file with mode: 0644]
cinder/taskflow/patterns/linear_flow.py [new file with mode: 0644]
cinder/taskflow/states.py [new file with mode: 0644]
cinder/taskflow/task.py [new file with mode: 0644]
cinder/taskflow/utils.py [new file with mode: 0644]
cinder/tests/test_volume.py
cinder/utils.py
cinder/volume/api.py
cinder/volume/flows/__init__.py [new file with mode: 0644]
cinder/volume/flows/create_volume.py [new file with mode: 0644]
cinder/volume/manager.py
taskflow.conf [new file with mode: 0644]