Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1828434

Summary: Better integration of per-platform defaults
Product: Red Hat Enterprise Linux 8 Reporter: Colin Walters <walters>
Component: chronyAssignee: Miroslav Lichvar <mlichvar>
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.3CC: jlebon, lucab, miabbott
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-09-21 13:53:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Colin Walters 2020-04-27 17:22:30 UTC
See https://github.com/openshift/installer/pull/3513

Basically on Azure we always want to use their PTP device; we can do that by changing chrony.conf but that can potentially conflict with any per-user customizations.

It'd help if chrony supported both drop-in dirs like:
/etc/chrony.conf.d
as well as
/run/chrony.conf.d

See e.g. https://docs.rs/liboverdrop/0.0.2/liboverdrop/

Comment 1 Jonathan Lebon 2020-04-27 17:45:47 UTC
It looks like chrony supports include directives: https://git.tuxfamily.org/chrony/chrony.git/tree/doc/chrony.conf.adoc?id=ad8fb64276bfaf94feedb7e5ae61bba2f741308e#n2143. Is it possible to have the example there (`include @SYSCONFDIR@/chrony.d/*.conf`) included by default in `/etc/chrony.conf`? (Or is there a reason why this is avoided?)

Comment 2 Miroslav Lichvar 2020-04-28 07:21:31 UTC
The reason why the default chrony.conf doesn't use the include directive is that there wasn't a good use case so far and it makes debugging more difficult (if you don't have access to all the files).

The default chrony.conf uses pool.ntp.org servers. If there is a trusted local time source like the PTP clock, the pool.ntp.org servers should be disabled. But that cannot be done by adding files to /etc/chrony.conf.d. A file needs to be removed or modified.

Comment 3 Colin Walters 2020-04-28 18:22:01 UTC
> But that cannot be done by adding files to /etc/chrony.conf.d. A file needs to be removed or modified.

OK so what you're saying here is that the Azure recommendations at
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/time-sync
are insufficient, because we want to *only* use the PHC by removing
the `pool` line?

Comment 4 Luca BRUNO 2020-04-29 08:19:41 UTC
> A file needs to be removed or modified.

The original ticket was a request to support dropins, which are a logical superset of include-directories.
Specifically, they cover this exact case without removing or modifying any vendor file.
The "same filename overriding" logic allows to surgically blankout/supercede a vendor default (in /usr) from a user customization fragment (in /etc).

It would be nice for chrony to support that.

Comment 5 Miroslav Lichvar 2020-04-29 09:19:20 UTC
(In reply to Colin Walters from comment #3)
> OK so what you're saying here is that the Azure recommendations at
> https://docs.microsoft.com/en-us/azure/virtual-machines/linux/time-sync
> are insufficient, because we want to *only* use the PHC by removing
> the `pool` line?

They list "Host-only using VMICTimeSync." as one of the three ways to synchronize the clock. If security is a concern, I think that should be preferred over using (unauthenticated) external NTP servers. If NTP servers need to be used, ideally they should be local to the datacenter.

(In reply to Luca BRUNO from comment #4)
> The original ticket was a request to support dropins, which are a logical
> superset of include-directories.
> Specifically, they cover this exact case without removing or modifying any
> vendor file.
> The "same filename overriding" logic allows to surgically blankout/supercede
> a vendor default (in /usr) from a user customization fragment (in /etc).

Ok, that makes sense. We would need to split the default configuration file into multiple files, where one would have the pool.ntp.org servers. This needs some thought. However, it would be a major change in the packaging. I don't think it can be done in a minor RHEL update.

FWIW, there is a chrony-helper script included in the chrony package. It can modify the sources in /etc/chrony.conf, e.g.

echo "refclock PHC /dev/ptp0 poll 2" | /usr/libexec/chrony-helper set-static-sources

Comment 6 Miroslav Lichvar 2020-05-14 13:56:25 UTC
FWIW, the latest upstream code now supports a "confdirs" directive, which allows configuration fragments to be disabled or replaced by adding files to other directories (e.g. /etc/chrony.d, /var/run/chrony.d). I'm not sure whether or how the packaged configuration should adopt that yet.

Comment 7 Robert Fairley 2020-06-05 23:07:01 UTC
Some thoughts on DHCP-provided NTP servers - currently a record of the DHCP-provided NTP servers added to chrony is kept in `/run/chrony-helper/added_servers`, written by chrony-helper. One way to disable all DHCP-provided servers through host config is chrony-helper could be adjusted to write the servers to a config snippet `/run/chrony.d/10-dhcp-servers`, and then have chronyd re-read config snippets. That way, writing an empty file to `/etc/chrony.d/10-dhcp-servers` would disable DHCP-provided NTP servers. The empty host config file could be added as part of the generator https://github.com/coreos/fedora-coreos-config/blob/a8fb8e2caac6b981296c34e206dfc4157b56d486/overlay.d/20platform-chrony/usr/lib/systemd/system-generators/coreos-platform-chrony or in an overlay. To override the addition of the empty file (i.e. deleting it) https://github.com/coreos/ignition/issues/739 would probably be required, in FCOS/RHCOS at least. This should work considering interface-specific NTP servers from DHCP are currently stored persistently on disk at first at somewhere like `/var/lib/dhclient/chrony.servers.${interface}`, and then are read into a common (non interface-specific) location `/run/chrony-helper/added_servers` before being added to chronyd.

Comment 9 Miroslav Lichvar 2020-06-08 15:22:13 UTC
FWIW, chronyd doesn't currently support reloading of config files. It would need to be restarted, but we want to avoid unnecessary restarts to avoid losing NTP measurements and avoid a limited makestep triggering again. There is also an issue that some directives can't work after dropping the root privileges (e.g. opening an RTC or reference clock). So, we would probably need a new directive to read NTP sources from files, which could be reloaded with a "reload" command from chronyc.

Comment 10 Miroslav Lichvar 2020-06-11 08:33:18 UTC
The upstream code now has a "sourcedirs" directive to read NTP sources from files, which can be reloaded with "chronyc reload sources" command. However, I don't see how we could migrate to such a configuration in a minor RHEL release. On systems that have a non-default chrony.conf, we could add the sourcedirs directive to the file in a scriptlet, but that would break as soon as it was replaced by the user or regenerated by a configuration tool (e.g. the timesync ansible role). This looks like a major change in packaging that needs to wait for the next major release.

Comment 11 Miroslav Lichvar 2020-09-21 13:53:48 UTC
As explained in the previous comment, I don't see a way to enable this feature in RHEL8 without breaking compatibility with existing tools. I'm closing the bug.