Skip to content

Commit

Permalink
Adds log to not manage /var/run/redis with systemd
Browse files Browse the repository at this point in the history
* The existence of /var/run/redis causes the startup of redis-server via
systemd to fail on debian systems with redis-server >= 3.2.8-2:

```
May 18 19:17:54 debian-8 systemd[1]: Starting Advanced key-value store...
       May 18 19:17:54 debian-8 systemd[803]: Failed at step RUNTIME_DIRECTORY spawning /bin/run-parts: File exists
       May 18 19:17:54 debian-8 systemd[804]: Failed at step RUNTIME_DIRECTORY spawning /usr/bin/redis-server: File exists
       May 18 19:17:54 debian-8 systemd[1]: redis-server.service: control process exited, code=exited status=233
       May 18 19:17:54 debian-8 systemd[1]: Failed to start Advanced key-value store.
       May 18 19:17:54 debian-8 systemd[1]: Unit redis-server.service entered failed state.
       May 18 19:17:54 debian-8 systemd[1]: redis-server.service holdoff time over, scheduling restart.
```
* It will actually eventually start, but the first run will fail
* The default unit file for redis-server in debian jessie-backports
contains `RuntimeDirectory=redis`, see [this commit](https://github.com/lamby/pkg-redis/commit/1cecea5abcb2ce05beacd4347977634d06c59cef).
* Adds logic to not manage the /var/run/redis directory if systemd present
  • Loading branch information
ntnn authored and petems committed May 18, 2017
1 parent 481a487 commit 1827691
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 12 deletions.
28 changes: 16 additions & 12 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,24 @@
owner => $::redis::config_owner,
}

case $::operatingsystem {
'Debian': {
$var_run_redis_mode = '2775'
}
default: {
$var_run_redis_mode = '0755'
$service_provider_lookup = pick(getvar_emptystring('service_provider'), false)

if $service_provider_lookup != 'systemd' {
case $::operatingsystem {
'Debian': {
$var_run_redis_mode = '2775'
}
default: {
$var_run_redis_mode = '0755'
}
}
}

file { '/var/run/redis':
ensure => 'directory',
owner => $::redis::config_owner,
group => $::redis::config_group,
mode => $var_run_redis_mode,
file { '/var/run/redis':
ensure => 'directory',
owner => $::redis::config_owner,
group => $::redis::config_group,
mode => $var_run_redis_mode,
}
}

}
Expand Down
53 changes: 53 additions & 0 deletions spec/acceptance/redis_debian_run_dir_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require 'spec_helper_acceptance'

describe 'redis', :if => (fact('operatingsystem') == 'Debian') do
it 'should run with newer Debian package' do
pp = <<-EOS
include ::apt
class {'::apt::backports':}
->
file { '/usr/sbin/policy-rc.d':
ensure => present,
content => "/usr/bin/env sh\nexit 101",
mode => '0755',
}
->
package { 'redis-server':
ensure => 'latest',
install_options => {
'-t' => "${::lsbdistcodename}-backports",
},
}
->
class { 'redis':
manage_package => false,
}
EOS

apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_change => true)
end

describe package('redis-server') do
it { should be_installed }
end

describe service('redis-server') do
it { should be_running }
end

context 'redis should respond to ping command' do
describe command('redis-cli ping') do
its(:stdout) { should match /PONG/ }
end
end

context 'redis log should be clean' do
describe command('journalctl --no-pager') do
its(:stdout) { should_not match /Failed at step RUNTIME_DIRECTORY/ }
end
end

end

0 comments on commit 1827691

Please sign in to comment.