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

Fixes #18757 - Move foreman-tasks service to Foreman #530

Closed
wants to merge 1 commit into from

Conversation

dLobatog
Copy link
Member

@dLobatog dLobatog commented Mar 1, 2017

As per #18618, the dynflow executor is moving over to Foreman, in order
to support ActiveJob. Tasks will provide an UI and persistence layer for
Dynflow, but Foreman should be able to run jobs without it too.

Part of this effort includes moving the Dynflow executor over to
Foreman, which at the moment is managed by the foreman-tasks service.

theforeman/foreman#4316 has to be merged before this

@ekohl
Copy link
Member

ekohl commented Mar 3, 2017

Any reason it has to live in tasks_service rather than service? I'm guessing that the service needs a restart if any settings change which it currently won't.

Other than that we generally keep compatibility with older Foreman versions (current and current - 1 is what we at least aim for) or bump the major version. The current implementation breaks on 1.14 without foreman-tasks so it needs to deal with this.

$service = $::foreman::params::tasks_service,
) inherits foreman::params {
service { 'foreman-tasks':
ensure => running,
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest pulling the variables out so you can overwrite them if you want.
Just move them to the "signature" of the class, similar to service.

@dLobatog
Copy link
Member Author

dLobatog commented Mar 9, 2017

@ekohl Actually no need to restart the tasks service AFAIK - that's not a problem. I see a small problem though if foreman 1.14 has to be supported. The situation is the following:

On 1.14:

  • foreman-tasks ships the foreman-tasks service. This service starts the dynflow executor.
  • foreman 'core' does not ship the foreman-tasks service. it does not have anything to do with dynflow

On 1.15:

  • foreman-tasks does not ship the foreman-tasks service. It needs foreman to run the dynflow executor
  • foreman 'core' ships 'foreman-tasks' to start the dynflow executor.

To keep this module compatible with both versions it would require:

We thought about changing the foreman-tasks service to a "fake" one that simply calls 'foreman-jobs' (a renamed foreman-tasks task in Foreman core) for everything. That would mean:

  • Keeping the foreman-tasks module as-is
  • On 1.15: foreman-jobs is started automatically with the foreman service.

@dLobatog
Copy link
Member Author

@mmoll What you suggested was having a parameter dynflow_in_core = true that triggers the foreman-tasks service from foreman or foreman-tasks depending on its value, correct?

@mmoll
Copy link
Contributor

mmoll commented Mar 10, 2017

@dLobatog exactly.

@dLobatog
Copy link
Member Author

Updated to reflect the changes asked for @ekohl @mmoll & @timogoebel - I have to add tests for this dynflow_in_core option to ensure it works properly. I suppose I'd have to add dynflow_in_core: true to the default options in the installer if theforeman/foreman#4316 gets merged on time

) inherits foreman::plugin::tasks::params {
if $dynflow_in_core == false {
Copy link
Member

Choose a reason for hiding this comment

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

nitpick, cant you just use

unless $dynflow_in_core {

@@ -99,6 +99,7 @@
$init_config_tmpl = 'foreman.sysconfig'
$puppet_etcdir = '/etc/puppet'
$puppet_home = '/var/lib/puppet'
$tasks_service = 'foreman-tasks'
Copy link
Member

Choose a reason for hiding this comment

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

IMHO we should not call it foreman-tasks

@@ -0,0 +1,28 @@
# = foreman-tasks service
Copy link
Member

Choose a reason for hiding this comment

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

nitpick about the name, imho dynflow or background-jobs makes sense not to confuse with task plugin.

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 I'd prefer to name it foreman::service::tasks (or jobs).

$ensure = $::foreman::params::tasks_service_ensure,
$enable = $::foreman::params::tasks_service_enable,
) inherits foreman::params {
service { 'foreman-tasks':
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: use the parameter?

@dLobatog dLobatog force-pushed the 18757 branch 3 times, most recently from 55cdc15 to 2cd459d Compare March 16, 2017 13:06
@mmoll
Copy link
Contributor

mmoll commented Mar 17, 2017

please check the test errors

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

There's a section in the README with compatibility notes. We typically describe parameters like dynflow_in_core there with a note how 1.14 users should continue using this module.

Given these changes, we should also bump the major version after merging this. That should be a different commit and can be done in a separate PR.

enable => true,
name => $service,
}
unless $dynflow_in_core {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this parameter is actually needed. Given there's an include in foreman::service if it's true that means it's going to be included anyway.

You're also losing the notify on the service if the plugin changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

This one is precisely for the opposite thing - if it's false, I don't want to include the tasks service as it's not necessary to restart it when foreman-tasks was installed.

Copy link
Member

Choose a reason for hiding this comment

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

My point is: if it's true, it's included anyway (through foreman::service). Here you also ensure it's included if it's false. Doesn't that mean you can unconditionally include it?


describe 'foreman::tasks_service' do
let :facts do
on_supported_os['redhat-7-x86_64']
Copy link
Member

Choose a reason for hiding this comment

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

Given this code is relevant for every distro where we run Foreman, I'd feel more comfortable if this was tested on more platforms. We've already seen that there are subtle problems with dependencies if we take these shortcuts.

@dLobatog dLobatog force-pushed the 18757 branch 9 times, most recently from 5ca06c8 to abe98eb Compare March 21, 2017 17:34
@dLobatog
Copy link
Member Author

@ekohl @mmoll mind to double check? I think I've implemented the changes you asked for. Thanks!


foreman::plugin {'remote_execution':
notify => Service['foreman-tasks'],
notify => Service[$::foreman::params::tasks_service],
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if that parameter is overridden?

@mmoll
Copy link
Contributor

mmoll commented Mar 21, 2017

what's the name of service? it'll come with the RPM/DEB package, correct?

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I think this is correct now. @mmoll could you have a look again?

README.md Outdated
@@ -51,6 +51,7 @@ previous stable release.

### Foreman version compatibility notes

For Foreman 1.15 or older, please set the 'dynflow_in_core' parameter to false.
Copy link
Contributor

Choose a reason for hiding this comment

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

1.16

@@ -0,0 +1,35 @@
# = Jobs service
#
# Service to start a Dynflow executorfor background job
Copy link
Contributor

Choose a reason for hiding this comment

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

excutor for

# On foreman 1.16+ this runs the dynflow-executor. This class could be
# renamed to dynflow-executor when this module has to be compatible with
# 1.16 and 1.17 only
#
Copy link
Contributor

Choose a reason for hiding this comment

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

version updates needed also here

it { should contain_foreman__plugin('remote_execution').that_notifies("Class[foreman::service::jobs]") }
end

context "in 1.15 or lower, tasks is included" do
Copy link
Contributor

Choose a reason for hiding this comment

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

1.16

@mmoll
Copy link
Contributor

mmoll commented Aug 31, 2017

looking good, but I first want to have the change done in nightly packages (after 1.16 RC1 would be good, I think).

@ekohl
Copy link
Member

ekohl commented Sep 15, 2017

What's the status of the packaging? Can this be merged?

Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

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

@ekohl @mmoll Rebased and updated the versions to say 1.16 where it was 1.15

@ekohl
Copy link
Member

ekohl commented Sep 19, 2017

So now it's only pending theforeman/foreman-packaging#1549?

@ares
Copy link
Member

ares commented Oct 16, 2017

@dLobatog sadly this needs another rebase

As per #18618, the dynflow executor is moving over to Foreman, in order
to support ActiveJob. Tasks will provide an UI and persistence layer for
Dynflow, but Foreman should be able to run jobs without it too.

Part of this effort includes moving the Dynflow executor over to
Foreman, which at the moment is managed by the foreman-tasks service.

Change contain to notify

Conflicts:
	manifests/plugin/tasks.pp
Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

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

Rebased with the latest master

@dLobatog
Copy link
Member Author

Tests 🍏 cc @ekohl @mmoll

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I'll send you a patch with suggestions.

@@ -51,6 +51,7 @@ previous stable release.

### Foreman version compatibility notes

For Foreman 1.16 or older, please set the 'dynflow_in_core' parameter to false.
Copy link
Member

Choose a reason for hiding this comment

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

If we want to get this in 1.16, this should be 1.15 or older

@@ -5,6 +5,7 @@
$ssl = $::foreman::ssl,
) {
anchor { ['foreman::service_begin', 'foreman::service_end']: }
contain ::foreman::service::jobs
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 should be surrounded by if $dynflow_in_core { and added added to the class parameters.

@@ -102,6 +104,8 @@
$init_config_tmpl = 'foreman.sysconfig'
$puppet_etcdir = '/etc/puppet'
$puppet_home = '/var/lib/puppet'
$jobs_service = $dynflow_in_core ? { true => 'dynflow-executor',
Copy link
Member

Choose a reason for hiding this comment

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

Since here $dynflow_in_core is always true, you can just write $jobs_service = 'dynflow-executor. If you want to dynamically determine this it should be in the foreman::service::jobs class. I'd recommend $jobs_service = undef here and then determine it later.

@ekohl
Copy link
Member

ekohl commented Jan 15, 2018

Closing since the replacement PR was merged.

@ekohl ekohl closed this Jan 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants