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 3 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).gsub(/\.yml$/, '') }
adamruzicka marked this conversation as resolved.
Show resolved Hide resolved
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
22 changes: 22 additions & 0 deletions definitions/features/redis.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Features::Redis < ForemanMaintain::Feature
SCL_PREFIX = 'rh-redis5'.freeze
adamruzicka marked this conversation as resolved.
Show resolved Hide resolved
SERVICE_NAME = "#{SCL_PREFIX}-redis".freeze
Copy link
Member

Choose a reason for hiding this comment

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

This could be fine for now, but will be an issue for Debian if ever used there. This will also break on EL8 when we land there. Unfortunately other SCLs have syspaths packages to allow using the classic service names. Redis does not appear to. @evgeni have you seen anything? would it be worth our shipping our own?

Copy link
Member

Choose a reason for hiding this comment

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

We can ask the SCL team to provide one? :)


metadata do
label :redis

confine do
# Luckily, the service name is the same as the package providing it
server? && find_package(SERVICE_NAME)
end

def services
[system_service(SERVICE_NAME, 10)]
end

def config_files
["/etc/opt/rh/#{SCL_PREFIX}/redis",
Copy link
Member

Choose a reason for hiding this comment

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

I think this is a directory puppet-redis adds to be ready for multiple instances but we don't intend to use those. AFAIK the RPM doesn't create this directory. Debian(-based) does have such a directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should be safe, if a file does not exist, f-m will just skip it. I'd say it is better to try to collect everything there is

"/etc/opt/rh/#{SCL_PREFIX}/redis.conf"]
Copy link
Member

Choose a reason for hiding this comment

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

These paths will also be different when there is no SCL. On non-SCL (EL8), it's /etc/redis.conf. Debian(-based) uses /etc/redis/redis.conf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled it similarly as with the scl prefix. When support for el8/deb lands, the etc_prefix method will need to contain a condition checking current platform

end
end
end