From 8e9514d85cdd4bdd13ac0e0099759194aeadea8c Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Thu, 12 Mar 2015 18:39:13 -0700 Subject: [PATCH] systemd: add UseNTP DHCP option, allow timesyncd in VMs These are two important prerequisites for eventually switching from ntpd to timesyncd as our default ntp service. --- ...enable-timesyncd-in-virtual-machines.patch | 39 ++++++++++++++++ ...-0005-network-add-UseNTP-DHCP-option.patch | 46 +++++++++++++++++++ ...enable-timesyncd-in-virtual-machines.patch | 39 ++++++++++++++++ ...-0002-network-add-UseNTP-DHCP-option.patch | 46 +++++++++++++++++++ ...md-218-r5.ebuild => systemd-218-r6.ebuild} | 4 ++ ...stemd-219.ebuild => systemd-219-r1.ebuild} | 4 ++ 6 files changed, 178 insertions(+) create mode 100644 sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/218-0004-timesyncd-enable-timesyncd-in-virtual-machines.patch create mode 100644 sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/218-0005-network-add-UseNTP-DHCP-option.patch create mode 100644 sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/219-0001-timesyncd-enable-timesyncd-in-virtual-machines.patch create mode 100644 sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/219-0002-network-add-UseNTP-DHCP-option.patch rename sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/{systemd-218-r5.ebuild => systemd-218-r6.ebuild} (98%) rename sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/{systemd-219.ebuild => systemd-219-r1.ebuild} (98%) diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/218-0004-timesyncd-enable-timesyncd-in-virtual-machines.patch b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/218-0004-timesyncd-enable-timesyncd-in-virtual-machines.patch new file mode 100644 index 0000000000..f019ac656c --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/218-0004-timesyncd-enable-timesyncd-in-virtual-machines.patch @@ -0,0 +1,39 @@ +From 48a6d639f867ba5b96ff22edce6a297cdace9cf9 Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Sun, 15 Mar 2015 19:44:59 +0100 +Subject: [PATCH 4/5] timesyncd: enable timesyncd in virtual machines + +On Fri, Mar 13, 2015 at 8:25 PM, Michael Marineau wrote: +> Currently systemd-timesyncd.service includes +> ConditionVirtualization=no, disabling it in both containers and +> virtual machines. Each VM platform tends to deal with or ignore the +> time problem in their own special ways, KVM/QEMU has the kernel time +> source kvm-clock, Xen has had different schemes over the years, VMware +> expects a userspace daemon sync the clock, and other platforms are +> content to drift with the wind as far as I can tell. +> +> I don't know of a robust way to know if a platform needs a little +> extra help from userspace to keep the clock sane or not but it seems +> generally safer to try than to risk drifting. Does anyone know of a +> reason to leave timesyncd off by default? Otherwise switching to +> ConditionVirtualization=!container should be reasonable. +--- + units/systemd-timesyncd.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/units/systemd-timesyncd.service.in b/units/systemd-timesyncd.service.in +index 39edafc..8219c95 100644 +--- a/units/systemd-timesyncd.service.in ++++ b/units/systemd-timesyncd.service.in +@@ -9,7 +9,7 @@ + Description=Network Time Synchronization + Documentation=man:systemd-timesyncd.service(8) + ConditionCapability=CAP_SYS_TIME +-ConditionVirtualization=no ++ConditionVirtualization=!container + DefaultDependencies=no + RequiresMountsFor=/var/lib/systemd/clock + After=systemd-remount-fs.service systemd-tmpfiles-setup.service systemd-sysusers.service +-- +2.0.5 + diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/218-0005-network-add-UseNTP-DHCP-option.patch b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/218-0005-network-add-UseNTP-DHCP-option.patch new file mode 100644 index 0000000000..7c0a616f87 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/218-0005-network-add-UseNTP-DHCP-option.patch @@ -0,0 +1,46 @@ +From 5aabe1661ded65cf5231a213cbf161a09b603207 Mon Sep 17 00:00:00 2001 +From: Michael Marineau +Date: Fri, 13 Mar 2015 12:01:29 -0700 +Subject: [PATCH 5/5] network: add UseNTP DHCP option + +Despite having the internal logic in place to enable/disable using NTP +servers provided by DHCP the network config didn't expose the option. +--- + man/systemd.network.xml | 8 ++++++++ + src/network/networkd-network-gperf.gperf | 1 + + 2 files changed, 9 insertions(+) + +diff --git a/man/systemd.network.xml b/man/systemd.network.xml +index 79c7a23..1897657 100644 +--- a/man/systemd.network.xml ++++ b/man/systemd.network.xml +@@ -468,6 +468,14 @@ + + + ++ UseNTP= ++ ++ When true (the default), the NTP servers received ++ from the DHCP server will be used by systemd-timesyncd ++ and take precedence over any statically configured ones. ++ ++ ++ + UseMTU= + + When true, the interface maximum transmission unit from the DHCP server will +diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf +index 640a3a2..8c1f552 100644 +--- a/src/network/networkd-network-gperf.gperf ++++ b/src/network/networkd-network-gperf.gperf +@@ -52,6 +52,7 @@ Route.Destination, config_parse_destination, 0, + Route.Source, config_parse_destination, 0, 0 + Route.Metric, config_parse_route_priority, 0, 0 + DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns) ++DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_ntp) + DHCP.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu) + DHCP.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname) + DHCP.UseDomains, config_parse_bool, 0, offsetof(Network, dhcp_domains) +-- +2.0.5 + diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/219-0001-timesyncd-enable-timesyncd-in-virtual-machines.patch b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/219-0001-timesyncd-enable-timesyncd-in-virtual-machines.patch new file mode 100644 index 0000000000..ab4c4bc192 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/219-0001-timesyncd-enable-timesyncd-in-virtual-machines.patch @@ -0,0 +1,39 @@ +From 4b16233e59b3edd8338819dad275cc94b5e5f6e7 Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Sun, 15 Mar 2015 19:44:59 +0100 +Subject: [PATCH] timesyncd: enable timesyncd in virtual machines + +On Fri, Mar 13, 2015 at 8:25 PM, Michael Marineau wrote: +> Currently systemd-timesyncd.service includes +> ConditionVirtualization=no, disabling it in both containers and +> virtual machines. Each VM platform tends to deal with or ignore the +> time problem in their own special ways, KVM/QEMU has the kernel time +> source kvm-clock, Xen has had different schemes over the years, VMware +> expects a userspace daemon sync the clock, and other platforms are +> content to drift with the wind as far as I can tell. +> +> I don't know of a robust way to know if a platform needs a little +> extra help from userspace to keep the clock sane or not but it seems +> generally safer to try than to risk drifting. Does anyone know of a +> reason to leave timesyncd off by default? Otherwise switching to +> ConditionVirtualization=!container should be reasonable. +--- + units/systemd-timesyncd.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/units/systemd-timesyncd.service.in b/units/systemd-timesyncd.service.in +index 39edafc..8219c95 100644 +--- a/units/systemd-timesyncd.service.in ++++ b/units/systemd-timesyncd.service.in +@@ -9,7 +9,7 @@ + Description=Network Time Synchronization + Documentation=man:systemd-timesyncd.service(8) + ConditionCapability=CAP_SYS_TIME +-ConditionVirtualization=no ++ConditionVirtualization=!container + DefaultDependencies=no + RequiresMountsFor=/var/lib/systemd/clock + After=systemd-remount-fs.service systemd-tmpfiles-setup.service systemd-sysusers.service +-- +2.0.5 + diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/219-0002-network-add-UseNTP-DHCP-option.patch b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/219-0002-network-add-UseNTP-DHCP-option.patch new file mode 100644 index 0000000000..c3b10aa0bc --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/219-0002-network-add-UseNTP-DHCP-option.patch @@ -0,0 +1,46 @@ +From 301f4073fe1c2757e602aef24cee9ccf5f81a3a3 Mon Sep 17 00:00:00 2001 +From: Michael Marineau +Date: Fri, 13 Mar 2015 12:01:29 -0700 +Subject: [PATCH] network: add UseNTP DHCP option + +Despite having the internal logic in place to enable/disable using NTP +servers provided by DHCP the network config didn't expose the option. +--- + man/systemd.network.xml | 8 ++++++++ + src/network/networkd-network-gperf.gperf | 1 + + 2 files changed, 9 insertions(+) + +diff --git a/man/systemd.network.xml b/man/systemd.network.xml +index ed0b2eb..087e9e2 100644 +--- a/man/systemd.network.xml ++++ b/man/systemd.network.xml +@@ -515,6 +515,14 @@ + + + ++ UseNTP= ++ ++ When true (the default), the NTP servers received ++ from the DHCP server will be used by systemd-timesyncd ++ and take precedence over any statically configured ones. ++ ++ ++ + UseMTU= + + When true, the interface maximum transmission unit +diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf +index 93df83a..8abf5bc 100644 +--- a/src/network/networkd-network-gperf.gperf ++++ b/src/network/networkd-network-gperf.gperf +@@ -60,6 +60,7 @@ Route.Metric, config_parse_route_priority, 0, + Route.Scope, config_parse_route_scope, 0, 0 + DHCP.ClientIdentifier, config_parse_dhcp_client_identifier,0, offsetof(Network, dhcp_client_identifier) + DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns) ++DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_ntp) + DHCP.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu) + DHCP.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname) + DHCP.UseDomains, config_parse_bool, 0, offsetof(Network, dhcp_domains) +-- +2.0.5 + diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-218-r5.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-218-r6.ebuild similarity index 98% rename from sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-218-r5.ebuild rename to sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-218-r6.ebuild index 77c1cba554..a4cf04c465 100644 --- a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-218-r5.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-218-r6.ebuild @@ -186,6 +186,10 @@ fi # https://github.com/coreos/bugs/issues/186 epatch "${FILESDIR}"/218-0003-core-open-up-DefaultDependencies-property-for-transi.patch + # Allow timesyncd in VMs, make DHCP provided NTP servers optional + epatch "${FILESDIR}"/218-0004-timesyncd-enable-timesyncd-in-virtual-machines.patch + epatch "${FILESDIR}"/218-0005-network-add-UseNTP-DHCP-option.patch + autotools-utils_src_prepare } diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-219.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-219-r1.ebuild similarity index 98% rename from sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-219.ebuild rename to sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-219-r1.ebuild index 1bd4640eb7..c7fa9d38e4 100644 --- a/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-219.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-219-r1.ebuild @@ -183,6 +183,10 @@ fi # Bug 463376 sed -i -e 's/GROUP="dialout"/GROUP="uucp"/' rules/*.rules || die + # Allow timesyncd in VMs, make DHCP provided NTP servers optional + epatch "${FILESDIR}"/219-0001-timesyncd-enable-timesyncd-in-virtual-machines.patch + epatch "${FILESDIR}"/219-0002-network-add-UseNTP-DHCP-option.patch + autotools-utils_src_prepare }