Skip to content

Commit

Permalink
Fixes #28067 - dynflow sidekiq services config
Browse files Browse the repository at this point in the history
  • Loading branch information
ezr-ondrej committed Jan 16, 2020
1 parent f273316 commit ad55480
Show file tree
Hide file tree
Showing 22 changed files with 235 additions and 23 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fixtures:
extlib: 'https://github.com/voxpupuli/puppet-extlib'
postgresql: 'https://github.com/puppetlabs/puppetlabs-postgresql'
puppet: 'https://github.com/theforeman/puppet-puppet'
redis: 'https://github.com/voxpupuli/puppet-redis'
systemd: 'https://github.com/camptocamp/puppet-systemd'
selinux_core:
repo: "https://github.com/puppetlabs/puppetlabs-selinux_core"
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ gem 'beaker', '>= 4.2.0', {"groups"=>["system_tests"]}
gem 'beaker-docker', {"groups"=>["system_tests"]}
gem 'beaker-hostgenerator', '>= 1.1.10', {"groups"=>["system_tests"]}
gem 'beaker-puppet', {"groups"=>["system_tests"]}
gem 'beaker-vagrant', {"groups"=>["system_tests"]}
gem 'beaker-rspec', {"groups"=>["system_tests"]}
gem 'beaker-module_install_helper', {"groups"=>["system_tests"]}
gem 'beaker-puppet_install_helper', {"groups"=>["system_tests"]}
Expand Down
13 changes: 13 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
Class['puppet::server::install'] -> Class['foreman::config']
}

if $::foreman::jobs_manage_service {
if $::foreman::jobs_sidekiq_redis_url != undef {
$jobs_redis_url = $::foreman::jobs_sidekiq_redis_url
} else {
include ::redis
$jobs_redis_url = "redis://localhost:${::redis::port}/6"
}

file { '/etc/foreman/dynflow':
ensure => directory,
}
}

concat::fragment {'foreman_settings+01-header.yaml':
target => '/etc/foreman/settings.yaml',
content => template('foreman/settings.yaml.erb'),
Expand Down
26 changes: 26 additions & 0 deletions manifests/dynflow/worker.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Initialize the dynflow worker
# @param concurrency
# Defines number of threads used for job processing
define foreman::dynflow::worker (
String $service_name = $name,
Integer[1] $concurrency = $foreman::dynflow_pool_size,
Array[String] $queues = ['default', 'remote_execution'],
String $config_owner = 'root',
String $config_group = $::foreman::group,
Stdlib::Ensure::Service $service_ensure = $::foreman::jobs_service_ensure,
Boolean $service_enable = $::foreman::jobs_service_enable
) {

file { "/etc/foreman/dynflow/${service_name}.yml":
ensure => file,
owner => $config_owner,
group => $config_group,
mode => '0644',
content => template('foreman/dynflow_worker.yml.erb'),
}

service { "dynflow-sidekiq@${service_name}":
ensure => $service_ensure,
enable => $service_enable,
}
}
9 changes: 6 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,16 @@
#
# $telemetry_logger_level:: Telemetry debugging logs level
#
# $dynflow_pool_size:: How many workers should Dynflow use
# $dynflow_pool_size:: How many threads per worker process should Dynflow use
#
# $jobs_service:: Name of the service for running the background Dynflow executor
# $jobs_manage_service:: Whether to manage the dynflow services
#
# $jobs_service_enable:: Whether the Dynflow executor should be enabled
#
# $jobs_service_ensure:: Whether the Dynflow executor should be running or stopped
#
# $jobs_sidekiq_redis_url:: If set, the redis server is not managed and we use the defined url to connect
#
# $hsts_enabled:: Should HSTS enforcement in https requests be enabled
#
# $cors_domains:: List of domains that show be allowed for Cross-Origin Resource Sharing. This requires Foreman 1.22+
Expand Down Expand Up @@ -278,9 +280,10 @@
Boolean $telemetry_logger_enabled = $::foreman::params::telemetry_logger_enabled,
Enum['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'] $telemetry_logger_level = $::foreman::params::telemetry_logger_level,
Stdlib::Port $dynflow_pool_size = $::foreman::params::dynflow_pool_size,
String $jobs_service = $::foreman::params::jobs_service,
Boolean $jobs_manage_service = $::foreman::params::jobs_manage_service,
Stdlib::Ensure::Service $jobs_service_ensure = $::foreman::params::jobs_service_ensure,
Boolean $jobs_service_enable = $::foreman::params::jobs_service_enable,
Optional[Redis::RedisUrl] $jobs_sidekiq_redis_url = $::foreman::params::jobs_sidekiq_redis_url,
Boolean $hsts_enabled = $::foreman::params::hsts_enabled,
Array[Stdlib::HTTPUrl] $cors_domains = $::foreman::params::cors_domains,
) inherits foreman::params {
Expand Down
6 changes: 6 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
}
}

if $::foreman::jobs_manage_service {
package { 'foreman-dynflow-sidekiq':
ensure => installed,
}
}

if $::foreman::ipa_authentication and $::foreman::ipa_manage_sssd {
package { 'sssd-dbus':
ensure => installed,
Expand Down
4 changes: 3 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@
$foreman_service_port = 3000

# Define job processing service properties
$jobs_service = 'dynflowd'
$jobs_manage_service = true
$jobs_service_ensure = 'running'
$jobs_service_enable = true
$jobs_sidekiq_redis_url = undef


$hsts_enabled = true

Expand Down
14 changes: 8 additions & 6 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
String $foreman_service = $::foreman::foreman_service,
Stdlib::Ensure::Service $foreman_service_ensure = $::foreman::foreman_service_ensure,
Boolean $foreman_service_enable = $::foreman::foreman_service_enable,
String $jobs_service = $::foreman::jobs_service,
Stdlib::Ensure::Service $jobs_service_ensure = $::foreman::jobs_service_ensure,
Boolean $jobs_service_enable = $::foreman::jobs_service_enable,
Boolean $jobs_manage_service = $::foreman::jobs_manage_service,
) {
service { $jobs_service:
ensure => $jobs_service_ensure,
enable => $jobs_service_enable,
if $jobs_manage_service {
foreman::dynflow::worker { 'orchestrator':
concurrency => 1,
queues => ['dynflow_orchestrator'],
}

foreman::dynflow::worker { 'worker': }
}

if $apache {
Expand Down
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
{
"name": "puppet/extlib",
"version_requirement": ">= 3.0.0 < 5.0.0"
},
{
"name": "puppet/redis",
"version_requirement": ">= 5.0.0 < 6.0.0"
}
],
"requirements": [
Expand Down
13 changes: 12 additions & 1 deletion spec/acceptance/foreman_basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class { '::apache::mod::passenger':
manage_repo => false,
}
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
Expand Down Expand Up @@ -68,7 +74,12 @@ class { '::foreman':
it { is_expected.to be_running }
end

describe service('dynflowd') do
describe service('dynflow-sidekiq@orchestrator') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('dynflow-sidekiq@worker') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down
17 changes: 14 additions & 3 deletions spec/acceptance/foreman_journald_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class { '::apache::mod::passenger':
manage_repo => false,
}
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
Expand Down Expand Up @@ -69,7 +75,12 @@ class { '::foreman':
it { is_expected.to be_running }
end

describe service('dynflowd') do
describe service('dynflow-sidekiq@orchestrator') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('dynflow-sidekiq@worker') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down Expand Up @@ -97,7 +108,7 @@ class { '::foreman':
its(:stdout) { is_expected.to match(%r{Redirected to https://#{host_inventory['fqdn']}/users/login}) }
end

describe command('journalctl -u dynflowd'), unless: ENV['TRAVIS'] == 'true' && os[:family] == 'redhat' && os[:release] =~ /^7\./ do
its(:stdout) { is_expected.to match(%r{Dynflow Executor: start in progress}) }
describe command('journalctl -u dynflow-sidekiq@orchestrator'), unless: ENV['TRAVIS'] == 'true' && os[:family] == 'redhat' && os[:release] =~ /^7\./ do
its(:stdout) { is_expected.to match(%r{Everything ready for world: }) }
end
end
13 changes: 12 additions & 1 deletion spec/acceptance/foreman_prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class { '::apache::mod::passenger':
manage_repo => false,
}
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
Expand Down Expand Up @@ -69,7 +75,12 @@ class { '::foreman':
it { is_expected.to be_running }
end

describe service('dynflowd') do
describe service('dynflow-sidekiq@orchestrator') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('dynflow-sidekiq@worker') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down
13 changes: 12 additions & 1 deletion spec/acceptance/foreman_reverse_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

let(:pp) do
<<-EOS
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
Expand Down Expand Up @@ -59,7 +65,12 @@ class { '::foreman':
it { is_expected.to be_running }
end

describe service('dynflowd') do
describe service('dynflow-sidekiq@orchestrator') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('dynflow-sidekiq@worker') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down
13 changes: 12 additions & 1 deletion spec/acceptance/foreman_rex_cockpit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

let(:pp) do
<<-EOS
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
Expand Down Expand Up @@ -59,7 +65,12 @@ class { 'foreman':
it { is_expected.to be_running }
end

describe service('dynflowd') do
describe service('dynflow-sidekiq@orchestrator') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('dynflow-sidekiq@worker') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down
13 changes: 12 additions & 1 deletion spec/acceptance/foreman_statsd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class { '::apache::mod::passenger':
manage_repo => false,
}
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
Expand Down Expand Up @@ -69,7 +75,12 @@ class { '::foreman':
it { is_expected.to be_running }
end

describe service('dynflowd') do
describe service('dynflow-sidekiq@orchestrator') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('dynflow-sidekiq@worker') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down
11 changes: 11 additions & 0 deletions spec/classes/foreman_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
it { should contain_package('foreman-postgresql').that_requires('Class[foreman::repo]') }
end

describe 'sidekiq jobs' do
context 'with jobs_manage_service disabled' do
let(:params) { super().merge(jobs_manage_service: false) }
it { is_expected.not_to contain_package('foreman-dynflow-sidekiq') }
end
context 'with jobs_manage_service enabled' do
let(:params) { super().merge(jobs_manage_service: true) }
it { is_expected.to contain_package('foreman-dynflow-sidekiq') }
end
end

context 'with SELinux enabled' do
let(:facts) { super().merge(selinux: true) }
it { should contain_package('foreman-selinux') }
Expand Down
5 changes: 1 addition & 4 deletions spec/classes/foreman_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
foreman_service: 'foreman',
foreman_service_ensure: 'running',
foreman_service_enable: true,
jobs_service: 'dynflower',
jobs_service_ensure: 'stopped',
jobs_service_enable: false
jobs_manage_service: false
}
end

Expand All @@ -28,7 +26,6 @@
context 'with ssl' do
let(:params) { super().merge(ssl: true) }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_service('dynflower').with_ensure('stopped').with_enable(false) }

it 'should restart passenger' do
should contain_exec('restart_foreman')
Expand Down
Loading

0 comments on commit ad55480

Please sign in to comment.