Merge ~hloeung/ntp-charm:master into ntp-charm:master

Proposed by Haw Loeung on 2020-01-07
Status: Merged
Approved by: Haw Loeung on 2020-01-07
Approved revision: 1fa23565027eac5297532ea9ffd7f9fc438d5da8
Merged at revision: d6a14230812f6388fedf549f7e4a68a7837abd19
Proposed branch: ~hloeung/ntp-charm:master
Merge into: ntp-charm:master
Diff against target: 32 lines (+21/-0)
1 file modified
reactive/ntp.py (+21/-0)
Reviewer Review Type Date Requested Status
Joel Sing +1 2020-01-07 Approve on 2020-01-07
Canonical IS Reviewers 2020-01-07 Pending
Review via email: mp+377213@code.launchpad.net

Commit message

Work around LP:1823098 and LP:1758775

Prefer the configured NTP servers via the charm over what's provided over DHCP.

To post a comment you must log in.

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Haw Loeung (hloeung) wrote :

Output of Juju unit logs with these charm changes:

2020-01-07 03:36:13 DEBUG juju-log tracer>
tracer: hooks phase, 2 handlers queued
tracer: ++ queue handler reactive/ntp.py:291:prefer_non_dhcp_ntp_servers
tracer: ++ queue handler reactive/ntp.py:311:assess_status
2020-01-07 03:36:13 INFO juju-log Invoking reactive handler: reactive/ntp.py:291:prefer_non_dhcp_ntp_servers
2020-01-07 03:36:13 DEBUG juju-log tracer: cleared flag ntp.configured
2020-01-07 03:36:13 INFO juju-log Invoking reactive handler: reactive/ntp.py:311:assess_status
2020-01-07 03:36:13 DEBUG update-status active

2020-01-07 03:36:15 DEBUG juju-log tracer>
tracer: set flag ntp.configured
tracer: -- dequeue handler ../.venv/lib/python3.5/site-packages/charmhelpers/core/host.py:715:wrapped_f
2020-01-07 03:36:15 DEBUG update-status active
2020-01-07 03:36:15 INFO juju-log Invoking reactive handler: hooks/relations/juju-info/requires.py:19:changed:juju-info
2020-01-07 03:36:16 INFO juju-log Invoking reactive handler: reactive/ntp.py:169:config_changed

Joel Sing (jsing) wrote :

LGTM (although it's a pretty ugly "fix" for an ugly problem :)

review: Approve (+1)

Change successfully merged at revision d6a14230812f6388fedf549f7e4a68a7837abd19

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/reactive/ntp.py b/reactive/ntp.py
2index 6b8f082..7b39470 100755
3--- a/reactive/ntp.py
4+++ b/reactive/ntp.py
5@@ -289,6 +289,27 @@ def get_nagios_result(cmd):
6
7
8 @hook('update-status')
9+def prefer_non_dhcp_ntp_servers():
10+ ntp_dhcp_conf = '/var/lib/ntp/ntp.conf.dhcp'
11+ if not os.path.exists(ntp_dhcp_conf):
12+ return
13+
14+ # Work around LP#1823098 and LP#1758775 to prefer the configured NTP servers
15+ # over what gets given by DHCP. The ntpd start up script checks the
16+ # timestamp of ntp_dhcp_conf to see if it's newer than ntp.conf so let's
17+ # just remove it.
18+ os.unlink(ntp_dhcp_conf)
19+
20+ # We also want to make sure ntp_dhcp_conf isn't written out in the future.
21+ if os.path.exists('/etc/dhcp/dhclient-exit-hooks.d/ntp'):
22+ os.unlink('/etc/dhcp/dhclient-exit-hooks.d/ntp')
23+
24+ # Remove ntp.configured flag so we ship out updated ntp.conf and restart
25+ # ntpd.
26+ remove_state('ntp.configured')
27+
28+
29+@hook('update-status')
30 def assess_status():
31 package = implementation.package_name()
32 version = fetch.get_upstream_version(package)

Subscribers

People subscribed via source and target branches