Skip to contentSkip to conversation

mdadm: fix systemd service start up failure

PATCH Superseded [email protected] 2 participants 4 messages Jun 20, 2019 – Jun 24, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mdadm: fix systemd service start up failure

From: Changqing Li <[email protected]>

1. mdadm: No mail address or alert command - not monitoring

with --monitor mode, mdadm needs a mail address and/or a program. This can be given with "mailaddr" and "program" lines to that monitoring can be started using.

fix by given a mail address, user can replace with a valid one when use.

2. cannot create pid file: No such file or directory

fix by create dir before starting.

---
 meta/recipes-extended/mdadm/files/mdmonitor.service | 1 +
 meta/recipes-extended/mdadm/mdadm_4.1.bb            | 1 +
 2 files changed, 2 insertions(+)
meta/recipes-extended/mdadm/files/mdmonitor.service +1 -0
index bd243b4..a1b693f 100644
@@ -13,6 +13,7 @@ ConditionPathExists=/etc/mdadm.conf
 Type=forking
 PIDFile=/var/run/mdadm/mdadm.pid
 EnvironmentFile=-/etc/sysconfig/mdmonitor
+ExecStartPre=mkdir -p /var/run/mdadm
 ExecStart=/sbin/mdadm --monitor --scan -f --pid-file=/var/run/mdadm/mdadm.pid
 
 [Install]
meta/recipes-extended/mdadm/mdadm_4.1.bb +1 -0
index 494b81b..aa1fdb3 100644
@@ -57,6 +57,7 @@ do_install() {
 do_install_append() {
         install -d ${D}/${sysconfdir}/
         install -m 644 ${S}/mdadm.conf-example ${D}${sysconfdir}/mdadm.conf
+        sed -i -e 's/#MAILADDR [email protected]/MAILADDR [email protected]/g' ${D}${sysconfdir}/mdadm.conf
         install -d ${D}/${sysconfdir}/init.d
         install -m 755 ${WORKDIR}/mdadm.init ${D}${sysconfdir}/init.d/mdmonitor
 }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 8 lines · On Thu, Jun 20, 2019 at 11:14:03AM +0800, [email protected] wrote:

From: Changqing Li <[email protected]>

1. mdadm: No mail address or alert command - not monitoring

with --monitor mode, mdadm needs a mail address and/or a program. This can be given with "mailaddr" and "program" lines to that monitoring can be started using.

Quoted 5 lines

fix by given a mail address, user can replace with a valid one when use.
...
+ sed -i -e 's/#MAILADDR [email protected]/MAILADDR [email protected]/g' ${D}${sysconfdir}/mdadm.conf
...

Defaulting to try to send emails to an invalid address is worse than not having an email address configured.

Looking at the manpages I would have expected syslog-only monitoring to work if neither mailaddr nor program are configured.
If this isn't working, is this something upstream considers a bug?

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#2 lore raw
Quoted 14 lines · Adrian Bunk
Quoted 8 lines · On Thu, Jun 20, 2019 at 11:14:03AM +0800, [email protected] wrote:

From: Changqing Li <[email protected]>

1. mdadm: No mail address or alert command - not monitoring

with --monitor mode, mdadm needs a mail address and/or a program. This can be given with "mailaddr" and "program" lines to that monitoring can be started using.

Quoted 5 lines

fix by given a mail address, user can replace with a valid one when use.
...
+ sed -i -e 's/#MAILADDR [email protected]/MAILADDR [email protected]/g' ${D}${sysconfdir}/mdadm.conf
...

Quoted 6 lines

Defaulting to try to send emails to an invalid address is worse than not having an email address configured.

Looking at the manpages I would have expected syslog-only monitoring to work if neither mailaddr nor program are configured.
If this isn't working, is this something upstream considers a bug?

Thanks, I will check this, and try find another solution.

Quoted 4 lines

cu
Adrian

Signature · 3 lines
BRs

Sandy(Li Changqing)
#3 lore raw

PATCH v2 1/1 mdadm: fix systemd service start up failure

In reply to Adrian Bunk

From: Changqing Li <[email protected]>

1. mdadm: No mail address or alert command - not monitoring

fixed by use option -y to cause all events to be reported through 'syslog'.

2. cannot create pid file: No such file or directory

fix by create dir before starting.

---
 meta/recipes-extended/mdadm/files/mdmonitor.service | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/recipes-extended/mdadm/files/mdmonitor.service +2 -1
index bd243b4..a81578e 100644
@@ -13,7 +13,8 @@ ConditionPathExists=/etc/mdadm.conf
 Type=forking
 PIDFile=/var/run/mdadm/mdadm.pid
 EnvironmentFile=-/etc/sysconfig/mdmonitor
-ExecStart=/sbin/mdadm --monitor --scan -f --pid-file=/var/run/mdadm/mdadm.pid
+ExecStartPre=mkdir -p /var/run/mdadm
+ExecStart=/sbin/mdadm --monitor -y --scan -f --pid-file=/var/run/mdadm/mdadm.pid
 
 [Install]
 WantedBy=multi-user.target
Signature · 1 line
2.7.4