Skip to content

Commit

Permalink
Merge pull request #50 from agrare/run_workflows_on_miq_automation_wo…
Browse files Browse the repository at this point in the history
…rker

Run workflows asyncrhonously on MiqAutomationWorker

(cherry picked from commit be6f4d1)
  • Loading branch information
Fryguy committed Sep 27, 2023
1 parent 1998237 commit 0d1e031
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ManageIQ::Providers::Workflows::AutomationManager::WorkflowInstance < ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationScript
def run_queue(zone: nil, role: "automate", object: nil)
def run_queue(zone: nil, role: "automate", object: nil, deliver_on: nil, server_guid: nil)
raise _("run_queue is not enabled") unless Settings.prototype.ems_workflows.enabled

args = {:zone => zone, :role => role}
Expand All @@ -12,9 +12,12 @@ def run_queue(zone: nil, role: "automate", object: nil)
:class_name => self.class.name,
:instance_id => id,
:method_name => "run",
:queue_name => "automate",
:role => role,
:zone => zone,
:args => [args],
:deliver_on => deliver_on,
:server_guid => server_guid
}

if miq_task_id
Expand Down Expand Up @@ -69,7 +72,7 @@ def run(args = {})
end

wf = Floe::Workflow.new(payload, context, creds)
wf.step
wf.run_nonblock

update!(:context => wf.context.to_h, :status => wf.status, :output => wf.output)

Expand All @@ -87,6 +90,6 @@ def run(args = {})
object.after_ae_delivery(ae_result)
end

run_queue(:zone => zone, :role => role, :object => object) unless wf.end?
run_queue(:zone => zone, :role => role, :object => object, :deliver_on => 10.seconds.from_now.utc, :server_guid => MiqServer.my_server.guid) unless wf.end?
end
end
2 changes: 1 addition & 1 deletion manageiq-providers-workflows.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "floe", "~> 0.3.0"
spec.add_dependency "floe", "~> 0.4.0"

spec.add_development_dependency "manageiq-style"
spec.add_development_dependency "simplecov", ">= 0.21.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@
end

context "with a zone and role" do
let(:zone) { FactoryBot.create(:zone) }
let(:zone) { EvmSpecHelper.local_miq_server.zone }
let(:payload) do
{
"Comment" => "Example Workflow",
"StartAt" => "FirstState",
"States" => {
"FirstState" => {
"Type" => "Pass",
"Next" => "SuccessState"
"Type" => "Wait",
"Seconds" => 10,
"Next" => "SuccessState"
},
"SuccessState" => {
"Type" => "Succeed"
Expand Down

0 comments on commit 0d1e031

Please sign in to comment.