mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-05 04:27:55 +00:00
fix(xcat-core): trim the commentary around the Ubuntu NTP fix
setupntp explained systemd-timesyncd in four lines where two carry the reason nothing displaces it, and repeated the hwclock rationale that the guard below already implies. NTP::Backend's header narrated that the module exists to be unit-tested. The test header restated all of it a third time, and said "the first three are behaviours of the script" about a list of three items whose third is the packaging check. Corrected and shortened; the note on why setupntp cannot simply be executed is kept, since that is not obvious from reading it. Interface documentation is left alone: choose()'s parameter list and default_backend()'s per-family table are what a caller needs. 18 comment lines removed, no behaviour change. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
package xCAT::NTP::Backend;
|
||||
|
||||
# Selector for the NTP daemon xCAT configures on a node (chrony vs. ntpd), in the same spirit as
|
||||
# xCAT::DHCP::Backend (ISC vs. Kea). makentp/setupntp support chronyd and ntpd only -- there is no
|
||||
# systemd-timesyncd path (timesyncd is an SNTP client and cannot serve time to compute nodes), so an
|
||||
# xCAT MN always needs chrony or ntpd. This module centralizes and unit-tests the choice.
|
||||
# Selector for the NTP daemon xCAT configures (chrony vs. ntpd), in the same spirit as
|
||||
# xCAT::DHCP::Backend. There is no timesyncd path: it is an SNTP client and cannot serve time to
|
||||
# compute nodes, so an MN always needs chrony or ntpd.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@@ -33,8 +32,8 @@ sub normalize {
|
||||
# requested -- override (default: site.ntpbackend, else 'auto')
|
||||
# os_name/version -- OS identity (default: detected)
|
||||
# available -- optional { chrony => 0/1, ntpd => 0/1 } to bypass command detection (tests)
|
||||
# check_available -- when true, downgrade chrony->ntpd (or ntpd->chrony) if the chosen one is
|
||||
# absent but the other is present, and flag install=1 when neither is present.
|
||||
# check_available -- when true, downgrade to whichever daemon is installed, and flag install=1
|
||||
# when neither is.
|
||||
sub choose {
|
||||
my ( $class, %args ) = @_;
|
||||
|
||||
|
||||
@@ -6,14 +6,10 @@ use FindBin;
|
||||
use File::Temp qw(tempdir);
|
||||
use Test::More;
|
||||
|
||||
# setupntp configures a server-capable NTP daemon on the management node. On a stock Ubuntu MN
|
||||
# three things went wrong: hwclock had moved to util-linux-extra and was absent, so the fatal
|
||||
# executable check aborted the ENTIRE NTP setup including the clock step that does not use it;
|
||||
# systemd-timesyncd was left running and kept disciplining the clock against the daemon being
|
||||
# configured; and the xcat package did not pull in a daemon that can serve time at all.
|
||||
#
|
||||
# The first three are behaviours of the script, so run it. The last is a property of the
|
||||
# packaging manifests, so read those.
|
||||
# A stock Ubuntu MN broke three ways: a missing hwclock aborted the whole NTP setup,
|
||||
# systemd-timesyncd kept fighting the daemon being configured, and the xcat package pulled in no
|
||||
# daemon that can serve time. The first two are behaviours of the script, so run it; the third is
|
||||
# a property of the packaging manifests, so read those.
|
||||
|
||||
my $repo = "$FindBin::Bin/../..";
|
||||
my $setupntp_path = "$repo/xCAT/postscripts/setupntp";
|
||||
@@ -25,10 +21,9 @@ my @lines = <$fh>;
|
||||
close $fh;
|
||||
my $source = join '', @lines;
|
||||
|
||||
# setupntp forces its own PATH and refuses to run unless UID is 0, so its commands cannot be
|
||||
# stubbed from outside and it cannot run as an ordinary user. Take the script's own helper
|
||||
# functions and the section that configures the daemon, and drive them with shell functions --
|
||||
# which bash resolves ahead of PATH, and which `type` and `command -v` both report as present.
|
||||
# setupntp forces its own PATH and exits unless UID is 0, so it cannot be stubbed from outside
|
||||
# or run unprivileged. Drive its own helper functions with shell functions instead: bash resolves
|
||||
# those ahead of PATH, and both `type` and `command -v` report them as present.
|
||||
my ($helpers) = $source =~ /\A(.*?)^\[ "\$\{UID\}" -eq "0" \]/ms;
|
||||
my ($body) = $source =~ /^(check_exec_or_exit cp cat logger grep\n.*?)^CHRONY_CONF=/ms;
|
||||
BAIL_OUT('could not take the helper functions from setupntp') unless $helpers;
|
||||
|
||||
@@ -146,9 +146,9 @@ unset MASTER
|
||||
unset NTPSERVERS
|
||||
|
||||
check_exec_or_exit cp cat logger grep
|
||||
# hwclock is NOT required: it only persists the (already chronyd-stepped) system clock to the RTC
|
||||
# below, and it is optional -- on Ubuntu 24.04+ it moved to util-linux-extra, which is absent on
|
||||
# minimal cloud images. Requiring it here aborted the whole NTP setup (and the clock step) on noble.
|
||||
# hwclock is NOT required: it only persists the already-stepped clock to the RTC below, and on
|
||||
# Ubuntu 24.04+ it moved to util-linux-extra, absent on minimal images. Requiring it here aborted
|
||||
# the whole NTP setup, including the clock step that does not use it.
|
||||
check_exec_or_exit systemctl timedatectl
|
||||
|
||||
systemctl stop ntp.service 2>/dev/null
|
||||
@@ -159,10 +159,8 @@ systemctl disable ntpd.service 2>/dev/null
|
||||
systemctl disable ntp-wait.service 2>/dev/null
|
||||
systemctl disable ntpdate.service 2>/dev/null
|
||||
|
||||
# systemd-timesyncd is an SNTP client that also disciplines the system clock. It is part of systemd
|
||||
# (not a "time-daemon" package), so it coexists with chrony/ntpd at the package level but must be
|
||||
# stopped or it fights the NTP daemon we are configuring. This is the default time-sync stack on
|
||||
# Ubuntu, where it must yield to chrony (timesyncd cannot serve time to compute nodes).
|
||||
# systemd-timesyncd ships as part of systemd rather than a time-daemon package, so nothing
|
||||
# displaces it and it keeps disciplining the clock against the daemon being configured.
|
||||
systemctl stop systemd-timesyncd.service 2>/dev/null
|
||||
systemctl disable systemd-timesyncd.service 2>/dev/null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user