Repository navigation
Conversation
|
Tests done:
|
d42a0dc to
b69fbf0
Compare
|
Last push:
|
psafont
left a comment
There was a problem hiding this comment.
I do like removing these kinds of dependencies. One thing that is not clear, is how is the synchronization between the writing of the configuration and reading of it by the NTP client happening, they just read it periodically, or is there some kind of trigger elsewhere that makes them read the configuration?
|
The #!/usr/bin/bash
CHRONY_SOURCEDIR=/run/chrony-dhcp
SERVERFILE=$CHRONY_SOURCEDIR/$interface.sources
chrony_config() {
# Disable modifications if called from a NM dispatcher script
[ -n "$NM_DISPATCHER_ACTION" ] && return 0
rm -f "$SERVERFILE"
if [ "$PEERNTP" != "no" ]; then
mkdir -p $CHRONY_SOURCEDIR
for server in $new_ntp_servers; do
echo "server $server ${NTPSERVERARGS:-iburst}" >> "$SERVERFILE"
done
/usr/bin/chronyc reload sources > /dev/null 2>&1 || :
fi
}
chrony_restore() {
[ -n "$NM_DISPATCHER_ACTION" ] && return 0
if [ -f "$SERVERFILE" ]; then
rm -f "$SERVERFILE"
/usr/bin/chronyc reload sources > /dev/null 2>&1 || :
fi
}The functions are called by On receiving IP from DHCP,
On lease release, |
|
Thanks @psafont involves me. I remember the implementation has some historical reasons. I will look into it. |
b69fbf0 to
1a5ee37
Compare
|
I have added migration code path. At xapi start, it will look at the current NTP system layout and update it. I used an integer for keeping track of "NTP system layout version" instead of just a boolean in order to have a possibly different layout later. On the first host startup after the upgrade, it will ensure that the DHCP hook file is executable and rewrite the NTP configuration file. Regarding populating the NTP sources at switch time, I think it is not necessary:
But there is one edge-case that I need to review more deeply: the upgrade time. I think there is a possible race window where the hook isn't executable at DHCP time (so no sources will be recorded), and xapi updating it later. |
|
Regarding the edge-case I mentioned, I confirm it is existing (and I am able to trigger it).
I dunno if the drawback of this one-time and not-immediately effective NTP configuration change is acceptable or not. |
1a5ee37 to
f8a91cd
Compare
f8a91cd to
cb7dd19
Compare
|
|
||
| let add_dhcp_ntp_servers () = | ||
| let servers, _, other = parse_ntp_conf () in | ||
| write_ntp_conf other [dhcp_line ()] servers |
There was a problem hiding this comment.
parse_ntp_conf gives the whole server_line. But write_ntp_conf needs bare server name. It should be wrong here. You may have a self test to verify this.
There was a problem hiding this comment.
Thanks for pointing that. My tests doesn't expose it because I didn't done tests with manually edited chrony.conf file.
When you sets ntp-mode=DHCP (which it calling add_dhcp_ntp_servers function), the state were:
ntp-mode=Factory: it callsclear_servers_in_conffirstntp-mode=Custom: it callsclear_servers_in_conffirstntp-mode=Disable: file was not touched before only the service is disabledntp-mode=DHCP:set_ntp_modeskips the change
So you usually don't have server lines in the chrony.conf file at add_dhcp_ntp_servers time.
I will look to fix it. There is no reason to produce an invalid chrony.conf file.
There was a problem hiding this comment.
Hi @semarie do you have any plans to backport it to lcm-26.1? There are a few more corner cases to consider there I think.
There was a problem hiding this comment.
there is no backport intent for 26.1-lcm.
There was a problem hiding this comment.
Hi @changlei-li I added a commit to do a small refactor of parse_ntp_conf / write_ntp_conf first.
There was a problem hiding this comment.
Thank you. I have no more comments now. If you have manual tests, you can paste the test results here.
As I mentioned, this change needs to be released together with the corresponding changes in xsconsole and host-installer. I will keep the change request here to avoid it is merged unintentionally until the changes in those public repos are done.
I can handle the XenRT test cases on our side when all is settled.
Small refactor to make `parse_ntp_conf` and `write_ntp_conf` parallel:
`parse_ntp_conf` is returning `parsed_ntp` type and `write_ntp_conf` is consuming it.
It changes `write_ntp_conf` to take a server line ("server %s iburst") instead of a server address.
The conversion is now done inside `set_servers_in_conf`.
It is done as preliminary work before using more `parse_ntp_conf` and `write_ntp_conf`.
Signed-off-by: Sebastien Rodot <sebastien.rodot@vates.tech>
…SC dhclient internals Change the way `ntp-mode=DHCP` integration is done. Previously, xapi was parsing dhclient leases (internal format, DHCPv4 format only) and manually create sources file inside `/run/chrony-dhcp` directory. Prefer relying on proper NTP and DHCP integration: only change `chrony.conf` file and add `sourcedir /run/chrony-dhcp` directive only when `ntp-mode=DHCP`, and let's the DHCP client to manage populating /run/chrony-dhcp directory. It makes `ntp-mode=DHCP` to be independent of ISC dhclient. On startup, take care of migrate the system layout: - ensure the ntp_dhcp_script filemode has executable bit (whatever the ntp-mode is) - take care of `sourcedir` line in the ntp configuration (new marker for ntp-mode=DHCP) Tracking-reference: XCPNG-1094 Signed-off-by: Sebastien Rodot <sebastien.rodot@vates.tech>
cb7dd19 to
d6d182d
Compare
Following xapi-project/xen-api#7332, this commit changes the way the DHCP mode of NTP is implemented. Instead of relying on executable permission of `chrony.sh` (dhclient hook), use the presence of `sourcedir` line in `chrony.conf`. It makes the implementation to depend only on chrony instead of both chrony and dhclient. Tracking-reference: XCPNG-1094 Signed-off-by: Sebastien Rodot <sebastien.rodot@vates.tech>
It makes xsconsole independant of the XAPI implementation for NTP DHCP (which is changed by xapi-project/xen-api#7332). Tracking-reference: XCPNG-1094 Signed-off-by: Sebastien Rodot <sebastien.rodot@vates.tech>
It makes xsconsole independant of the XAPI implementation for NTP DHCP (which is changed by xapi-project/xen-api#7332). Tracking-reference: XCPNG-1094 Signed-off-by: Sebastien Rodot <sebastien.rodot@vates.tech>
Change the way
ntp-mode=DHCPintegration is done.Previously, xapi was parsing dhclient leases (internal format, DHCPv4 format only) and manually create sources file inside
/run/chrony-dhcpdirectory.Prefer relying on proper NTP and DHCP integration: only change
chrony.conffile and addsourcedir /run/chrony-dhcpdirective only whenntp-mode=DHCP, and let's the DHCP client to manage populating /run/chrony-dhcp directory.It makes
ntp-mode=DHCPto be independent of ISC dhclient.