Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #9508 - use Dynflow sub-plans support for sub tasks and bulk actions #104

Merged
merged 1 commit into from Mar 17, 2015

Conversation

iNecas
Copy link
Member

@iNecas iNecas commented Mar 13, 2015

Bulk actions is just one of the use-cases for using sub-plans. This patch
extract the common code to be used for triggering external tasks in
general and moves that to the Dynflow.

The usage is as follows: one needs to inherit it's action from the
Actions::ActionWithSubPlans and override the
create_sub_plans method. The create_sub_plans will be executed in
run phase and the rest of the action will make sure that the execution of
the action will wait till the sub plan is done. It also tracks the relation
between parent and child tasks, as it already did in bulk actions.

An example code could look like this (taken from real Katello actions):

class SyncAsSubPlan < Actions::ActionWithSubPlans
 input_format do
   param :id, Integer
 end

  def plan(repository)
   plan_self(:id => repository.id)
 end

  def create_sub_plans
   trigger(Repository::Sync, ::Katello::Repository.find(input[:id]))
 end
end

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • e5a45c5 must be in the format Fixes/refs #redmine_number - brief description.

Guidelines are available on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@iNecas
Copy link
Member Author

iNecas commented Mar 13, 2015

Depends on Dynflow/dynflow#145

@bbuckingham
Copy link
Member

Ran a test of fusor which uses ActionWithSubPlans and it ran cleanly, with no unexpected behaviors. This included both this PR and the referenced dynflow PR.

if parent_task
ret.concat(parent_task.with_parents)
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you would like to make things more complicated [self, *(parent_task.with_parents if parent_task)] ;)

@pitr-ch
Copy link
Member

pitr-ch commented Mar 16, 2015

1 noop and 1 minor, otherwise ACK

…ulk actions

Bulk actions is just one of the use-cases for using sub-plans. This
patch extract the common code to be used for triggering external tasks
in general.

The usage is as follows: one needs to inherit it's action
from the ``Actions::ActionWithSubPlans`` and override the
``create_sub_plans`` method. The ``create_sub_plans`` will be executed
in run phase and the rest of the action will make sure that the
execution of the action will wait till the sub plan is done. It also
tracks the relation between parent and child tasks, as it already did
in bulk actions.

An example code could look like this (taken from real Katello actions):

    class SyncAsSubPlan < Actions::ActionWithSubPlans
      input_format do
        param :id, Integer
      end

      def plan(repository)
        plan_self(:id => repository.id)
      end

      def create_sub_plans
        trigger(Repository::Sync, ::Katello::Repository.find(input[:id]))
      end
    end
@iNecas
Copy link
Member Author

iNecas commented Mar 17, 2015

Comments addressed. Waiting for the CI, then merging and releasing new version of foreman-tasks

iNecas added a commit that referenced this pull request Mar 17, 2015
Fixes #9508 - use Dynflow sub-plans support for sub tasks and bulk actions
@iNecas iNecas merged commit 781b7c5 into theforeman:master Mar 17, 2015
@iNecas
Copy link
Member Author

iNecas commented Mar 17, 2015

@bbuckingham foreman-tasks 0.6.13 and dynflow 0.7.7 containt this change.The PR for foreman-packaging is here theforeman/foreman-packaging#582

@bbuckingham
Copy link
Member

Thanks @iNecas !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants