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

disable::mpm_event: Fix module deactivation #2349

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

bastelfreak
Copy link
Collaborator

@bastelfreak bastelfreak commented Dec 6, 2022

there were a few things broken:

  • a2dismod was called with the wrong module name. at least on apache 2.4.54 on Debian 11 it is named mpm_event, not event
  • the paths to the files were wrong
  • a2dismod already purges the .load and .conf file, the exec resources
    are not required (even then a file resource would probably be cleaner
    to purge them)
  • Apache needs to be reloaded, so just running this priot to
    apache2::service isn't enough, it needs to be a notify

This initially worked but was changed from mpm_event to event in #1961. Then it was fixed in #2034 by adding the exec resources, but the actual a2dismod was still broken.

@bastelfreak bastelfreak requested a review from a team as a code owner December 6, 2022 10:41
@puppet-community-rangefinder
Copy link

apache::mpm::disable_mpm_event is a class

that may have no external impact to Forge modules.

This module is declared in 176 of 580 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

Copy link
Collaborator

@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 was wondering about differences in disable steps. We already have 2 identical disable steps: worker and prefork:

$ diff -Nut <(sed 's/worker/prefork/g' disable_mpm_worker.pp) disable_mpm_prefork.pp 
$

With this change there is a third:

$ diff -Nut <(sed 's/worker/event/g' disable_mpm_worker.pp) disable_mpm_event.pp 
--- /dev/fd/63	2022-12-06 11:53:19.373572653 +0100
+++ disable_mpm_event.pp	2022-12-06 11:53:00.571376870 +0100
@@ -1,11 +1,11 @@
 # @summary disable Apache-Module event
 class apache::mpm::disable_mpm_event {
-  $event_command = ['/usr/sbin/a2dismod', 'event']
-  $event_onlyif = [['/usr/bin/test', '-e', join([$apache::mod_enable_dir, 'event.load'],'/')]]
-  exec { '/usr/sbin/a2dismod event':
+  $event_command = ['/usr/sbin/a2dismod', 'mpm_event']
+  $event_onlyif = [['/usr/bin/test', '-e', join([$apache::mod_enable_dir, 'mpm_event.load'],'/')]]
+  exec { '/usr/sbin/a2dismod mpm_event':
     command => $event_command,
     onlyif  => $event_onlyif,
     require => Package['httpd'],
-    before  => Class['apache::service'],
+    notify  => Class['apache::service'],
   }
 }

There are 2 changes: first is that my replacement isn't quite correct, but really it would be if you introduced $mpm_name. The second is before vs notify. Looking at this file it was before, but notify looks more correct to me.

They're also (IMHO) private classes that are only used once:

unless $mpm in ['itk', 'prefork'] {
include apache::mpm::disable_mpm_prefork
}
if $mpm != 'worker' {
include apache::mpm::disable_mpm_worker
}
if $mpm != 'event' {
include apache::mpm::disable_mpm_event
}
}

Perhaps we should introduce a define and call it with the right module name?

@bastelfreak
Copy link
Collaborator Author

I also noticed this and will try to clean it up. I updated the commit description with some history of this.

ekohl
ekohl previously approved these changes Dec 6, 2022
Copy link
Collaborator

@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 is an a2mod type. I wonder that should be used. However, in the short term I'll take this cleanup.

there were a few things broken:
* a2dismod was called with the wrong module name. at least on apache
  2.4.54 on Debian 11 it is named mpm_event, not event
* the paths to the files were wrong
* a2dismod already purges the .load and .conf file, the exec resources
  are not required (even then a file resource would probably be cleaner
  to purge them)
* Apache needs to be reloaded, so just running this priot to
  apache2::service isn't enough, it needs to be a notify

This initially worked but was changed from mpm_event to event in
puppetlabs#1961. Then it was
fixed in puppetlabs#2034 by
adding the exec resources, but the actual a2dismod was still broken.
Copy link
Member

@david22swan david22swan left a comment

Choose a reason for hiding this comment

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

LGTM

@david22swan david22swan merged commit 0b74e1d into puppetlabs:main Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants