Salt does not rotate logfiles with included logrotate config
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue
Salt (Master and Minions) do not rotate logs correctly.
Setup
Using Salt from the company repository. With the logrotate files provided by same. You literally have to do nothing to make this happen.
Steps to Reproduce Issue
Let the master or minions run longer than the time their logs rotate (Weekly in the standard configuration). Logs will rotate but salt-minion and salt-master are still logging to the (now deleted) log file that was just rotated. Only restarting the master or minion causes it to re-open its log file correctly. 'lsof' shows the master or minion still writing logs to the deleted log file.
Versions Report
Salt Version:
Salt: 2019.2.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: 0.6.4
gitpython: 1.0.1
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.31.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: 1.2.5
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.5 (default, Aug 7 2019, 00:51:29)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: centos 7.7.1908 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-1062.7.1.el7.x86_64
system: Linux
version: CentOS Linux 7.7.1908 Core
If Salt does not auto-reopen its logs, then adding code to catch sighup and re-open its normal log files would fix this with the addition of the proper post-rotate section being added to the logrotate config file.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Salt master and minion logging entry points and the included logrotate configuration described in the issue. Reproduce weekly rotation and inspect the open file with lsof. Done means rotated logs are reopened without restarting the master or minion, with the SIGHUP and post-rotate behavior working as described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, python
- Domain
- devops, infrastructure, observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100