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

Run workflows asyncrhonously on MiqAutomationWorker #50

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines -72 to +75
Copy link
Member

Choose a reason for hiding this comment

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

🎉


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?
Copy link
Member

Choose a reason for hiding this comment

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

@agrare Is this what you mentioned to me?

So my question here is why we need the pinning and deliver time at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this re-queue while the docker/podman/k8s task is still running so we don't want it to spin (hence deliver on) and we need to run it on the same server so podman inspect will be able to see the running container.

Copy link
Member

Choose a reason for hiding this comment

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

ohhh I see - ok, this is what I wasn't understanding in our discussion yesterday because I thought it worked differently.

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