influxdata / influxdata/influxdb
Startup script failing with SELinux enabled
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
### Environment
Problem occurred on Oracle Linux 8.x., with SELinux in enforcing mode. It probably affects all RHEL variants, didn't test on members of the Debian family.
### Problem
Systemd startup fails as follows:
systemd[1]: influxdb.service: Can't open PID file /var/lib/influxdb/influxd.pid (yet?) after start: Permission denied
No special SELinux rules are provided, and `/var/lib` is not where a PID file *should* be placed. That's why there is no matching default rule.
### Proposed Solution
The easiest way to fix this should be switching to a default PID file location. For an installation with the given packages, after `dnf/yum install` I did the following to get it up and running:
```
install -d -o influxdb -g influxdb -m 0750 /run/influxdb
echo 'd /run/influxdb 0750 influxdb influxdb -' > /usr/lib/tmpfiles.d/influxdb.conf
sed -ri 's#/var/lib/influxdb/influxd.pid#/run/influxdb/influxd.pid#g' /usr/lib/influxdb/scripts/influxd-systemd-start.sh
sed -ri 's#/var/lib/influxdb/influxd.pid#/run/influxdb/influxd.pid#g' /usr/lib/systemd/system/influxdb.service
systemctl daemon-reload
systemctl start influxdb
```
Please note that `/run` is a temporary file system, that's why I'm telling `systemd-tmpfiles` to deal with that directory.
Contributor guide
Research direction
Start by inspecting /usr/lib/influxdb/scripts/influxd-systemd-start.sh and /usr/lib/systemd/system/influxdb.service, then reproduce the package startup failure with SELinux enforcing. Check how the PID path and runtime directory are defined and verify the service starts successfully after the packaging changes, including across reboot or runtime-directory recreation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, shell
- Domain
- devops, infrastructure, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100