Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 628968

Summary: sys-fs/mdadm-4.0 with systemd: service mdmonitor.service fails in default configuration
Product: Gentoo Linux Reporter: Martin Dummer <martin.dummer>
Component: Current packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: UNCONFIRMED ---    
Severity: normal CC: alexanderyt, gentoo, martin.dummer, mva, systemd
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Martin Dummer 2017-08-26 11:07:31 UTC
When sys-fs/mdadm is emerged on systemd systems, it adds a service "mdmonitor.service" which is the equivalent to the OpenRC service "mdadm".

But "mdmonitor.service" fails to start with the error message
  mdadm: No mail address or alert command - not monitoring.

Here is an excerpt from the service file:
###########################
[Service]
Environment=  MDADM_MONITOR_ARGS=--scan
EnvironmentFile=-/run/sysconfig/mdadm
ExecStartPre=-/usr/lib/systemd/scripts/mdadm_env.sh
ExecStart=/sbin/mdadm --monitor $MDADM_MONITOR_ARGS
###########################

Reasons:
 - not enough arguments for "mdadm --monitor"
 - script "/usr/lib/systemd/scripts/mdadm_env.sh" does not exist.
 - I assume "mdadm_env.sh" should extract variables from "/etc/conf.d/mdadm" to file "/run/sysconfig/mdadm"
 - the consequence is: file "/run/sysconfig/mdadm" does not exist, too
 - these two non-existent files are non-fatal for the service because the "-" prefix
 - now the line "Environment=.." comes into play
 - therefore 
     ExecStart=/sbin/mdadm --monitor $MDADM_MONITOR_ARGS
   expands to
     /sbin/mdadm --monitor --scan
   which terminates with the message
     "mdadm: No mail address or alert command - not monitoring."


Solution:
Add "--syslog" to arguments to make "mdadm --monitor" happy. And IMHO what the user expects.

How?
My choice would be to add "/usr/lib/systemd/scripts/mdadm_env.sh" to extract variables from "/etc/conf.d/mdadm" to file "/run/sysconfig/mdadm". Also: IMHO what the user (here: me) expects. Like on OpenRC systems.


Reproducible: Always
Comment 1 Vadim A. Misbakh-Soloviov (mva) gentoo-dev 2017-11-08 08:23:23 UTC
1) nope
mail address should be manually set in /etc/mdadm.conf (see on few last lines, before the ones of your arrays, that you've added on their initialisation).

Also, as you can see, there is "-" sign before both `/run/sysconfig/mdadm` and `/usr/lib/systemd/scripts/mdadm_env.sh`. This means "it is ok to fail".

And it fails exactly because you didn't set the email in mdadm.conf

2) although, I came here to report this exactly bug, but with another argumentation:

a) `/run/sysconfig` looks like definitelly non-gentoo path. And looks like that systemd unit was copy-pasted from archlinux or so.

b) well, it would be nice to either drop /usr/lib/systemd/scripts/mdadm_env.sh from the unit and make conf.d/mdadm the EnvironmentFile, or create that file during package installation and make it to do something useful.
Comment 2 r7l 2020-05-17 19:13:31 UTC
Sadly this seems to be stuck here for years. I've just tried to enable the service file and got the following error:

The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

The other reported issues with /usr/lib/systemd/scripts/mdadm_env.sh are still in there as well.
Comment 3 Vadim A. Misbakh-Soloviov (mva) gentoo-dev 2020-12-11 07:32:25 UTC
(In reply to r7l from comment #2)
> Sadly this seems to be stuck here for years. I've just tried to enable the
> service file and got the following error:
> 
> The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
> Alias= settings in the [Install] section, and DefaultInstance= for template
> units). This means they are not meant to be enabled using systemctl.
> 
> The other reported issues with /usr/lib/systemd/scripts/mdadm_env.sh are
> still in there as well.

I guess, "the right way" would be to use per-device `mdmon@` service :)