-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 El 2021-08-28 a las 20:59 +0300, Andrei Borzenkov escribió:
On Sat, Aug 28, 2021 at 4:52 PM Carlos E. R. <> wrote:
Hi,
In this leap 15.2 laptop postfix fails to start atuomatically during boot, because network, handled by network manager, has not started yet:
minas-tirith:~ # systemctl status postfix ● postfix.service - Postfix Mail Transport Agent Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2021-08-28 14:10:44 CEST; 1h 34min ago Process: 3066 ExecStopPost=/etc/postfix/system/cond_slp deregister (code=exited, status=0/SUCCESS) Process: 2719 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE) Process: 2699 ExecStartPre=/etc/postfix/system/update_postmaps (code=exited, status=0/SUCCESS) Process: 2695 ExecStartPre=/etc/postfix/system/update_chroot (code=exited, status=0/SUCCESS) Process: 2691 ExecStartPre=/etc/postfix/system/config_postfix (code=exited, status=0/SUCCESS) Process: 2668 ExecStartPre=/bin/echo Starting mail service (Postfix) (code=exited, status=0/SUCCESS) Tasks: 0 CGroup: /system.slice/postfix.service
Aug 28 14:10:42 minas-tirith postfix[2719]: fatal: parameter inet_interfaces: no local interface found for 192.168.1.9 Aug 28 14:10:43 minas-tirith systemd[1]: postfix.service: Control process exited, code=exited status=1 Aug 28 14:10:44 minas-tirith systemd[1]: Failed to start Postfix Mail Transport Agent. Aug 28 14:10:44 minas-tirith systemd[1]: postfix.service: Unit entered failed state. Aug 28 14:10:44 minas-tirith systemd[1]: postfix.service: Failed with result 'exit-code'. minas-tirith:~ #
And systemd does not try to start it again after network becomes available.
Systemd has nothing to do with the network nor is it aware of network state. Nor is it even possible to give a generic definition of "network becomes available" that is suitable for everyone.
I'm not sure of that. Look at the sequence in syslog: <3.6> 2021-09-06 13:25:25 minas-tirith systemd 1 - - Starting Network Manager Script Dispatcher Service... <3.6> 2021-09-06 13:25:25 minas-tirith systemd 1 - - Started DNS caching server.. <3.6> 2021-09-06 13:25:25 minas-tirith systemd 1 - - Reached target Host and Network Name Lookups. <3.6> 2021-09-06 13:25:25 minas-tirith systemd 1 - - Starting NTP Server Daemon... <3.6> 2021-09-06 13:25:25 minas-tirith dnsmasq 2266 - - started, version 2.78 cachesize 2000 <3.6> 2021-09-06 13:25:25 minas-tirith systemd 1 - - Starting Notify NFS peers of a restart... <3.6> 2021-09-06 13:25:25 minas-tirith systemd 1 - - Started Laptop Mode Tools. <3.5> 2021-09-06 13:25:25 minas-tirith sm-notify 2327 - - Version 2.1.1 starting <3.6> 2021-09-06 13:25:25 minas-tirith systemd 1 - - Started Notify NFS peers of a restart. <3.6> 2021-09-06 13:25:25 minas-tirith dbus-daemon 1544 - - [system] Successfully activated service 'org.freedesktop.nm_dispatcher' <3.6> 2021-09-06 13:25:25 minas-tirith systemd 1 - - Started Network Manager Script Dispatcher Service. <4.6> 2021-09-06 13:25:25 minas-tirith sshd 2280 - - Server listening on 0.0.0.0 port 22. <4.6> 2021-09-06 13:25:25 minas-tirith sshd 2280 - - Server listening on :: port 22. <3.6> 2021-09-06 13:25:25 minas-tirith systemd 1 - - Started OpenSSH Daemon. <1.6> 2021-09-06 13:25:26 minas-tirith sntp 2513 - - sntp 4.2.8p15@1.3728-o Tue Jun 15 12:00:00 UTC 2021 (1) ... <1.6> 2021-09-06 13:25:26 minas-tirith sntp 2571 - - sntp 4.2.8p15@1.3728-o Tue Jun 15 12:00:00 UTC 2021 (1) <1.3> 2021-09-06 13:25:26 minas-tirith sntp 2571 - - sendpkt: sendto(192.168.1.16:123) failed: Network is unreachable <3.6> 2021-09-06 13:25:26 minas-tirith start-ntpd 2325 - - Time could not be synchronized <3.5> 2021-09-06 13:25:26 minas-tirith ntpd 2602 - - ntpd 4.2.8p15@1.3728-o Tue Jun 15 12:00:00 UTC 2021 (1): Starting <3.5> 2021-09-06 13:25:26 minas-tirith ntpd 2602 - - Command line: /usr/sbin/ntpd -p /var/run/ntp/ntpd.pid -g -u ntp:ntp -i /var/lib/ntp -c /etc/ntp.conf <3.5> 2021-09-06 13:25:26 minas-tirith ntpd 2602 - - ---------------------------------------------------- <3.5> 2021-09-06 13:25:26 minas-tirith ntpd 2602 - - ntp-4 is maintained by Network Time Foundation, <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started NTP Server Daemon. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Reached target System Time Synchronized. <3.6> 2021-09-06 13:25:26 minas-tirith start-ntpd 2325 - - Starting network time protocol daemon (NTPD) <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started NTP Server Daemon. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Reached target System Time Synchronized. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started daily update of the root trust anchor for DNSSEC. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Discard unused blocks once a week. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Starting Postfix Mail Transport Agent... <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Check if mainboard battery is Ok. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Deferred execution scheduler. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Backup of /etc/sysconfig. <3.6> 2021-09-06 13:25:26 minas-tirith echo 2653 - - Starting mail service (Postfix) <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Daily maintenance of news spool. Huh. This one is an expensive job on a timer that should run at 4AM but did not, so it runs at next boot... cron.daily did not do this, it waited 15 minutes after boot. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Balance block groups on a btrfs filesystem. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Daily rotation of log files. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Backup of RPM database. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Daily locate database update. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Timeline of Snapper Snapshots. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Scrub btrfs filesystem, verify block checksums. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Discard unused blocks on a mounted filesystem. <3.6> 2021-09-06 13:25:26 minas-tirith systemd 1 - - Started Do daily mandb update. <0.6> 2021-09-06 13:25:27 minas-tirith kernel - - - [ 21.843767] wlan0: authenticate with 64:68:0c:74:e7:07 <0.6> 2021-09-06 13:25:27 minas-tirith kernel - - - [ 21.871088] wlan0: send auth to 64:68:0c:74:e7:07 (try 1/3) <0.6> 2021-09-06 13:25:27 minas-tirith kernel - - - [ 21.875024] wlan0: authenticated ... <3.3> 2021-09-06 13:25:27 minas-tirith systemd 1 - - Failed to start Postfix Mail Transport Agent. <3.5> 2021-09-06 13:25:27 minas-tirith systemd 1 - - postfix.service: Unit entered failed state. <3.4> 2021-09-06 13:25:27 minas-tirith systemd 1 - - postfix.service: Failed with result 'exit-code'. <3.6> 2021-09-06 13:25:27 minas-tirith systemd 1 - - Started Command Scheduler. <9.6> 2021-09-06 13:25:27 minas-tirith cron 3048 - - (CRON) INFO (RANDOM_DELAY will be scaled with factor 57% if used.) <9.6> 2021-09-06 13:25:27 minas-tirith cron 3048 - - (CRON) INFO (running with inotify support) <4.6> 2021-09-06 13:25:28 minas-tirith SuSEfirewall2 2166 - - Firewall rules successfully set <3.6> 2021-09-06 13:25:28 minas-tirith systemd 1 - - Started SuSEfirewall2 phase 2. <3.6> 2021-09-06 13:25:28 minas-tirith avahi-daemon 1537 - - Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.1.9. <3.6> 2021-09-06 13:25:28 minas-tirith avahi-daemon 1537 - - New relevant interface wlan0.IPv4 for mDNS. <3.6> 2021-09-06 13:25:28 minas-tirith avahi-daemon 1537 - - Registering new address record for 192.168.1.9 on wlan0.IPv4. <3.6> 2021-09-06 13:25:28 minas-tirith systemd-hostnamed 2194 - - Changed host name to 'minas-tirith.valinor' <3.6> 2021-09-06 13:25:31 minas-tirith systemd 1 - - Started Network Manager Wait Online. <3.6> 2021-09-06 13:25:31 minas-tirith systemd 1 - - Reached target Network is Online. <========= At that point, systemd knows that network is available. Or it should.
Could something be changed in the service file to correct the situation?
minas-tirith:~ # systemctl cat postfix # /usr/lib/systemd/system/postfix.service # This file is part of package postfix. # # Copyright (c) 2021 SuSE LINUX Products GmbH, Germany. # Authors: Werner Fink, Peter Varkoly # Please send feedback to https://bugs.opensuse.org/ # # Description: # # Used to start the postfix Mail Transport Agent service # which handles all mails stored at /var/spool/postfix/ and # all connections on port 25 aka smtp at localhost as well # as on all other network interfaces. #
[Unit] Description=Postfix Mail Transport Agent After=nss-lookup.target network.target time-sync.target
If you are using NetworkManager, network.target just means that NetworkManager process has been started. It can take an arbitrarily long time to complete interface configuration. Basically you have two choices
Those services are started way before target "Network is online" is reached. Maybe that condition could be added somehow.
1. If you always use NetworkManager you could use a dispatcher script to start postfix when "network becomes available". It is up to you to define conditions when it happens.
It is not only postfix, it is several services... only postfix is the one that fails and complains loudly.
2. You could add After=network-online.target to your unit and enable NetworkManager-wait-online.service. This waits until nm-online reports "online" up to timeout (I think 30 seconds by default). It may be too strong (error message just complaints about missing local interface with fixed address, not about not being "online").
This one, yes. That's the one I need, and not only on postfix.
After=amavis.service mysql.service cyrus.service ldap.service openslp.service ypbind.service
I can't find what is the name of the "target Network is Online". It is not here: minas-tirith:~ # rpm -ql NetworkManager | grep target minas-tirith:~ # Use the nuc. minas-tirith:~ # locate /usr/lib/systemd/ | grep \.target | grep -i online /other/usr/lib/systemd/system/network-online.target /usr/lib/systemd/system/network-online.target minas-tirith:~ # Ok, found. minas-tirith:~ # systemctl cat network-online.target # /usr/lib/systemd/system/network-online.target # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=Network is Online Documentation=man:systemd.special(7) Documentation=https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget After=network.target minas-tirith:~ # Could I just add to the postfix service file After=network.target ? Well, I just did, but will not know the result till another reboot. And will only effect postfix, not the other services. Edit them one by one, or is there another method more global? Huh, something else I noticed, dunno is related: minas-tirith:~ # l /etc/systemd/system/multi-user.target.wants/network.service lrwxrwxrwx 1 root root 39 Jan 6 2014 /etc/systemd/system/multi-user.target.wants/network.service -> /usr/lib/systemd/system/network.service minas-tirith:~ # The link is broken. minas-tirith:/etc/systemd/system/multi-user.target.wants # l /usr/lib/systemd/system/network.service ls: cannot access '/usr/lib/systemd/system/network.service': No such file or directory minas-tirith:/etc/systemd/system/multi-user.target.wants # locate network.service /etc/systemd/system/network.service /etc/systemd/system/graphical.target.wants/network.service /etc/systemd/system/multi-user.target.wants/network.service /other/etc/systemd/system/network.service minas-tirith:/etc/systemd/system/multi-user.target.wants # minas-tirith:~ # l /etc/systemd/system/network.service lrwxrwxrwx 1 root root 46 Jan 6 2014 /etc/systemd/system/network.service -> /usr/lib/systemd/system/NetworkManager.service minas-tirith:~ # l /usr/lib/systemd/system/NetworkManager.service - -rw-r--r-- 1 root root 1175 Apr 23 14:20 /usr/lib/systemd/system/NetworkManager.service minas-tirith:~ # - -- Cheers Carlos E. R. (from openSUSE Leap 15.2 x86_64 (Minas Tirith)) -----BEGIN PGP SIGNATURE----- iJIEAREIADoWIQQt/vKEw5659AgM/X2NrxRtxRYzXAUCYTazrhwccm9iaW4ubGlz dGFzQHRlbGVmb25pY2EubmV0AAoJEI2vFG3FFjNcOmEBAJqZ2eHMlREvjCVn70WJ UjWYAlf/D2ItKyvCOEq8LngaAP4hITM2MnRpiLV6gcQOj7v5OETpY14VPmjfn2kK 6XbqUA== =H7hz -----END PGP SIGNATURE-----