Merge ~paelzer/ubuntu/+source/chrony:bionic-lp1764357 into ubuntu/+source/chrony:ubuntu/devel

Proposed by Christian Ehrhardt 
Status: Merged
Merge reported by: Christian Ehrhardt 
Merged at revision: a43489f69cca92440ec4b93c609951409c73fd27
Proposed branch: ~paelzer/ubuntu/+source/chrony:bionic-lp1764357
Merge into: ubuntu/+source/chrony:ubuntu/devel
Diff against target: 199 lines (+136/-1)
7 files modified
debian/changelog (+13/-0)
debian/control (+1/-0)
debian/links (+5/-0)
debian/patches/lp-1718227-ignore-non-up-down-events-in-nm-dispatcher.patch (+32/-0)
debian/patches/lp-1718227-nm-dispatcher-for-networkd.patch (+67/-0)
debian/patches/series (+2/-0)
debian/postrm (+16/-1)
Reviewer Review Type Date Requested Status
Steve Langasek (community) Needs Fixing
Nish Aravamudan (community) Approve
Canonical Server packageset reviewers Pending
git-ubuntu developers Pending
Review via email: mp+343328@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Tested from ppa [1] and working in my VM.
That said ready for review.

[1]: https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/3242

e685f84... by Christian Ehrhardt 

