[MDEV-22212] Validate systemd service file is correct with 'systemd-analyze verify' Created: 2020-04-10  Updated: 2023-09-19

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.4
Fix Version/s: 10.6

Type: Bug Priority: Minor
Reporter: Otto Kekäläinen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Ensure our systemd service files pass validation with https://www.freedesktop.org/software/systemd/man/systemd-analyze.html

systemd-analyze verify FILE...
This command will load unit files and print warnings if any errors are detected. Files specified on the command line will be loaded, but also any other units referenced by them. The full unit search path is formed by combining the directories for all command line arguments, and the usual unit load paths (variable $SYSTEMD_UNIT_PATH is supported, and may be used to replace or augment the compiled in set of unit load paths; see systemd.unit(5)). All units files present in the directories containing the command line arguments will be used in preference to the other paths.
The following errors are currently detected:

  • unknown sections and directives,
  • missing dependencies which are required to start the given unit,
  • man pages listed in Documentation= which are not found in the system,
  • commands listed in ExecStart= and similar which are not found in the system or not executable.

I already tested but failed to get it even running:

system 1, virtual machine:

systemd-analyze verify mariadb.service
Attempted to remove disk file system, and we can't allow that.

system 2, docker container:

systemd-analyze verify mariadb.service
Couldn't move remaining userspace processes, ignoring: Input/output error



 Comments   
Comment by Otto Kekäläinen [ 2021-04-04 ]

Maybe faust or danblack would like to take over this issue too?

Comment by Faustin Lammler [ 2021-04-30 ]

Hi otto!
It seems like a good idea.

Here is a snippet for docker:

docker run -it debian:sid bash -c "apt-get update &&\
  apt-get install -y software-properties-common dirmngr apt-transport-https &&\
  apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc' &&\
  add-apt-repository 'deb [arch=amd64,i386] https://ftp.igh.cnrs.fr/pub/mariadb/repo/10.6/debian sid main' &&\
  apt-get update && apt-get -y install mariadb-server systemd man &&\
  systemd-analyze verify mariadb.service &&\
  echo \"Generating an error because systemd-analyze does not come with a verbose option\" &&\
  sed -i 's/WantedBy/WntedBy/g' /lib/systemd/system/mariadb.service &&\
  systemd-analyze verify mariadb.service"

The only tricky part is that you need the man page as it is referenced in the systemd unit.
I am generating an error to show that the unit file is effectively parsed by systemd-analyze.

Warning, from `man systemd-analyze` :

Files specified on the command line will be loaded, but also any other units referenced by them.

You may have hit another unit file in your tests?

Comment by Daniel Black [ 2022-07-05 ]

https://github.com/MariaDB/buildbot/pull/24

Comment by Faustin Lammler [ 2022-07-06 ]

danblack can you double check now that the check is activated on Buildbot?
I have made a change to run it with sudo (ubuntu18.04 was complaining), but now I am not sure about this change.
See my comments in https://github.com/MariaDB/buildbot/pull/24

Comment by Faustin Lammler [ 2022-07-06 ]

I have just reverted the change since it probably needs a bit more testing.

Generated at Thu Feb 08 09:13:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.