Bug 222197

Summary: sysutils/py-google-compute-engine: Starts google_clock_skew_daemon too early
Product: Ports & Packages Reporter: Vick Khera <vivek>
Component: Individual Port(s)Assignee: Richard Gallamore <ultima>
Status: Closed FIXED    
Severity: Affects Some People CC: helen.koike, ultima
Priority: --- Keywords: needs-qa, patch
Version: LatestFlags: helen.koike: maintainer-feedback+
helen.koike: merge-quarterly?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Path which adds ntpd as a requirement in clock skew rc script
helen.koike: maintainer-approval+
Set stop action to null in the "setup" scripts
helen.koike: maintainer-approval+
Patch which adds ntpd as requirement for clock skew and set stop action to null in the "setup" scripts helen.koike: maintainer-approval+

Description Vick Khera 2017-09-10 13:58:41 UTC
The clock skew daemon interferes with ntpd upon startup.

On boot, the following is observed:

Starting sshd.
Performing sanity check on sshd configuration.
Starting google_network_setup.
Starting google_ip_forwarding_daemon.
Starting google_clock_skew_daemon.
Starting google_accounts_daemon.
ntpd is not running.
No core dumps found.
Clearing /tmp (X related).
Updating motd:.
Mounting late filesystems:.
Starting ntpd.
Sep  8 20:17:20 yertle ntpd[697]: unable to bind to wildcard address :: - another process may be running - EXITING

What happens is that the clock skew daemon starts and does not see ntpd running. It then proceeds to set the time using ntpdate. By luck of timing, it does so at the precise moment that ntpd wants to start, causing that to fail. Subsequently, since ntpd was not discovered by the daemon it is not restarted, and the system time drifts without ntpd to keep it in check.

Once the system is running, if you stop the clock skew daemon, start ntpd, then re-start the clock skew daemon, you will observe it stop and restart ntpd. If you stop ntpd, and restart the clock skew daemon, you will observe the "ntpd is not running." message, and ntpd is not started.

It seems to me that ntpd should come before the clock skew daemon in the startup order. The documentation implies that the daemon only does work on startup or migrate, so it is necessary for migration and ntpd is necessary for the rest of the time.
Comment 1 Vick Khera 2017-09-24 14:02:25 UTC
Also as an aside, the "setup" rc.d scripts only run actions at boot and do not leave daemons running, so their "stop" actions should be null, instead of complaining:

# /usr/local/etc/rc.d/google_network_setup stop
google_network_setup not running? (check /var/run/google_network_setup.pid).
# /usr/local/etc/rc.d/google_instance_setup stop
google_instance_setup not running? (check /var/run/google_instance_setup.pid).
Comment 2 Helen Koike 2017-09-25 18:39:37 UTC
Created attachment 186713 [details]
Path which adds ntpd as a requirement in clock skew rc script

(In reply to Vick Khera from comment #0)
Thanks for your report.
I attached a patch that should solve the issue (could you confirm please?)
Comment 3 Helen Koike 2017-09-25 18:41:49 UTC
Created attachment 186714 [details]
Set stop action to null in the "setup" scripts

(In reply to Vick Khera from comment #1)
Thanks for your report.
Please see attached patch that fixes this
Comment 4 Helen Koike 2017-09-25 19:53:43 UTC
Created attachment 186715 [details]
Patch which adds ntpd as requirement for clock skew and set stop action to null in the "setup" scripts

Re-adding the patch against the svn tree and merging both patch in a single diff to make it easier to merge
Comment 5 Vick Khera 2017-10-09 20:44:36 UTC
Thanks. The ntpd is restarted upon boot now. Sorry for the delay, but I don't reboot this system very often.

Any idea on when this will get committed to ports tree?
Comment 6 Helen Koike 2017-10-09 21:18:08 UTC
(In reply to Vick Khera from comment #5)
 Thank you for reporting this bug and testing the patch

 I set the merge-quarterly flag, I guess we need to wait for a committer to apply this patch or ping some commiter/mailinglist
Comment 7 commit-hook freebsd_committer freebsd_triage 2017-10-15 22:11:37 UTC
A commit references this bug:

Author: ultima
Date: Sun Oct 15 22:11:31 UTC 2017
New revision: 452169
URL: https://svnweb.freebsd.org/changeset/ports/452169

Log:
  Fixed ntpd starting too early causing other services to fail at start.
  Fixed error when stopping services.

  PR:		222197
  Submitted by:	Helen Koike (maintainer)
  Reported by:	Vick Khera
  MFH:		2017Q4

Changes:
  head/sysutils/py-google-compute-engine/Makefile
  head/sysutils/py-google-compute-engine/files/google_clock_skew_daemon.in
  head/sysutils/py-google-compute-engine/files/google_instance_setup.in
  head/sysutils/py-google-compute-engine/files/google_network_setup.in
Comment 8 Richard Gallamore freebsd_committer freebsd_triage 2017-10-15 22:12:54 UTC
Bumped port revision and committed, thanks!

Waiting for MFC approval.
Comment 9 commit-hook freebsd_committer freebsd_triage 2017-10-24 17:17:08 UTC
A commit references this bug:

Author: ultima
Date: Tue Oct 24 17:16:22 UTC 2017
New revision: 452788
URL: https://svnweb.freebsd.org/changeset/ports/452788

Log:
  MFH: r452169

  Fixed ntpd starting too early causing other services to fail at start.
  Fixed error when stopping services.

  PR:		222197
  Submitted by:	Helen Koike (maintainer)
  Reported by:	Vick Khera

  Approved by:	portmgr (swills)

Changes:
_U  branches/2017Q4/
  branches/2017Q4/sysutils/py-google-compute-engine/Makefile
  branches/2017Q4/sysutils/py-google-compute-engine/files/google_clock_skew_daemon.in
  branches/2017Q4/sysutils/py-google-compute-engine/files/google_instance_setup.in
  branches/2017Q4/sysutils/py-google-compute-engine/files/google_network_setup.in