Skip to content

Commit

Permalink
Merge pull request #75 from kbrock/config-engine
Browse files Browse the repository at this point in the history
Add Settings.ems.ems_workflows.runner
  • Loading branch information
agrare committed Mar 29, 2024
2 parents 73f359f + 4516132 commit 2135570
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/settings/development.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:ems:
:ems_workflows:
:runner:
:runner_options:
:docker:
:network: host
Expand Down
21 changes: 18 additions & 3 deletions lib/manageiq/providers/workflows/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,26 @@ def self.seedable_classes
]
end

def self.floe_runner_name
if (runner_setting = Settings.ems.ems_workflows.runner.presence)
runner_setting
elsif MiqEnvironment::Command.is_podified?
"kubernetes"
elsif MiqEnvironment::Command.is_appliance? || MiqEnvironment::Command.supports_command?("podman")
"podman"
else
"docker"
end
end

def self.set_floe_runner
require "miq_environment"
require "floe"

floe_runner_settings = Settings.ems.ems_workflows.runner_options

if MiqEnvironment::Command.is_podified?
case floe_runner_name
when "kubernetes"
host = ENV.fetch("KUBERNETES_SERVICE_HOST")
port = ENV.fetch("KUBERNETES_SERVICE_PORT")

Expand All @@ -56,16 +69,18 @@ def self.set_floe_runner
}.merge(floe_runner_settings.kubernetes)

Floe.set_runner("docker", "kubernetes", options)
elsif MiqEnvironment::Command.is_appliance? || MiqEnvironment::Command.supports_command?("podman")
when "podman"
options = {}
options["root"] = Rails.root.join("data/containers/storage").to_s if Rails.env.production?
options.merge!(floe_runner_settings.podman)

Floe.set_runner("docker", "podman", options)
else
when "docker"
options = floe_runner_settings.docker.to_hash

Floe.set_runner("docker", "docker", options)
else
raise "Unknown runner: #{floe_runner_name}. expecting [kubernetes, podman, docker]"
end
end
end
Expand Down

0 comments on commit 2135570

Please sign in to comment.