voxpupuli / puppet-redis

Puppet Module to manage Redis
https://forge.puppet.com/puppet/redis
Apache License 2.0
40 stars 183 forks source link

Systemd service stop issues with redis instances #428

Open jnguiot opened 2 years ago

jnguiot commented 2 years ago

Affected Puppet, Ruby, OS and module versions/distributions

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

redis::instance{"prodXXX-redis":
                    service_name    => "redis@prodXXX",
                    bind            => "172.3.0.1",
                    port            => 9999,
                    requirepass     => "foobar123",
}

What are you seeing

The service doesn't stop properly:

root@xxxx:~# service redis@prodXXX status
● redis@prodXXX.service - Redis Advanced key-value store for instance prodXXX-redis
   Loaded: loaded (/etc/systemd/system/redis@prodXXX.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2021-12-02 10:18:15 CET; 16min ago
  Process: 51032 ExecStop=/usr/bin/redis-cli -p 9999 shutdown (code=exited, status=1/FAILURE)
 Main PID: 60128 (redis-server)
   Status: "MASTER <-> REPLICA sync: Finished with success. Ready to accept connections in read-write mode."
   CGroup: /system.slice/system-redis.slice/redis@prodXXX.service
           └─60128 /usr/bin/redis-server 172.3.0.1:9999

Dec 02 10:18:15 xxxx systemd[1]: Starting Redis Advanced key-value store for instance prodXXX-redis...
Dec 02 10:18:15 xxxx systemd[1]: Started Redis Advanced key-value store for instance prodXXX-redis.

The ExecStop did not not stop the service and returns a failure.

What behaviour did you expect instead

The ExecStop should stop the service without error

Output log

Any additional information you'd like to impart

The redis-cli in the ExecStop does not connect to the right binding address. Thus, it fails. However, since redis is password protected (requirepass) , it will also fails. And I am not sure we should insert the password into the service file. My recommendation would be to be closer to the original redis-server systemd file and use ExecStop=/bin/kill -s TERM $MAINPID in https://github.com/voxpupuli/puppet-redis/blob/4a8d7811da5fd610b60c4b67f195f759e59f851c/templates/service_templates/redis.service.epp#L22

ekohl commented 2 years ago

I wonder if this is a duplicate of https://github.com/voxpupuli/puppet-redis/issues/386.

root-expert commented 2 years ago

I think this is fixed by https://github.com/voxpupuli/puppet-redis/commit/b7f7478c4db6f57b2b724e97ae4ad86be8c68338 Can you confirm?