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

undesired service restart due to missing /var/run/php-fpm dir #501

Closed
simondeziel opened this issue Dec 20, 2018 · 4 comments · May be fixed by #531
Closed

undesired service restart due to missing /var/run/php-fpm dir #501

simondeziel opened this issue Dec 20, 2018 · 4 comments · May be fixed by #531

Comments

@simondeziel
Copy link
Contributor

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.1.0
  • Ruby: 2.5.3
  • Distribution: Ubuntu Bionic
  • Module version: 6.0.2

How to reproduce (e.g Puppet code you use)

Create a FPM pool that matches Ubuntu default config as much as possible:

    case $::os['release']['major'] {
      '18.04': { $php_version = '7.2' }
      '16.04': { $php_version = '7.0' }
      '14.04': { $php_version = '5' }
      default: { fail("${module_name} does not support this OS version") }
    }
    class { 'php::globals':
      fpm_pid_file => "/run/php/php${php_version}-fpm.pid",
    }
    class { 'php':
      dev                      => false,
      composer                 => false,
      pear                     => false,
      fpm_global_pool_settings => {
        'listen'               => "/run/php/php${php_version}-fpm.sock",
        'listen_backlog'       => '511',
        'listen_owner'         => 'www-data',
        'listen_group'         => 'www-data',
        'pm_max_children'      => '5',
        'pm_start_servers'     => '2',
        'pm_min_spare_servers' => '1',
        'pm_max_spare_servers' => '3',
        'slowlog'              => 'log/$pool.log.slow',
      },
    }

What are you seeing

The unneeded directory /var/run/php-fpm gets created during the first puppet agent run after boot and triggers an undesired service restart:

# puppet agent -t  --noop
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Applying configuration version '1545336079'
Notice: /Stage[main]/Php::Fpm::Config/File[/var/run/php-fpm/]/ensure: current_value 'absent', should be 'directory' (noop)
Notice: Class[Php::Fpm::Config]: Would have triggered 'refresh' from 1 event
Info: Class[Php::Fpm::Config]: Scheduling refresh of Class[Php::Fpm::Service]
Notice: Class[Php::Fpm::Service]: Would have triggered 'refresh' from 1 event
Info: Class[Php::Fpm::Service]: Scheduling refresh of Service[php7.2-fpm]
Notice: /Stage[main]/Php::Fpm::Service/Service[php7.2-fpm]: Would have triggered 'refresh' from 1 event
Notice: Class[Php::Fpm::Service]: Would have triggered 'refresh' from 1 event
Notice: Class[Php::Fpm]: Would have triggered 'refresh' from 2 events
Notice: Class[Php]: Would have triggered 'refresh' from 1 event
Notice: Stage[main]: Would have triggered 'refresh' from 4 events
Notice: Applied catalog in 3.24 seconds

What behaviour did you expect instead

The useless directory /var/run/php-fpm shouldn't be created and no service restart should happen due to it.

@bastelfreak
Copy link
Member

Hi @simondeziel, thanks for reporting this. Can you provide the code as an acceptance test (or even a patch for this?)? We have some examples for acceptance tests here: https://github.com/voxpupuli/puppet-php/tree/master/spec/acceptance

@simondeziel
Copy link
Contributor Author

This was fixed by commit b9f81d7 so closing. Thanks!

@mboogert
Copy link

I'm experiencing this exact same issue (again).

  • Puppet: 6.21.1
  • Distribution: Ubuntu 20.04
  • Module version: 7.1.0

After a reboot the /var/run/php-fpm directory is recreated causing php-fpm to reload.

Notice: /Stage[main]/Php::Fpm::Config/File[/var/run/php-fpm/]/ensure: created (corrective)
Info: Class[Php::Fpm::Config]: Scheduling refresh of Class[Php::Fpm::Service]
Info: Class[Php::Fpm::Service]: Scheduling refresh of Service[php7.4-fpm]
Notice: /Stage[main]/Php::Fpm::Service/Service[php7.4-fpm]: Triggered 'refresh' from 1 event

@Hufschmidt
Copy link

Hufschmidt commented May 18, 2021

This was actually not fixed as $php::globals::default_fpm_pid_file points to /var/run/php/php${globals_php_version}-fpm.pid by default (for debian/ubuntu) and is configurable, while the resource-creation in php:.fpm::config points to /var/run/php-fpm/ and is hard-coded.

Solution: Use the value of php::fpm::config::pid_file for the directory-creation in php::fpm::config.


Note that php::fpm::pool might also need to ensure directory creation in case listening on a socket (instead of an ip/port) and directories for socket and pid differ.

Also (at least on Ubuntu 18.04), the packaged systemd service does:

ExecStartPost=-/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.3/fpm/pool.d/www.conf 73
ExecStopPost=-/usr/lib/php/php-fpm-socket-helper remove /run/php/php-fpm.sock /etc/php/7.3/fpm/pool.d/www.conf 73

So this should be handled by puppet for additional pools (when using sockets).

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 a pull request may close this issue.

4 participants