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

Add support for dynflow_sidekiq #292

Merged
merged 6 commits into from
Jan 22, 2020
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
39 changes: 39 additions & 0 deletions definitions/features/dynflow_sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class Features::DynflowSidekiq < ForemanMaintain::Feature
metadata do
label :dynflow_sidekiq

confine do
server? && find_package('foreman-dynflow-sidekiq')
end
end

def services
service_names.map { |service| system_service service, instance_priority(service) }
end

def config_files
# Workaround until foreman-installer can deploy scaled workers
service_symlinks = configured_services.map do |service|
"/etc/systemd/system/multi-user.target.wants/#{service}.service"
end
[
'/etc/foreman/dynflow',
service_symlinks
].flatten
end

private

def instance_priority(instance)
# Orchestrator should be started before the workers are
instance.end_with?('@orchestrator') ? 30 : 31
end

def service_names
configured_instances.map { |instance| "dynflow-sidekiq@#{instance}" }
end

def configured_instances
Dir['/etc/foreman/dynflow/*'].map { |config| File.basename(config, '.yml') }
end
end
2 changes: 1 addition & 1 deletion definitions/features/foreman_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def fetch_tasks_status(state, spinner)
end

def services
[system_service(service_name, 30)]
feature(:dynflow_sidekiq) ? [] : [system_service(service_name, 30)]
Copy link
Member

Choose a reason for hiding this comment

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

Does that mean rest of things from feature foreman_tasks remain as it is and only services get changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly

Copy link
Member

Choose a reason for hiding this comment

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

AFAIK foreman-tasks hasn't had a service ever since dynflowd was introduced. dynflowd is part of Foreman itself while foreman-tasks is an optional plugin. dynflowd.service always had the alias foreman-tasks so systemctl status foreman-tasks continued to work.

end

def service_name
Expand Down
34 changes: 34 additions & 0 deletions definitions/features/redis.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Features::Redis < ForemanMaintain::Feature
metadata do
label :redis

confine do
# Luckily, the service name is the same as the package providing it
server? && find_package(service_name)
Copy link
Member

Choose a reason for hiding this comment

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

Given block passed as argument to metadata and its execution happens outside of this feature scope so it will raise an error for service_name.

Either you can declare one more constant or use "#{SCL_NAME}-redis" directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, forgot about that. Fixed in a slightly different way

end
end

def services
[system_service(self.class.service_name, 10)]
end

def config_files
%w[redis redis.conf].map { |config| File.join(self.class.etc_prefix, config) }
end

class << self
SCL_NAME = 'rh-redis5'.freeze

def etc_prefix
"/etc/opt/rh/#{SCL_NAME}"
end

def scl_prefix
"#{SCL_NAME}-"
end

def service_name
"#{scl_prefix}redis"
end
end
end