Update sources in response to systemd-networkd events (LP: #1718227).

This is reusing the already provided script for NetworkManager.
This script is not hard-tied to NetworkManager as it does not use
and of its provided environment variables.

OTOH the NM scripts are general scripts that are called on any change
and then differentiate between invocation reasons via the environment provided.
But the script for chrony is agnostic to the event types - it just checks if
servers are reachable and calls chronyc online/offline accordingly.

Therefore we just link this script into networkd-dispatcher events to work the
same way. Even if not setting servers offline via loosing an interface, but
instead e.g. using the auto_offline function of chrony and then configuring a
new device it will detect the servers as no-reachable and try to connect the
sources again.

Signed-off-by: Christian Ehrhardt <email address hidden>

3ee0889... by Christian Ehrhardt 

changelog: Update sources in response to systemd-networkd events (LP: #1718227).

Signed-off-by: Christian Ehrhardt <email address hidden>

6b7b54b... by Christian Ehrhardt 

- d/control: set Recommends to networkd-dispatcher

Signed-off-by: Christian Ehrhardt <email address hidden>

0d4466e... by Christian Ehrhardt 

add patches to nm-dispatcher script for networkd-dispatcher

Signed-off-by: Christian Ehrhardt <email address hidden>

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Added the changes that I brought upstream and the related packaging changes for bug 1718227.

I also updated the version in the PPA.

Revision history for this message
Nish Aravamudan (nacc) wrote :

Agree with the changes, please upload tag & upload.

review: Approve
Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

The base file is a conffile, the links are not.
Not in /etc nor in /usr/lib - I think that is ok for now as any changes needed could be done in the one conffile that it is.

I'll add a versioned dependency for the new path and wait until 1765152 is resolved with my upload.
Thanks Steve for letting me know about this!

e14e575... by Christian Ehrhardt 

d/control: make networkd-dispatcher dependency versioned for the new path by LP: #1765152

Signed-off-by: Christian Ehrhardt <email address hidden>

659b8a3... by Christian Ehrhardt 

d/links: adapt paths for changes by LP: #1765152

Signed-off-by: Christian Ehrhardt <email address hidden>

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Fixups according to Julians change for bug 1765152 pushed.

a43489f... by Christian Ehrhardt 

link targets should be non-absolute

Signed-off-by: Christian Ehrhardt <email address hidden>

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Tested with my ppa (as I'll upload) and the networkd-dispatcher from -proposed.
All good.

Tags pushed and uploading to bionic(-unapproved)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index 773796a..78c6ecc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
1chrony (3.2-4ubuntu4) bionic; urgency=medium
2
3 * d/postrm: re-establish systemd-timesyncd on removal (LP: #1764357)
4 * Notify chrony to update sources in response to systemd-networkd
5 events (LP: #1718227)
6 - d/links: link dispatcher script to networkd-dispatcher events routable
7 and off
8 - d/control: set Recommends to networkd-dispatcher
9 - d/p/lp-1718227-ignore-non-up-down-events-in-nm-dispatcher.patch
10 - d/p/lp-1718227-nm-dispatcher-for-networkd.patch
11
12 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Mon, 16 Apr 2018 17:04:06 +0200
13
1chrony (3.2-4ubuntu3) bionic; urgency=medium14chrony (3.2-4ubuntu3) bionic; urgency=medium
215
3 * debian/usr.sbin.chronyd: add cap net_admin for hwtimestamp (LP: #1761327)16 * debian/usr.sbin.chronyd: add cap net_admin for hwtimestamp (LP: #1761327)
diff --git a/debian/control b/debian/control
index 4cb4022..2e2c71f 100644
--- a/debian/control
+++ b/debian/control
@@ -29,6 +29,7 @@ Depends: ${misc:Depends},
29 lsb-base,29 lsb-base,
30 libcap2-bin,30 libcap2-bin,
31 adduser31 adduser
32Recommends: networkd-dispatcher (>= 1.7-0ubuntu3)
32Suggests: dnsutils33Suggests: dnsutils
33Conflicts: time-daemon, ntp34Conflicts: time-daemon, ntp
34Provides: time-daemon35Provides: time-daemon
diff --git a/debian/links b/debian/links
35new file mode 10064436new file mode 100644
index 0000000..71e2c52
--- /dev/null
+++ b/debian/links
@@ -0,0 +1,5 @@
1# Update sources in response to systemd-networkd events (LP: #1718227).
2# This is reusing the NetworkManager dispatch script which has no hard
3# dependency to NetworkManager (not using any of its arguments)
4etc/NetworkManager/dispatcher.d/20-chrony usr/lib/networkd-dispatcher/routable.d/chrony
5etc/NetworkManager/dispatcher.d/20-chrony usr/lib/networkd-dispatcher/off.d/chrony
diff --git a/debian/patches/lp-1718227-ignore-non-up-down-events-in-nm-dispatcher.patch b/debian/patches/lp-1718227-ignore-non-up-down-events-in-nm-dispatcher.patch
0new file mode 1006446new file mode 100644
index 0000000..cf12711
--- /dev/null
+++ b/debian/patches/lp-1718227-ignore-non-up-down-events-in-nm-dispatcher.patch
@@ -0,0 +1,32 @@
1From b563048ee28d121142a663ac6a598e4c71e2c21d Mon Sep 17 00:00:00 2001
2From: Miroslav Lichvar <mlichvar@redhat.com>
3Date: Tue, 13 Feb 2018 11:44:24 +0100
4Subject: [PATCH 1/2] examples: ignore non-up/down events in nm-dispatcher
5 script
6
7Forwarded: no (backport)
8Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
9Original-Author: Miroslav Lichvar <mlichvar@redhat.com>
10Origin: upstream, https://git.tuxfamily.org/chrony/chrony.git/commit/?id=b563048ee28d121142a663ac6a598e4c71e2c21d
11Bug-Ubuntu: https://bugs.launchpad.net/bugs/1718227
12Last-Update: 2018-04-18
13---
14 examples/chrony.nm-dispatcher | 2 ++
15 1 file changed, 2 insertions(+)
16
17diff --git a/examples/chrony.nm-dispatcher b/examples/chrony.nm-dispatcher
18index 51d7fa2..a609a66 100644
19--- a/examples/chrony.nm-dispatcher
20+++ b/examples/chrony.nm-dispatcher
21@@ -4,6 +4,8 @@
22
23 export LC_ALL=C
24
25+[ "$2" != "up" ] && [ "$2" != "down" ] && exit 0
26+
27 # Check if there is a default route
28
29 if /sbin/ip route list 2> /dev/null | grep -q '^default'; then
30--
312.7.4
32
diff --git a/debian/patches/lp-1718227-nm-dispatcher-for-networkd.patch b/debian/patches/lp-1718227-nm-dispatcher-for-networkd.patch
0new file mode 10064433new file mode 100644
index 0000000..37dc411
--- /dev/null
+++ b/debian/patches/lp-1718227-nm-dispatcher-for-networkd.patch
@@ -0,0 +1,67 @@
1From 8cbc68f28f96d48a7ee128fa91731ca02a598913 Mon Sep 17 00:00:00 2001
2From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
3Date: Wed, 18 Apr 2018 15:44:21 +0200
4Subject: [PATCH 2/2] examples: make nm-dispatcher script usable for
5 networkd-dispatcher
6
7Historically there were plenty of callback based implementations around
8ifupdown via /etc/network/if-up and similar. NetworkManager added the
9dispatcher [1] feature for such a kind of functionality.
10
11But so far a systemd-networkd (only) systemd had no means to handle those
12cases. This is solved by networkd-dispatcher which is currently available
13at least in ArchLinux and Ubuntu.
14It takes away the responsibility to listen on netlink events in each
15application and provides a more classic script-drop-in interface to respond
16to networkd events [3].
17
18This commit makes the NM example compatible to be used by NetworkManager
19dispatcher as well as by networkd-dispatcher. That way we avoid too much
20code duplication and can from now on handle special cases in the
21beginning so that the tail can stay commonly used.
22
23After discussion on IRC the current check differs by checking the
24argument count (only in NetworkManager), if ever needed we could extend
25that to check for known custom environment vars (NetworkManager =>
26CONNECTION_UUID; networkd-dispatcher => OperationalState).
27
28[1]: https://developer.gnome.org/NetworkManager/stable/NetworkManager.html
29[2]: https://github.com/craftyguy/networkd-dispatcher
30[3]: https://github.com/systemd/systemd/blob/master/src/systemd/sd-network.h#L86
31
32Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
33
34Forwarded: no (backport)
35Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
36Origin: upstream, https://git.tuxfamily.org/chrony/chrony.git/commit/?id=8cbc68f28f96d48a7ee128fa91731ca02a598913
37Bug-Ubuntu: https://bugs.launchpad.net/bugs/1718227
38Last-Update: 2018-04-18
39---
40 examples/chrony.nm-dispatcher | 10 +++++++---
41 1 file changed, 7 insertions(+), 3 deletions(-)
42
43diff --git a/examples/chrony.nm-dispatcher b/examples/chrony.nm-dispatcher
44index a609a66..8bd7df0 100644
45--- a/examples/chrony.nm-dispatcher
46+++ b/examples/chrony.nm-dispatcher
47@@ -1,10 +1,14 @@
48 #!/bin/sh
49-# This is a NetworkManager dispatcher script for chronyd to set its NTP sources
50-# online or offline when a network interface is configured or removed
51+# This is a NetworkManager dispatcher / networkd-dispatcher script for
52+# chronyd to set its NTP sources online or offline when a network interface
53+# is configured or removed
54
55 export LC_ALL=C
56
57-[ "$2" != "up" ] && [ "$2" != "down" ] && exit 0
58+# For NetworkManager consider only up/down events
59+[ $# -ge 2 ] && [ "$2" != "up" ] && [ "$2" != "down" ] && exit 0
60+
61+# Note: for networkd-dispatcher routable.d ~= on and off.d ~= off
62
63 # Check if there is a default route
64
65--
662.7.4
67
diff --git a/debian/patches/series b/debian/patches/series
index 3b2acc6..947a7d5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
1lp1589780-sys_linux-don-t-keep-CAP_SYS_TIME-with-x-option.patch1lp1589780-sys_linux-don-t-keep-CAP_SYS_TIME-with-x-option.patch
2lp-1718227-ignore-non-up-down-events-in-nm-dispatcher.patch
3lp-1718227-nm-dispatcher-for-networkd.patch
diff --git a/debian/postrm b/debian/postrm
index 42f48bc..6fba6b5 100644
--- a/debian/postrm
+++ b/debian/postrm
@@ -7,6 +7,15 @@ set -e
77
8# targets: purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear8# targets: purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear
99
10restore_timesyncd() {
11 # on next reboot it would start, but that would leave time
12 # unsynchronized until then. So as the Conflicts in the service file kill
13 # systemd-timesyncd re-establish it if it is enabled
14 if [ "$(systemctl is-enabled systemd-timesyncd 2>/dev/null)" = "enabled" ] ; then
15 systemctl start systemd-timesyncd
16 fi
17}
18
10case "$1" in19case "$1" in
11 purge)20 purge)
12 rm -f /var/lib/chrony/*21 rm -f /var/lib/chrony/*
@@ -30,9 +39,15 @@ case "$1" in
30 then39 then
31 deluser --quiet --system _chrony > /dev/null 2>&1 || true40 deluser --quiet --system _chrony > /dev/null 2>&1 || true
32 fi41 fi
42
43 restore_timesyncd
44 ;;
45
46 remove)
47 restore_timesyncd
33 ;;48 ;;
3449
35 remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)50 upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
3651
37 ;;52 ;;
3853

Subscribers

People subscribed via source and target branches