Comment 15 for bug 1600164

Revision history for this message
EOLE team (eole-team) wrote :

I just made the test to be sure: using Wants= does not prevent MySQL to start event if the system never reaches “time-sync.target”.

I added an ntpdate.service:

  # /etc/systemd/system/ntpdate.service
  [Unit]
  Description=Force synchronisation of time
  ConditionPathExists=/etc/default/ntpdate
  DefaultDependencies=no
  Conflicts=shutdown.target
  After=network-online.target
  Before=time-sync.target shutdown.target
  Wants=network-online.target time-sync.target

  [Service]
  Type=oneshot
  Environment="NTPSERVERS=pool.ntp.org"
  EnvironmentFile=/etc/default/ntpdate
  ExecStart=/usr/sbin/ntpdate -v $NTPSERVERS
  RemainAfterExit=yes

  [Install]
  WantedBy=sysinit.target

And an override for MySQL:

  # /etc/systemd/system/mysql.service.d/override.conf
  [Unit]
  After=network-online.target time-sync.target
  Wants=network-online.target time-sync.target

ntpdate.service is failed:

  systemctl status ntpdate.service
  ● ntpdate.service - Force synchronisation of time
     Loaded: loaded (/etc/systemd/system/ntpdate.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2018-10-15 16:51:25 CEST; 40s ago
    Process: 1129 ExecStart=/usr/sbin/ntpdate -v $NTPSERVERS (code=exited, status=1/FAILURE)
   Main PID: 1129 (code=exited, status=1/FAILURE)

But MySQL is started:

  systemctl status mysql.service
  ● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/mysql.service.d
             └─override.conf
     Active: active (running) since Mon 2018-10-15 16:51:27 CEST; 3min 17s ago
    Process: 1600 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
    Process: 1550 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 1602 (mysqld)
      Tasks: 30 (limit: 4915)
     CGroup: /system.slice/mysql.service
             └─1602 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

Regards.