Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 628968 - sys-fs/mdadm-4.0 with systemd: service mdmonitor.service fails in default configuration
Summary: sys-fs/mdadm-4.0 with systemd: service mdmonitor.service fails in default con...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-26 11:07 UTC by Martin Dummer
Modified: 2024-02-19 21:00 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 :)
Comment 4 Larry the Git Cow gentoo-dev 2024-02-19 21:00:58 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b0152d3ed507c45608377046bc2f65a48b47ec10

commit b0152d3ed507c45608377046bc2f65a48b47ec10
Author:     Robin H. Johnson <robbat2@gentoo.org>
AuthorDate: 2024-02-19 20:32:53 +0000
Commit:     Robin H. Johnson <robbat2@gentoo.org>
CommitDate: 2024-02-19 21:00:55 +0000

    sys-fs/mdadm: improve mdmonitor on systemd
    
    Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
    Closes: https://bugs.gentoo.org/628968

 sys-fs/mdadm/files/mdadm-4.2-mdadm_env.patch |  36 ++++++++++
 sys-fs/mdadm/mdadm-4.2-r3.ebuild             | 104 +++++++++++++++++++++++++++
 2 files changed, 140 insertions(+)