* [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel
@ 2026-11-26 13:39 Jonas Theisen
2026-11-26 13:39 ` [PATCH common 01/16] systemd: add helpers to get and set NTP servers Jonas Theisen
` (15 more replies)
0 siblings, 16 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:39 UTC (permalink / raw)
To: pve-devel
This series allows configuring the NTP servers of a node via the API
and GUI, instead of having to edit the configuration of the time
synchronization service on the shell. As correct time is important for
clusters and Ceph, it also adds ways to check that synchronization
works after a change:
- show whether the system clock is synchronized
- open the log of the NTP service from the time panel
- synchronize the clock immediately ("Sync now")
- list the sources currently in use, including pool members, with
their state, reachability and offset
Supported are chrony, the default on new installations, and
systemd-timesyncd. Custom sources are written to drop-ins, and once
all are removed, the service uses its default sources again. For
chrony, the default pool lines in chrony.conf are commented out with
a marker while custom sources are set, as a drop-in cannot disable
them, and restored afterwards. Pools are only supported with chrony,
as systemd-timesyncd only uses single servers.
On cluster nodes, an immediate synchronization can make the clock
jump and disrupt services such as Ceph, so the API requires the new
'force' parameter there, and the GUI asks for an explicit
acknowledgement before passing it.
The toolkit components are shared with other products, so all new
rows and buttons are only shown if the time API reports the respective
support. The PUT parameters are optional, including the time zone, so
existing API callers are not affected.
Dependencies:
- proxmox-widget-toolkit and pve-manager need a bumped
libpve-common-perl for the PVE::Systemd helpers
- the pve-manager GUI change needs a bumped proxmox-widget-toolkit
for the 'useJournalLog' option of the time view
pve-common:
Jonas Theisen (4):
systemd: add helpers to get and set NTP servers
systemd: add helper to query clock synchronization status
systemd: add helpers to synchronize the clock immediately
systemd: add helper to list the current NTP sources
src/PVE/Systemd.pm | 388 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 388 insertions(+)
proxmox-widget-toolkit:
Jonas Theisen (7):
node: time: do not open the editor for the server time row
partially fix #3809: node: time: show and edit NTP servers if
supported
node: time: show clock synchronization status
window: add reusable service log window
node: time: add button to open the NTP service log
node: time: add button to synchronize the clock immediately
node: time: add window listing the current NTP sources
src/Makefile | 2 +
src/node/ServiceView.js | 26 +---
src/node/TimeEdit.js | 285 ++++++++++++++++++++++++++++++++++++---
src/node/TimeView.js | 242 +++++++++++++++++++++++++++++++--
src/window/NTPSources.js | 155 +++++++++++++++++++++
src/window/ServiceLog.js | 45 +++++++
6 files changed, 704 insertions(+), 51 deletions(-)
create mode 100644 src/window/NTPSources.js
create mode 100644 src/window/ServiceLog.js
pve-manager:
Jonas Theisen (5):
partially fix #3809: api: nodes: time: allow configuring NTP servers
api: nodes: time: report clock synchronization status
ui: node: time: use journal for the NTP service log
api: nodes: time: add endpoint to synchronize the clock immediately
api: nodes: time: add endpoint to list the current NTP sources
PVE/API2/Nodes.pm | 256 +++++++++++++++++++++++++++++++++++-
www/manager6/node/Config.js | 1 +
2 files changed, 253 insertions(+), 4 deletions(-)
Summary over all repositories:
9 files changed, 1345 insertions(+), 55 deletions(-)
--
Generated by murpp 0.12.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH common 01/16] systemd: add helpers to get and set NTP servers
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
@ 2026-11-26 13:39 ` Jonas Theisen
2026-11-26 13:39 ` [PATCH common 02/16] systemd: add helper to query clock synchronization status Jonas Theisen
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:39 UTC (permalink / raw)
To: pve-devel
Allow configuring custom servers for the active NTP service.
Supported are chrony, the default on new installations, and
systemd-timesyncd. For chrony, the servers are written to a drop-in in
/etc/chrony/sources.d. Since chrony has no way to disable the default
pool from a drop-in, the pool/server/peer lines in chrony.conf are
commented out with a marker and restored once the custom servers are
removed again. For systemd-timesyncd, a drop-in setting NTP= is used,
which already takes precedence over the default servers.
NTP pools are considered separately for chrony since it is able
to distinguish between servers and pools, while timesyncd only
supports single servers.
The service is only reloaded or restarted if its configuration
actually changed. chronyd can reload the sources directory at runtime,
but needs a restart to pick up changes to chrony.conf.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/PVE/Systemd.pm | 173 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 173 insertions(+)
diff --git a/src/PVE/Systemd.pm b/src/PVE/Systemd.pm
index 1ed5271..abd3c61 100644
--- a/src/PVE/Systemd.pm
+++ b/src/PVE/Systemd.pm
@@ -13,6 +13,7 @@ use Socket qw(SOCK_DGRAM);
use PVE::Cmd qw(run);
use PVE::Exception qw(raise_param_exc);
use PVE::File qw(file_set_contents file_get_contents);
+use PVE::JSONSchema;
use PVE::Tools qw(trim);
sub escape_unit {
@@ -319,6 +320,178 @@ sub list_timezones {
return @timezones;
}
+my $ntp_lock_file = '/var/lock/proxmox-ntp.lck';
+my $chrony_conf = '/etc/chrony/chrony.conf';
+my $chrony_sources = '/etc/chrony/sources.d/proxmox.sources';
+my $timesyncd_conf_dir = '/etc/systemd/timesyncd.conf.d';
+my $timesyncd_conf = "$timesyncd_conf_dir/proxmox.conf";
+
+# Prefix for the default sources in a config file that get replaced by custom servers. It allows
+# restoring exactly those sources once the custom servers are removed again.
+my $ntp_disabled_marker = '#proxmox-disabled# ';
+
+sub get_ntp_service {
+ for my $service ('chrony', 'systemd-timesyncd') {
+ return $service if is_unit_active("${service}.service");
+ }
+ return undef;
+}
+
+# systemd-timesyncd only ever uses a single server, so it has no notion of pools
+sub is_ntp_pools_supported {
+ my ($service) = @_;
+
+ return defined($service) && $service eq 'chrony' ? 1 : 0;
+}
+
+# Returns the custom NTP servers and pools as { servers => [...], pools => [...] }, or undef if the
+# service uses its default sources.
+sub get_ntp_servers {
+ my $service = get_ntp_service() // return undef;
+
+ my $sources = { servers => [], pools => [] };
+ if ($service eq 'chrony') {
+ return undef if !-f $chrony_sources;
+
+ for my $line (split(/\n/, file_get_contents($chrony_sources))) {
+ next if $line !~ m/^\s*(server|pool)\s+(\S+)/;
+ push $sources->{ $1 eq 'pool' ? 'pools' : 'servers' }->@*, $2;
+ }
+ } elsif ($service eq 'systemd-timesyncd') {
+ return undef if !-f $timesyncd_conf;
+
+ my $ntp = read_ini($timesyncd_conf)->{Time}->{NTP} // [];
+ for my $value (ref($ntp) ? @$ntp : ($ntp)) {
+ push $sources->{servers}->@*, split(/\s+/, trim($value));
+ }
+ }
+
+ return scalar($sources->{servers}->@*) || scalar($sources->{pools}->@*) ? $sources : undef;
+}
+
+# Rewrites chrony.conf so that its default sources are disabled if $sources is defined and enabled
+# otherwise. Returns whether the file changed.
+my sub update_chrony_conf {
+ my ($sources) = @_;
+
+ my $content = file_get_contents($chrony_conf);
+ my $new_content = '';
+ for my $line (split(/^/, $content)) {
+ if (!defined($sources)) {
+ $line =~ s/^\Q$ntp_disabled_marker\E//;
+ } elsif ($line =~ m/^\s*(?:server|pool|peer)\s/) {
+ $line = "${ntp_disabled_marker}${line}";
+ }
+ $new_content .= $line;
+ }
+
+ return 0 if $new_content eq $content;
+
+ file_set_contents($chrony_conf, $new_content);
+ return 1;
+}
+
+my sub set_chrony_servers {
+ my ($sources) = @_;
+
+ my $conf_changed = update_chrony_conf($sources);
+
+ my $sources_changed = 0;
+ if (defined($sources)) {
+ my $content = join(
+ '',
+ (map { "server $_ iburst\n" } $sources->{servers}->@*),
+ (map { "pool $_ iburst\n" } $sources->{pools}->@*),
+ );
+ my $old_content = -f $chrony_sources ? file_get_contents($chrony_sources) : undef;
+ if (!defined($old_content) || $old_content ne $content) {
+ file_set_contents($chrony_sources, $content);
+ $sources_changed = 1;
+ }
+ } elsif (-f $chrony_sources) {
+ unlink($chrony_sources) or die "failed to remove '$chrony_sources' - $!\n";
+ $sources_changed = 1;
+ }
+
+ # chronyd only reads chrony.conf on startup, but can reload the sources directory at runtime
+ if ($conf_changed) {
+ run(['systemctl', 'try-restart', 'chrony.service']);
+ } elsif ($sources_changed) {
+ run(['chronyc', 'reload', 'sources'], outfunc => sub { });
+ }
+}
+
+my sub set_timesyncd_servers {
+ my ($sources) = @_;
+
+ my $changed = 0;
+ if (defined($sources)) {
+ my $content = "[Time]\nNTP=" . join(' ', $sources->{servers}->@*) . "\n";
+ my $old_content = -f $timesyncd_conf ? file_get_contents($timesyncd_conf) : undef;
+ if (!defined($old_content) || $old_content ne $content) {
+ if (!-d $timesyncd_conf_dir) {
+ mkdir($timesyncd_conf_dir) or die "failed to create '$timesyncd_conf_dir' - $!\n";
+ }
+ file_set_contents($timesyncd_conf, $content);
+ $changed = 1;
+ }
+ } elsif (-f $timesyncd_conf) {
+ unlink($timesyncd_conf) or die "failed to remove '$timesyncd_conf' - $!\n";
+ $changed = 1;
+ }
+
+ run(['systemctl', 'try-restart', 'systemd-timesyncd.service']) if $changed;
+}
+
+# Checks that the NTP servers and pools, given as for set_ntp_servers(), can be configured for the
+# active service and returns that service. Allows callers to check them before applying other
+# changes, so that a request is either applied completely or not at all.
+sub check_ntp_servers {
+ my ($servers, $pools) = @_;
+
+ my $sources = { servers => $servers // [], pools => $pools // [] };
+ for my $type ('servers', 'pools') {
+ for my $address ($sources->{$type}->@*) {
+ raise_param_exc({ "ntp-$type" => "invalid address '$address'" })
+ if !PVE::JSONSchema::pve_verify_address($address, 1);
+ }
+ }
+
+ my $service = get_ntp_service()
+ or die "no supported time synchronization service (chrony, systemd-timesyncd) active\n";
+
+ raise_param_exc({ 'ntp-pools' => "pools are not supported by $service" })
+ if scalar($sources->{pools}->@*) && !is_ntp_pools_supported($service);
+
+ return $service;
+}
+
+# Configures the custom NTP servers and pools, given as array references of addresses. If both are
+# empty or undef, the service uses its default sources again.
+sub set_ntp_servers {
+ my ($servers, $pools) = @_;
+
+ my $service = check_ntp_servers($servers, $pools);
+
+ my $sources = { servers => $servers // [], pools => $pools // [] };
+ $sources = undef if !scalar($sources->{servers}->@*) && !scalar($sources->{pools}->@*);
+
+ PVE::Tools::lock_file(
+ $ntp_lock_file,
+ 10,
+ sub {
+ if ($service eq 'chrony') {
+ set_chrony_servers($sources);
+ } elsif ($service eq 'systemd-timesyncd') {
+ set_timesyncd_servers($sources);
+ }
+ },
+ );
+ die $@ if $@;
+
+ return;
+}
+
=head3 notify()
This is a pure Perl reimplementation of systemd's C<sd_notify()> mechanism as defined in
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH common 02/16] systemd: add helper to query clock synchronization status
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
2026-11-26 13:39 ` [PATCH common 01/16] systemd: add helpers to get and set NTP servers Jonas Theisen
@ 2026-11-26 13:39 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH common 03/16] systemd: add helpers to synchronize the clock immediately Jonas Theisen
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:39 UTC (permalink / raw)
To: pve-devel
Expose whether the kernel considers the system clock synchronized, the
same information timedatectl shows as "System clock synchronized".
Querying the kernel state via timedatectl works independently of the
time synchronization service in use, so it also covers services whose
NTP servers cannot be configured through the Proxmox helpers.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/PVE/Systemd.pm | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/PVE/Systemd.pm b/src/PVE/Systemd.pm
index abd3c61..35554ce 100644
--- a/src/PVE/Systemd.pm
+++ b/src/PVE/Systemd.pm
@@ -320,6 +320,17 @@ sub list_timezones {
return @timezones;
}
+sub is_clock_synchronized {
+ my $synchronized;
+
+ run(
+ ['timedatectl', 'show', '--property=NTPSynchronized', '--value'],
+ outfunc => sub { $synchronized //= shift },
+ );
+
+ return defined($synchronized) && $synchronized eq 'yes' ? 1 : 0;
+}
+
my $ntp_lock_file = '/var/lock/proxmox-ntp.lck';
my $chrony_conf = '/etc/chrony/chrony.conf';
my $chrony_sources = '/etc/chrony/sources.d/proxmox.sources';
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH common 03/16] systemd: add helpers to synchronize the clock immediately
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
2026-11-26 13:39 ` [PATCH common 01/16] systemd: add helpers to get and set NTP servers Jonas Theisen
2026-11-26 13:39 ` [PATCH common 02/16] systemd: add helper to query clock synchronization status Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH common 04/16] systemd: add helper to list the current NTP sources Jonas Theisen
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
After changing the NTP servers or noticing that the clock is off,
admins may want to synchronize it right away instead of waiting for
the time synchronization service to correct it over time.
chrony supports this at runtime: a burst of measurements is requested
and the automatic stepping of the 'makestep' directive is re-armed
with the configured values, as described in chronyc(1). The configured
stepping usually only applies to the first clock updates after chronyd
started, so the clock is then stepped just like on startup. Using the
configured values instead of fixed ones keeps a custom stepping policy
in place, for example one that always allows stepping. Without the
directive, chronyd never steps the clock, so it is only slewed sooner.
systemd-timesyncd has no runtime command for this, but polls its
server right after starting and steps the clock if needed, so it is
restarted instead.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/PVE/Systemd.pm | 83 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/src/PVE/Systemd.pm b/src/PVE/Systemd.pm
index 35554ce..35551a3 100644
--- a/src/PVE/Systemd.pm
+++ b/src/PVE/Systemd.pm
@@ -503,6 +503,89 @@ sub set_ntp_servers {
return;
}
+sub is_ntp_sync_supported {
+ my ($service) = @_;
+
+ return 0 if !defined($service);
+ return (grep { $_ eq $service } ('chrony', 'systemd-timesyncd')) ? 1 : 0;
+}
+
+# Returns the threshold and limit of the effective 'makestep' directive of chronyd as array
+# reference, or undef if there is none. Like chronyd, this follows the 'include' and 'confdir'
+# directives in place and uses the last 'makestep' directive.
+my sub get_chrony_makestep {
+ my $makestep;
+
+ my sub parse_file {
+ use feature 'current_sub';
+ my ($file, $depth) = @_;
+
+ # chronyd refuses deeper nesting, which also prevents include loops
+ die "too deeply nested chrony configuration includes\n" if $depth > 10;
+ return if !-f $file;
+
+ for my $line (split(/\n/, file_get_contents($file))) {
+ next if $line =~ m/^\s*[!;#%]/; # comment characters of chrony.conf(5)
+ my ($directive, @args) = split(/\s+/, trim($line));
+ next if !defined($directive);
+ $directive = lc($directive);
+
+ if ($directive eq 'makestep') {
+ # use the captures, as the values are passed to chronyc, which taint mode in the
+ # API daemons only allows for untainted values
+ my ($threshold) = ($args[0] // '') =~ m/^(\d+(?:\.\d+)?)$/;
+ my ($limit) = ($args[1] // '') =~ m/^(-?\d+)$/;
+ $makestep = [$threshold, $limit] if defined($threshold) && defined($limit);
+ } elsif ($directive eq 'include' && defined($args[0])) {
+ __SUB__->($_, $depth + 1) for glob($args[0]);
+ } elsif ($directive eq 'confdir') {
+ # if multiple directories contain a file with the same name, the first one wins
+ my $files = {};
+ for my $dir (@args) {
+ for my $path (glob("$dir/*.conf")) {
+ my ($name) = $path =~ m|([^/]+)$|;
+ $files->{$name} //= $path;
+ }
+ }
+ __SUB__->($files->{$_}, $depth + 1) for sort keys $files->%*;
+ }
+ }
+ }
+ parse_file($chrony_conf, 0);
+
+ return $makestep;
+}
+
+sub sync_ntp {
+ my $service = get_ntp_service();
+
+ die "immediate synchronization is not supported for the active time synchronization service\n"
+ if !is_ntp_sync_supported($service);
+
+ PVE::Tools::lock_file(
+ $ntp_lock_file,
+ 10,
+ sub {
+ if ($service eq 'chrony') {
+ # The configured automatic stepping usually only applies to the first few clock
+ # updates after chronyd started. Re-arm it with the configured values, so the burst
+ # of measurements steps the clock exactly when chronyd would on startup, see
+ # chronyc(1). Without the directive, chronyd never steps and only slews the clock.
+ if (my $makestep = get_chrony_makestep()) {
+ run(['chronyc', 'makestep', $makestep->@*], outfunc => sub { });
+ }
+ run(['chronyc', 'burst', '1/2'], outfunc => sub { });
+ } else {
+ # timesyncd polls its server right after starting and steps the clock if needed
+ run(['systemctl', 'restart', "${service}.service"]);
+ }
+ },
+ );
+ die $@ if $@;
+
+ return;
+}
+
=head3 notify()
This is a pure Perl reimplementation of systemd's C<sd_notify()> mechanism as defined in
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH common 04/16] systemd: add helper to list the current NTP sources
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (2 preceding siblings ...)
2026-11-26 13:40 ` [PATCH common 03/16] systemd: add helpers to synchronize the clock immediately Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 05/16] node: time: do not open the editor for the server time row Jonas Theisen
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
To be able to provide a detailed state of the local clock
versus the clock sources this commit introduces the helpers
to get an overview.
This includes the currently used sources, their state and
the offset between each source.
For chrony, the machine-readable output of 'chronyc -c sources' is
parsed. It is queried twice, once for the numeric addresses and once
for the names the sources were configured with, so that pool members
can be attributed to their pool. For systemd-timesyncd, which only
ever uses a single server, the output of 'timedatectl timesync-status'
is parsed, as the machine-readable variant does not include the
offset.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/PVE/Systemd.pm | 121 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 121 insertions(+)
diff --git a/src/PVE/Systemd.pm b/src/PVE/Systemd.pm
index 35551a3..5d33ea4 100644
--- a/src/PVE/Systemd.pm
+++ b/src/PVE/Systemd.pm
@@ -586,6 +586,127 @@ sub sync_ntp {
return;
}
+sub is_ntp_sources_supported {
+ my ($service) = @_;
+
+ return 0 if !defined($service);
+ return (grep { $_ eq $service } ('chrony', 'systemd-timesyncd')) ? 1 : 0;
+}
+
+my sub get_chrony_sources {
+ my $read_sources = sub {
+ my ($option) = @_;
+ my $rows = [];
+ run(
+ ['chronyc', '-c', $option, 'sources'],
+ outfunc => sub { push @$rows, [split(/,/, shift)] },
+ );
+ return $rows;
+ };
+
+ # '-n' prints the numeric addresses, '-N' the names the sources were configured with, e.g. the
+ # name of the pool for all of its members
+ my $rows = $read_sources->('-n');
+ my $names = $read_sources->('-N');
+ $names = [] if scalar(@$names) != scalar(@$rows); # the sources changed in between
+
+ my $states = {
+ '*' => 'selected',
+ '+' => 'combined',
+ '-' => 'candidate',
+ 'x' => 'falseticker',
+ '~' => 'unusable', # too variable
+ '?' => 'unusable', # e.g. unreachable or not enough measurements yet
+ };
+
+ my $sources = [];
+ for my $i (0 .. $#$rows) {
+ my ($mode, $state, $address, $stratum, $poll, $reach, $last_rx, $offset) = $rows->[$i]->@*;
+ next if !defined($offset);
+
+ my $source = {
+ address => $address,
+ state => $states->{$state} // 'unusable',
+ stratum => int($stratum),
+ poll => 2**$poll, # logarithm to base 2
+ reach => oct($reach), # octal
+ offset => $offset + 0,
+ };
+ # never received samples are reported with the maximum unsigned 32-bit value
+ $source->{'last-rx'} = int($last_rx) if $last_rx =~ m/^\d+$/ && $last_rx < 0xffffffff;
+
+ my $name = $names->[$i]->[2];
+ $source->{name} = $name if defined($name) && $name ne $address;
+
+ push @$sources, $source;
+ }
+
+ return $sources;
+}
+
+# Converts a time span as printed by systemd, e.g. '-1.234ms' or '34min 8s', to seconds.
+my sub parse_systemd_timespan {
+ my ($text) = @_;
+
+ my $factors = { us => 1e-6, ms => 1e-3, s => 1, min => 60, h => 3600, d => 86400 };
+
+ my $sign = $text =~ s/^([+-])// && $1 eq '-' ? -1 : 1;
+ my $seconds;
+ while ($text =~ m/\G\s*(\d+(?:\.\d+)?)(min|ms|us|s|h|d)\b/gc) {
+ $seconds += $1 * $factors->{$2};
+ }
+ return undef if !defined($seconds) || pos($text) != length($text);
+
+ return $sign * $seconds;
+}
+
+# timesyncd only reports the server it currently uses
+my sub get_timesyncd_sources {
+ my $status = {};
+ run(
+ ['timedatectl', 'timesync-status', '--no-pager'],
+ outfunc => sub {
+ my ($line) = @_;
+ $status->{ lc($1) } = $2 if $line =~ m/^\s*([^:]+?):\s*(.*?)\s*$/;
+ },
+ );
+
+ my ($address, $name) = ($status->{server} // '') =~ m/^(\S+)(?:\s+\((.*)\))?$/;
+ return [] if !defined($address) || $address eq 'n/a';
+
+ my $source = { address => $address, state => 'unusable' };
+ $source->{name} = $name if defined($name) && $name ne $address;
+ $source->{stratum} = int($1) if ($status->{stratum} // '') =~ m/^(\d+)$/;
+
+ # e.g. '34min 8s (min: 32s; max 34min 8s)'
+ if (($status->{'poll interval'} // '') =~ m/^(.*?)\s*\(/) {
+ my $poll = parse_systemd_timespan($1);
+ $source->{poll} = $poll if defined($poll);
+ }
+
+ # Only reported once a sample was received. timesyncd reports the offset of the source to the
+ # local clock, while chrony reports it the other way round, i.e. positive if the local clock is
+ # ahead, so flip it to match.
+ my $offset = parse_systemd_timespan($status->{offset} // '');
+ if (defined($offset)) {
+ $source->{offset} = -$offset;
+ $source->{state} = 'selected';
+ }
+
+ return [$source];
+}
+
+# Returns the sources the active time synchronization service currently uses, including the
+# members of pools, see is_ntp_sources_supported() for the supported services.
+sub get_ntp_sources {
+ my $service = get_ntp_service();
+
+ die "listing the sources is not supported for the active time synchronization service\n"
+ if !is_ntp_sources_supported($service);
+
+ return $service eq 'chrony' ? get_chrony_sources() : get_timesyncd_sources();
+}
+
=head3 notify()
This is a pure Perl reimplementation of systemd's C<sd_notify()> mechanism as defined in
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH widget-toolkit 05/16] node: time: do not open the editor for the server time row
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (3 preceding siblings ...)
2026-11-26 13:40 ` [PATCH common 04/16] systemd: add helper to list the current NTP sources Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 06/16] partially fix #3809: node: time: show and edit NTP servers if supported Jonas Theisen
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
The server time cannot be edited, so opening the edit window when
double clicking or pressing enter on its row is unexpected. Do nothing
for this row instead.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/node/TimeView.js | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/node/TimeView.js b/src/node/TimeView.js
index cb74585..20214eb 100644
--- a/src/node/TimeView.js
+++ b/src/node/TimeView.js
@@ -23,11 +23,19 @@ Ext.define('Proxmox.node.TimeView', {
win.on('destroy', me.reload, me);
};
+ // the server time is read-only, so its row has no action
+ let run_row_action = () => {
+ let key = me.getSelectionModel().getSelection()[0]?.data.key;
+ if (key !== 'localtime') {
+ run_editor();
+ }
+ };
+
Ext.apply(me, {
url: `/api2/json/nodes/${me.nodename}/time`,
cwidth1: 150,
interval: 1000,
- run_editor: run_editor,
+ run_editor: run_row_action,
rows: {
timezone: {
header: gettext('Time zone'),
@@ -46,7 +54,7 @@ Ext.define('Proxmox.node.TimeView', {
},
],
listeners: {
- itemdblclick: run_editor,
+ itemdblclick: run_row_action,
},
});
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH widget-toolkit 06/16] partially fix #3809: node: time: show and edit NTP servers if supported
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (4 preceding siblings ...)
2026-11-26 13:40 ` [PATCH widget-toolkit 05/16] node: time: do not open the editor for the server time row Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 07/16] node: time: show clock synchronization status Jonas Theisen
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Add rows for the active NTP service and its custom sources to the time
view, and a table to the edit window, where sources can be added and
removed, each with a type selector for server or pool. They are only
shown if the API reports a supported time synchronization service, as
the components are shared with products whose time API does not
provide NTP settings.
The view shows the custom servers and pools together in one row, with
pools marked as such. The API returns neither if the service uses its
default sources, so the row gets an empty default value, which is
shown as "Default". It needs a separate filter to stay hidden without
a supported service, and an explicit sorter to keep the row order, as
rows with a default value are added before the first load.
The table is submitted as the separate server and pool parameters of
the API. The type selector is hidden if the API reports that the
service does not support pools, like systemd-timesyncd. Removing all
sources resets the service to its default sources. As the edit window
is no longer only about the time zone, change its title to "Time
settings".
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/node/TimeEdit.js | 285 ++++++++++++++++++++++++++++++++++++++++---
src/node/TimeView.js | 64 ++++++++--
2 files changed, 322 insertions(+), 27 deletions(-)
diff --git a/src/node/TimeEdit.js b/src/node/TimeEdit.js
index 2238a41..9624973 100644
--- a/src/node/TimeEdit.js
+++ b/src/node/TimeEdit.js
@@ -1,28 +1,281 @@
+// Edits the custom NTP servers and pools as one list, submitted as the 'ntp-servers' and
+// 'ntp-pools' parameters. An empty list resets the service to its default sources.
+Ext.define('Proxmox.form.NTPSourceList', {
+ extend: 'Ext.form.FieldContainer',
+ alias: 'widget.proxmoxNTPSourceList',
+
+ mixins: ['Ext.form.field.Field'],
+
+ isFormField: true,
+
+ // list of { type: 'server' | 'pool', address }
+ setValue: function (list) {
+ let me = this;
+
+ // copy, as the store uses the objects as record data and adds an id to them, which would
+ // modify the original value used for the dirty tracking
+ me.lookup('grid')
+ .getStore()
+ .setData((list ?? []).map(({ type, address }) => ({ type, address })));
+ me.checkChange();
+ return me;
+ },
+
+ getValue: function () {
+ let me = this;
+
+ let list = [];
+ me.lookup('grid')
+ .getStore()
+ .each((rec) => {
+ list.push({ type: rec.data.type, address: rec.data.address });
+ });
+ return list;
+ },
+
+ // the default compares the string representation, which is the same for all lists of objects
+ // with the same length
+ isEqual: function (value1, value2) {
+ return JSON.stringify(value1) === JSON.stringify(value2);
+ },
+
+ getErrors: function () {
+ let me = this;
+
+ let errors = [];
+ me.lookup('grid')
+ .getStore()
+ .each((rec) => {
+ let address = rec.data.address ?? '';
+ if (address === '' || !Ext.form.field.VTypes.DnsOrIp(address)) {
+ errors.push(Ext.form.field.VTypes.DnsOrIpText);
+ return false;
+ }
+ return true;
+ });
+ return errors;
+ },
+
+ getSubmitData: function () {
+ let me = this;
+
+ if (me.disabled || !me.submitValue) {
+ return null;
+ }
+
+ let addresses = { 'ntp-servers': [], 'ntp-pools': [] };
+ for (const { type, address } of me.getValue()) {
+ addresses[type === 'pool' ? 'ntp-pools' : 'ntp-servers'].push(address);
+ }
+
+ let data = {};
+ let deletes = [];
+ for (const [param, list] of Object.entries(addresses)) {
+ if (list.length) {
+ data[param] = list.join(',');
+ } else {
+ deletes.push(param);
+ }
+ }
+ if (deletes.length) {
+ data.delete = deletes;
+ }
+ return data;
+ },
+
+ // without pool support, all sources are servers, so there is nothing to choose
+ setPoolsSupported: function (supported) {
+ let me = this;
+ me.lookup('typeColumn').setHidden(!supported);
+ },
+
+ controller: {
+ xclass: 'Ext.app.ViewController',
+
+ addSource: function () {
+ let me = this;
+ me.lookup('grid').getStore().add({ type: 'server', address: '' });
+ me.getView().checkChange();
+ me.getView().validate();
+ },
+
+ removeSource: function (button) {
+ let me = this;
+ let record = button.getWidgetRecord();
+ if (record === undefined) {
+ // this is sometimes called before a record/column is initialized
+ return;
+ }
+ me.lookup('grid').getStore().remove(record);
+ me.getView().checkChange();
+ me.getView().validate();
+ },
+
+ itemChange: function (field, newValue) {
+ let me = this;
+ let record = field.getWidgetRecord();
+ if (!record) {
+ return;
+ }
+ record.set(field.getWidgetColumn().dataIndex, newValue);
+ me.getView().checkChange();
+ me.getView().validate();
+ },
+
+ control: {
+ 'grid button': {
+ click: 'removeSource',
+ },
+ },
+ },
+
+ initComponent: function () {
+ let me = this;
+
+ Ext.apply(me, {
+ items: [
+ {
+ xtype: 'grid',
+ reference: 'grid',
+ height: 150,
+ scrollable: 'vertical',
+ margin: '0 0 5 0',
+ viewConfig: {
+ deferEmptyText: false,
+ emptyText: gettext('Default sources of the service'),
+ },
+ store: {
+ fields: ['type', 'address'],
+ listeners: {
+ update: function () {
+ this.commitChanges();
+ },
+ },
+ },
+ columns: [
+ {
+ header: gettext('Type'),
+ reference: 'typeColumn',
+ dataIndex: 'type',
+ xtype: 'widgetcolumn',
+ width: 110,
+ widget: {
+ xtype: 'proxmoxKVComboBox',
+ isFormField: false,
+ comboItems: [
+ ['server', gettext('Server')],
+ ['pool', gettext('Pool')],
+ ],
+ listeners: {
+ change: 'itemChange',
+ },
+ },
+ },
+ {
+ header: gettext('Address'),
+ dataIndex: 'address',
+ xtype: 'widgetcolumn',
+ flex: 1,
+ widget: {
+ xtype: 'textfield',
+ isFormField: false,
+ allowBlank: false,
+ vtype: 'DnsOrIp', // matches the 'address' format of the API
+ emptyText: gettext('Host name or IP address'),
+ listeners: {
+ change: 'itemChange',
+ },
+ },
+ onWidgetAttach: function (_col, widget) {
+ widget.isValid();
+ },
+ },
+ {
+ xtype: 'widgetcolumn',
+ width: 40,
+ widget: {
+ xtype: 'button',
+ iconCls: 'fa fa-trash-o',
+ },
+ },
+ ],
+ },
+ {
+ xtype: 'button',
+ text: gettext('Add'),
+ iconCls: 'fa fa-plus-circle',
+ handler: 'addSource',
+ },
+ ],
+ });
+
+ me.callParent();
+ me.initField();
+ },
+});
+
Ext.define('Proxmox.node.TimeEdit', {
extend: 'Proxmox.window.Edit',
alias: ['widget.proxmoxNodeTimeEdit'],
- subject: gettext('Time zone'),
+ subject: gettext('Time settings'),
- width: 400,
+ width: 550,
autoLoad: true,
fieldDefaults: {
- labelWidth: 70,
- },
-
- items: {
- xtype: 'combo',
- fieldLabel: gettext('Time zone'),
- name: 'timezone',
- queryMode: 'local',
- store: Ext.create('Proxmox.data.TimezoneStore'),
- displayField: 'zone',
- editable: true,
- anyMatch: true,
- forceSelection: true,
- allowBlank: false,
+ labelWidth: 90,
+ },
+
+ items: [
+ {
+ xtype: 'combo',
+ fieldLabel: gettext('Time zone'),
+ name: 'timezone',
+ queryMode: 'local',
+ store: Ext.create('Proxmox.data.TimezoneStore'),
+ displayField: 'zone',
+ editable: true,
+ anyMatch: true,
+ forceSelection: true,
+ allowBlank: false,
+ },
+ {
+ // shown once the loaded data says configuring NTP sources is supported
+ xtype: 'proxmoxNTPSourceList',
+ fieldLabel: gettext('NTP sources'),
+ name: 'ntp-sources',
+ hidden: true,
+ disabled: true,
+ },
+ ],
+
+ setValues: function (values) {
+ let me = this;
+
+ let supported = !!values['ntp-service'];
+ let sourceList = me.down('proxmoxNTPSourceList');
+ sourceList.setVisible(supported);
+ sourceList.setDisabled(!supported);
+ sourceList.setPoolsSupported(!!values['ntp-pools-supported']);
+
+ // set through the parent, so that the loaded list becomes the original value for the dirty
+ // tracking and resetting of the form
+ let toList = (value, type) =>
+ (value ?? '')
+ .split(',')
+ .filter((address) => address !== '')
+ .map((address) => ({ type, address }));
+ values = {
+ ...values,
+ 'ntp-sources': [
+ ...toList(values['ntp-servers'], 'server'),
+ ...toList(values['ntp-pools'], 'pool'),
+ ],
+ };
+
+ me.callParent([values]);
},
initComponent: function () {
diff --git a/src/node/TimeView.js b/src/node/TimeView.js
index 20214eb..35ac72f 100644
--- a/src/node/TimeView.js
+++ b/src/node/TimeView.js
@@ -14,6 +14,7 @@ Ext.define('Proxmox.node.TimeView', {
let servertime = new Date(value * 1000 + tzOffset);
return Ext.Date.format(servertime, 'Y-m-d H:i:s');
};
+ let splitList = (value) => (value ?? '').split(',').filter((item) => item !== '');
let run_editor = () => {
let win = Ext.create('Proxmox.node.TimeEdit', {
@@ -23,6 +24,8 @@ Ext.define('Proxmox.node.TimeView', {
win.on('destroy', me.reload, me);
};
+ let get_ntp_service = () => me.rstore.getById('ntp-service')?.data.value;
+
// the server time is read-only, so its row has no action
let run_row_action = () => {
let key = me.getSelectionModel().getSelection()[0]?.data.key;
@@ -31,22 +34,55 @@ Ext.define('Proxmox.node.TimeView', {
}
};
+ let rows = {
+ timezone: {
+ header: gettext('Time zone'),
+ required: true,
+ },
+ localtime: {
+ header: gettext('Server time'),
+ required: true,
+ renderer: renderLocaltime,
+ },
+ // only returned if configuring NTP servers is supported
+ 'ntp-service': {
+ header: gettext('NTP service'),
+ renderer: Ext.htmlEncode,
+ },
+ // Shows the custom servers and pools together. It is keyed on the servers, as their row
+ // always exists through the empty default value, while neither is returned if the
+ // service uses its default sources. The filter below hides it if there is no NTP
+ // service.
+ 'ntp-servers': {
+ header: gettext('NTP sources'),
+ defaultValue: '',
+ renderer: function (servers) {
+ let pools = me.rstore.getById('ntp-pools')?.data.value;
+ let sources = [
+ ...splitList(servers),
+ ...splitList(pools).map((pool) => `${pool} (${gettext('Pool')})`),
+ ];
+ if (!sources.length) {
+ return Proxmox.Utils.defaultText;
+ }
+ return Ext.htmlEncode(sources.join(', '));
+ },
+ },
+ // the reader drops keys without a row, keep it in the store for the renderer above
+ 'ntp-pools': {
+ visible: false,
+ },
+ };
+ let rowOrder = Object.keys(rows);
+
Ext.apply(me, {
url: `/api2/json/nodes/${me.nodename}/time`,
cwidth1: 150,
interval: 1000,
run_editor: run_row_action,
- rows: {
- timezone: {
- header: gettext('Time zone'),
- required: true,
- },
- localtime: {
- header: gettext('Server time'),
- required: true,
- renderer: renderLocaltime,
- },
- },
+ rows: rows,
+ // rows with a default value are added before the first load, keep the defined order
+ sorterFn: (a, b) => rowOrder.indexOf(a.data.key) - rowOrder.indexOf(b.data.key),
tbar: [
{
text: gettext('Edit'),
@@ -60,6 +96,12 @@ Ext.define('Proxmox.node.TimeView', {
me.callParent();
+ me.store.filters.add(
+ Ext.create('Ext.util.Filter', {
+ filterFn: (item) => item.data.key !== 'ntp-servers' || !!get_ntp_service(),
+ }),
+ );
+
me.on('activate', me.rstore.startUpdate);
me.on('deactivate', me.rstore.stopUpdate);
me.on('destroy', me.rstore.stopUpdate);
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH widget-toolkit 07/16] node: time: show clock synchronization status
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (5 preceding siblings ...)
2026-11-26 13:40 ` [PATCH widget-toolkit 06/16] partially fix #3809: node: time: show and edit NTP servers if supported Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 08/16] window: add reusable service log window Jonas Theisen
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Show whether the system clock is synchronized in the time view. The
row is only shown if the API reports the status, as the view is shared
with products whose time API does not provide it.
Like the server time, the status is read-only, so double clicking
or pressing enter on its row does not open the editor.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/node/TimeView.js | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/node/TimeView.js b/src/node/TimeView.js
index 35ac72f..ca08f98 100644
--- a/src/node/TimeView.js
+++ b/src/node/TimeView.js
@@ -26,10 +26,10 @@ Ext.define('Proxmox.node.TimeView', {
let get_ntp_service = () => me.rstore.getById('ntp-service')?.data.value;
- // the server time is read-only, so its row has no action
+ // the rows with read-only status information have no action
let run_row_action = () => {
let key = me.getSelectionModel().getSelection()[0]?.data.key;
- if (key !== 'localtime') {
+ if (key !== 'localtime' && key !== 'ntp-synchronized') {
run_editor();
}
};
@@ -72,6 +72,10 @@ Ext.define('Proxmox.node.TimeView', {
'ntp-pools': {
visible: false,
},
+ 'ntp-synchronized': {
+ header: gettext('Clock synchronized'),
+ renderer: Proxmox.Utils.format_boolean,
+ },
};
let rowOrder = Object.keys(rows);
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH widget-toolkit 08/16] window: add reusable service log window
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (6 preceding siblings ...)
2026-11-26 13:40 ` [PATCH widget-toolkit 07/16] node: time: show clock synchronization status Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 09/16] node: time: add button to open the NTP service log Jonas Theisen
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Move the window showing the log of a service out of the service view
into its own class, so other components can open the log of a service
the same way.
No functional change intended.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/Makefile | 1 +
src/node/ServiceView.js | 26 ++++-------------------
src/window/ServiceLog.js | 45 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 22 deletions(-)
create mode 100644 src/window/ServiceLog.js
diff --git a/src/Makefile b/src/Makefile
index d5e246c..24bd719 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -90,6 +90,7 @@ JSSRC= \
window/SafeDestroy.js \
window/PackageVersions.js \
window/PackageChangelog.js \
+ window/ServiceLog.js \
window/TaskViewer.js \
window/LanguageEdit.js \
window/DiskSmart.js \
diff --git a/src/node/ServiceView.js b/src/node/ServiceView.js
index 2a51f17..bf49607 100644
--- a/src/node/ServiceView.js
+++ b/src/node/ServiceView.js
@@ -67,28 +67,10 @@ Ext.define('Proxmox.node.ServiceView', {
data: { service },
} = me.getSelectionModel().getSelection()[0];
- let viewSize = Ext.getBody().getViewSize();
-
- let logItem = me.useJournalLog
- ? {
- xtype: 'proxmoxJournalView',
- structured: true,
- unit: service,
- url: `/api2/extjs/nodes/${me.nodename}/journal`,
- }
- : {
- xtype: 'proxmoxLogView',
- url: `/api2/extjs/nodes/${me.nodename}/syslog?service=${service}`,
- log_select_timespan: 1,
- };
-
- Ext.create('Ext.window.Window', {
- title: gettext('System Log') + ': ' + service,
- modal: true,
- width: viewSize.width > 1600 ? 1000 : 800,
- height: viewSize.height > 900 ? 800 : 600,
- layout: 'fit',
- items: logItem,
+ Ext.create('Proxmox.window.ServiceLog', {
+ nodename: me.nodename,
+ service: service,
+ useJournalLog: me.useJournalLog,
autoShow: true,
});
};
diff --git a/src/window/ServiceLog.js b/src/window/ServiceLog.js
new file mode 100644
index 0000000..e962a36
--- /dev/null
+++ b/src/window/ServiceLog.js
@@ -0,0 +1,45 @@
+Ext.define('Proxmox.window.ServiceLog', {
+ extend: 'Ext.window.Window',
+ alias: 'widget.proxmoxServiceLog',
+
+ modal: true,
+ layout: 'fit',
+
+ // use the journal API endpoint instead of the syslog one
+ useJournalLog: false,
+
+ initComponent: function () {
+ let me = this;
+
+ if (!me.nodename) {
+ throw 'no node name specified';
+ }
+ if (!me.service) {
+ throw 'no service specified';
+ }
+
+ let viewSize = Ext.getBody().getViewSize();
+
+ let logItem = me.useJournalLog
+ ? {
+ xtype: 'proxmoxJournalView',
+ structured: true,
+ unit: me.service,
+ url: `/api2/extjs/nodes/${me.nodename}/journal`,
+ }
+ : {
+ xtype: 'proxmoxLogView',
+ url: `/api2/extjs/nodes/${me.nodename}/syslog?service=${me.service}`,
+ log_select_timespan: 1,
+ };
+
+ Ext.apply(me, {
+ title: gettext('System Log') + ': ' + me.service,
+ width: viewSize.width > 1600 ? 1000 : 800,
+ height: viewSize.height > 900 ? 800 : 600,
+ items: logItem,
+ });
+
+ me.callParent();
+ },
+});
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH widget-toolkit 09/16] node: time: add button to open the NTP service log
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (7 preceding siblings ...)
2026-11-26 13:40 ` [PATCH widget-toolkit 08/16] window: add reusable service log window Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 10/16] node: time: add button to synchronize the clock immediately Jonas Theisen
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Allow opening the log of the active NTP service directly from the time
view, for example to check why the clock is not synchronized after
changing the NTP servers, without having to look up the service in the
service list first.
The button is only shown if the API reports a supported NTP service,
as the view is shared with products whose time API does not provide
it. Like the service view, the time view can be configured to use the
journal instead of the syslog API endpoint.
Double clicking or pressing enter on the NTP service row opens the log
as well, as the edit window does not allow changing the service.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/node/TimeView.js | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/node/TimeView.js b/src/node/TimeView.js
index ca08f98..b2c4d68 100644
--- a/src/node/TimeView.js
+++ b/src/node/TimeView.js
@@ -2,6 +2,9 @@ Ext.define('Proxmox.node.TimeView', {
extend: 'Proxmox.grid.ObjectGrid',
alias: ['widget.proxmoxNodeTimeView'],
+ // show the NTP service log from the journal API endpoint instead of the syslog one
+ useJournalLog: false,
+
initComponent: function () {
let me = this;
@@ -26,14 +29,32 @@ Ext.define('Proxmox.node.TimeView', {
let get_ntp_service = () => me.rstore.getById('ntp-service')?.data.value;
- // the rows with read-only status information have no action
+ let view_service_log = () =>
+ Ext.create('Proxmox.window.ServiceLog', {
+ nodename: me.nodename,
+ service: get_ntp_service(),
+ useJournalLog: me.useJournalLog,
+ autoShow: true,
+ });
+
+ // double click or enter on the NTP service row shows its log instead of the editor, the rows
+ // with read-only status information have no action
let run_row_action = () => {
let key = me.getSelectionModel().getSelection()[0]?.data.key;
- if (key !== 'localtime' && key !== 'ntp-synchronized') {
+ if (key === 'ntp-service') {
+ view_service_log();
+ } else if (key !== 'localtime' && key !== 'ntp-synchronized') {
run_editor();
}
};
+ // only shown if the API reports a supported NTP service
+ let syslog_btn = new Ext.Button({
+ text: gettext('Service System Log'),
+ hidden: true,
+ handler: view_service_log,
+ });
+
let rows = {
timezone: {
header: gettext('Time zone'),
@@ -92,6 +113,7 @@ Ext.define('Proxmox.node.TimeView', {
text: gettext('Edit'),
handler: run_editor,
},
+ syslog_btn,
],
listeners: {
itemdblclick: run_row_action,
@@ -106,6 +128,8 @@ Ext.define('Proxmox.node.TimeView', {
}),
);
+ me.mon(me.rstore, 'load', () => syslog_btn.setVisible(!!get_ntp_service()));
+
me.on('activate', me.rstore.startUpdate);
me.on('deactivate', me.rstore.stopUpdate);
me.on('destroy', me.rstore.stopUpdate);
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH widget-toolkit 10/16] node: time: add button to synchronize the clock immediately
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (8 preceding siblings ...)
2026-11-26 13:40 ` [PATCH widget-toolkit 09/16] node: time: add button to open the NTP service log Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 11/16] node: time: add window listing the current NTP sources Jonas Theisen
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Add a "Sync now" button to the time view, so admins can synchronize
the clock right away, for example after changing the NTP servers.
It asks for confirmation first, as the clock may jump or the service
may be restarted. If the API reports that the node is part of a
cluster, the confirmation warns about the consequences and the
synchronization can only be started after explicitly checking a box,
as clock jumps can severely disrupt services that rely on synchronized
clocks across all nodes, such as Ceph. Only then is the 'force'
parameter passed, which the API requires on cluster nodes.
The button is only shown if the API reports that the active time
synchronization service supports it, which also keeps it hidden for
products whose time API does not provide it.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/node/TimeView.js | 114 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 113 insertions(+), 1 deletion(-)
diff --git a/src/node/TimeView.js b/src/node/TimeView.js
index b2c4d68..0c08e31 100644
--- a/src/node/TimeView.js
+++ b/src/node/TimeView.js
@@ -55,6 +55,107 @@ Ext.define('Proxmox.node.TimeView', {
handler: view_service_log,
});
+ // the API refuses to synchronize a cluster node unless forced
+ let sync_now = (force) =>
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${me.nodename}/time/sync`,
+ method: 'POST',
+ params: force ? { force: 1 } : {},
+ waitMsgTarget: me,
+ failure: (response) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+ success: () => me.rstore.load(),
+ });
+
+ // Clock jumps can severely disrupt a cluster, so there the user has to explicitly
+ // acknowledge that before the synchronization can be started.
+ let confirm_sync = () => {
+ let clustered = !!me.rstore.getById('clustered')?.data.value;
+
+ let message = Ext.htmlEncode(
+ gettext(
+ 'Synchronize the system clock now? Depending on the configuration of the time synchronization service, the clock may jump instead of being adjusted gradually.',
+ ),
+ );
+ if (clustered) {
+ message +=
+ '<br><br>' +
+ Ext.htmlEncode(
+ gettext(
+ 'This node is part of a cluster. Jumps of the system clock can severely disrupt services that rely on synchronized clocks across all nodes, such as Ceph.',
+ ),
+ );
+ }
+
+ let win = Ext.create('Ext.window.Window', {
+ title: gettext('Confirm'),
+ modal: true,
+ width: 450,
+ bodyPadding: 10,
+ buttonAlign: 'center',
+ layout: 'hbox',
+ items: [
+ {
+ xtype: 'component',
+ cls: [
+ Ext.baseCSSPrefix + 'message-box-icon',
+ Ext.baseCSSPrefix + 'dlg-icon',
+ Ext.baseCSSPrefix +
+ (clustered ? 'message-box-warning' : 'message-box-question'),
+ ],
+ },
+ {
+ xtype: 'container',
+ flex: 1,
+ layout: {
+ type: 'vbox',
+ align: 'stretch',
+ },
+ items: [
+ {
+ xtype: 'component',
+ html: message,
+ },
+ {
+ xtype: 'checkbox',
+ hidden: !clustered,
+ margin: '10 0 0 0',
+ boxLabel: gettext(
+ 'I understand that a clock jump can disrupt the cluster.',
+ ),
+ listeners: {
+ change: (_checkbox, checked) =>
+ win.down('#confirmButton').setDisabled(!checked),
+ },
+ },
+ ],
+ },
+ ],
+ buttons: [
+ {
+ itemId: 'confirmButton',
+ text: gettext('Sync now'),
+ disabled: clustered,
+ handler: () => {
+ win.close();
+ sync_now(clustered);
+ },
+ },
+ {
+ text: gettext('Cancel'),
+ handler: () => win.close(),
+ },
+ ],
+ });
+ win.show();
+ };
+
+ // only shown if the API reports that the NTP service supports it
+ let sync_btn = new Ext.Button({
+ text: gettext('Sync now'),
+ hidden: true,
+ handler: confirm_sync,
+ });
+
let rows = {
timezone: {
header: gettext('Time zone'),
@@ -93,6 +194,13 @@ Ext.define('Proxmox.node.TimeView', {
'ntp-pools': {
visible: false,
},
+ // the reader drops keys without a row, keep them in the store for the sync button
+ 'ntp-sync-supported': {
+ visible: false,
+ },
+ clustered: {
+ visible: false,
+ },
'ntp-synchronized': {
header: gettext('Clock synchronized'),
renderer: Proxmox.Utils.format_boolean,
@@ -113,6 +221,7 @@ Ext.define('Proxmox.node.TimeView', {
text: gettext('Edit'),
handler: run_editor,
},
+ sync_btn,
syslog_btn,
],
listeners: {
@@ -128,7 +237,10 @@ Ext.define('Proxmox.node.TimeView', {
}),
);
- me.mon(me.rstore, 'load', () => syslog_btn.setVisible(!!get_ntp_service()));
+ me.mon(me.rstore, 'load', () => {
+ syslog_btn.setVisible(!!get_ntp_service());
+ sync_btn.setVisible(!!me.rstore.getById('ntp-sync-supported')?.data.value);
+ });
me.on('activate', me.rstore.startUpdate);
me.on('deactivate', me.rstore.stopUpdate);
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH widget-toolkit 11/16] node: time: add window listing the current NTP sources
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (9 preceding siblings ...)
2026-11-26 13:40 ` [PATCH widget-toolkit 10/16] node: time: add button to synchronize the clock immediately Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 12/16] partially fix #3809: api: nodes: time: allow configuring NTP servers Jonas Theisen
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Add a "Sources" button to the time view that opens a window listing
the sources the time synchronization service currently uses, including
the members of pools, with their selection state, stratum, polling
interval, reachability, age of the last sample and offset. This helps
to find out why the clock is not synchronized, or how far off a node
is compared to its sources. Double clicking the clock synchronization
row opens the window as well.
The list refreshes every five seconds while the window is open. The
button and the row action are only available if the API reports that
the active service supports listing its sources, which also keeps them
hidden for products whose time API does not provide it.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/Makefile | 1 +
src/node/TimeView.js | 32 +++++++-
src/window/NTPSources.js | 155 +++++++++++++++++++++++++++++++++++++++
3 files changed, 185 insertions(+), 3 deletions(-)
create mode 100644 src/window/NTPSources.js
diff --git a/src/Makefile b/src/Makefile
index 24bd719..72bac69 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -91,6 +91,7 @@ JSSRC= \
window/PackageVersions.js \
window/PackageChangelog.js \
window/ServiceLog.js \
+ window/NTPSources.js \
window/TaskViewer.js \
window/LanguageEdit.js \
window/DiskSmart.js \
diff --git a/src/node/TimeView.js b/src/node/TimeView.js
index 0c08e31..ecae553 100644
--- a/src/node/TimeView.js
+++ b/src/node/TimeView.js
@@ -37,13 +37,26 @@ Ext.define('Proxmox.node.TimeView', {
autoShow: true,
});
- // double click or enter on the NTP service row shows its log instead of the editor, the rows
- // with read-only status information have no action
+ let sources_supported = () => !!me.rstore.getById('ntp-sources-supported')?.data.value;
+
+ let view_sources = () =>
+ Ext.create('Proxmox.window.NTPSources', {
+ nodename: me.nodename,
+ autoShow: true,
+ });
+
+ // Double click or enter on the NTP service row shows its log instead of the editor, and on
+ // the clock synchronization row the sources it is synchronized to, if supported. The rows
+ // with read-only status information have no action otherwise.
let run_row_action = () => {
let key = me.getSelectionModel().getSelection()[0]?.data.key;
if (key === 'ntp-service') {
view_service_log();
- } else if (key !== 'localtime' && key !== 'ntp-synchronized') {
+ } else if (key === 'ntp-synchronized') {
+ if (sources_supported()) {
+ view_sources();
+ }
+ } else if (key !== 'localtime') {
run_editor();
}
};
@@ -156,6 +169,13 @@ Ext.define('Proxmox.node.TimeView', {
handler: confirm_sync,
});
+ // only shown if the API reports that the NTP service supports it
+ let sources_btn = new Ext.Button({
+ text: gettext('Sources'),
+ hidden: true,
+ handler: view_sources,
+ });
+
let rows = {
timezone: {
header: gettext('Time zone'),
@@ -201,6 +221,10 @@ Ext.define('Proxmox.node.TimeView', {
clustered: {
visible: false,
},
+ // same for the sources button
+ 'ntp-sources-supported': {
+ visible: false,
+ },
'ntp-synchronized': {
header: gettext('Clock synchronized'),
renderer: Proxmox.Utils.format_boolean,
@@ -222,6 +246,7 @@ Ext.define('Proxmox.node.TimeView', {
handler: run_editor,
},
sync_btn,
+ sources_btn,
syslog_btn,
],
listeners: {
@@ -240,6 +265,7 @@ Ext.define('Proxmox.node.TimeView', {
me.mon(me.rstore, 'load', () => {
syslog_btn.setVisible(!!get_ntp_service());
sync_btn.setVisible(!!me.rstore.getById('ntp-sync-supported')?.data.value);
+ sources_btn.setVisible(sources_supported());
});
me.on('activate', me.rstore.startUpdate);
diff --git a/src/window/NTPSources.js b/src/window/NTPSources.js
new file mode 100644
index 0000000..178bfbb
--- /dev/null
+++ b/src/window/NTPSources.js
@@ -0,0 +1,155 @@
+Ext.define('proxmox-ntp-sources', {
+ extend: 'Ext.data.Model',
+ // not every service reports all values, keep missing ones null instead of converting to 0
+ fields: [
+ 'address',
+ 'name',
+ {
+ name: 'state',
+ // sort by how usable the source is, instead of alphabetically
+ sortType: (state) =>
+ ['unusable', 'falseticker', 'candidate', 'combined', 'selected'].indexOf(state),
+ },
+ { name: 'stratum', type: 'integer', allowNull: true },
+ { name: 'poll', type: 'number', allowNull: true },
+ { name: 'reach', type: 'integer', allowNull: true },
+ { name: 'last-rx', type: 'integer', allowNull: true },
+ { name: 'offset', type: 'number', allowNull: true },
+ ],
+ idProperty: 'address',
+});
+
+Ext.define('Proxmox.window.NTPSources', {
+ extend: 'Ext.window.Window',
+ alias: 'widget.proxmoxNTPSources',
+
+ title: gettext('NTP Sources'),
+ modal: true,
+ layout: 'fit',
+ width: 900,
+ height: 400,
+
+ initComponent: function () {
+ let me = this;
+
+ if (!me.nodename) {
+ throw 'no node name specified';
+ }
+
+ let rstore = Ext.create('Proxmox.data.UpdateStore', {
+ interval: 5000,
+ model: 'proxmox-ntp-sources',
+ proxy: {
+ type: 'proxmox',
+ url: `/api2/json/nodes/${me.nodename}/time/sources`,
+ },
+ });
+
+ // updates the rows in place, so the grid does not show its load mask on every refresh
+ let store = Ext.create('Proxmox.data.DiffStore', {
+ rstore: rstore,
+ // best first, kept when sources are added or change their state on a refresh
+ sortAfterUpdate: true,
+ sorters: [
+ {
+ property: 'state',
+ direction: 'DESC',
+ },
+ ],
+ });
+
+ let renderOptional = (renderer) => (value) =>
+ value === undefined || value === null ? '-' : renderer(value);
+
+ let renderState = function (state) {
+ let [icon, text] = {
+ selected: ['check-circle good', gettext('Selected')],
+ combined: ['check-circle good', gettext('Combined')],
+ candidate: ['circle-o', gettext('Candidate')],
+ falseticker: ['exclamation-circle warning', gettext('Falseticker')],
+ unusable: ['times-circle critical', gettext('Unusable')],
+ }[state] ?? ['question-circle', Ext.htmlEncode(state)];
+
+ return `<i class="fa fa-fw fa-${icon}"></i> ${text}`;
+ };
+
+ // the offset in the most readable unit, as it ranges from microseconds to seconds
+ let renderOffset = function (offset) {
+ let abs = Math.abs(offset);
+ let sign = offset < 0 ? '-' : '+';
+ if (abs < 0.001) {
+ return `${sign}${(abs * 1e6).toFixed(0)} us`;
+ } else if (abs < 1) {
+ return `${sign}${(abs * 1e3).toFixed(3)} ms`;
+ }
+ return `${sign}${abs.toFixed(3)} s`;
+ };
+
+ Ext.apply(me, {
+ items: {
+ xtype: 'grid',
+ store: store,
+ emptyText: gettext('No sources'),
+ columns: [
+ {
+ header: gettext('State'),
+ dataIndex: 'state',
+ width: 130,
+ renderer: renderState,
+ },
+ {
+ header: gettext('Address'),
+ dataIndex: 'address',
+ flex: 1,
+ renderer: Ext.htmlEncode,
+ },
+ {
+ header: gettext('Name'),
+ dataIndex: 'name',
+ flex: 1,
+ renderer: Ext.htmlEncode,
+ },
+ {
+ header: gettext('Stratum'),
+ dataIndex: 'stratum',
+ width: 80,
+ renderer: renderOptional((value) => value),
+ },
+ {
+ header: gettext('Poll interval'),
+ dataIndex: 'poll',
+ width: 100,
+ renderer: renderOptional(Proxmox.Utils.format_duration_human),
+ },
+ {
+ // octal, like the NTP tools show it, i.e. 377 if all of the last 8 polls
+ // got a response
+ header: gettext('Reach'),
+ dataIndex: 'reach',
+ width: 70,
+ renderer: renderOptional((value) => value.toString(8)),
+ },
+ {
+ header: gettext('Last sample'),
+ dataIndex: 'last-rx',
+ width: 100,
+ renderer: renderOptional(Proxmox.Utils.format_duration_human),
+ },
+ {
+ header: gettext('Offset'),
+ dataIndex: 'offset',
+ width: 100,
+ align: 'right',
+ renderer: renderOptional(renderOffset),
+ },
+ ],
+ },
+ });
+
+ me.callParent();
+
+ Proxmox.Utils.monStoreErrors(me.down('grid'), rstore);
+ me.on('destroy', rstore.stopUpdate);
+ rstore.startUpdate();
+ },
+});
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH manager 12/16] partially fix #3809: api: nodes: time: allow configuring NTP servers
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (10 preceding siblings ...)
2026-11-26 13:40 ` [PATCH widget-toolkit 11/16] node: time: add window listing the current NTP sources Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 13/16] api: nodes: time: report clock synchronization status Jonas Theisen
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Return the active time synchronization service and its custom NTP
servers and pools, if any, and allow setting or resetting them via the
existing time endpoint. Pools are separate from servers, as the
services use multiple addresses of a pool, like they do for the
default Debian pool.
To stay backwards compatible, the new properties are optional and the
time zone parameter of the PUT call becomes optional too, so existing
callers that always pass the time zone behave as before. The NTP
properties are only returned if the active service is supported, which
allows clients to decide whether to offer the setting at all.
Servers and pools can be reset individually with the 'delete'
parameter, like for other config endpoints. Once neither is set, the
service uses its default sources again. Like other list parameters,
for example the Ceph monitor addresses, an empty list is accepted and
has the same effect as deleting the setting.
The NTP settings are checked before the time zone is changed, so a
request that fails, for example because the active service does not
support pools, does not change anything.
As the PUT method no longer only sets the time zone, rename it from
set_timezone to set_timesettings. The name is not part of the API
path, so API clients are not affected.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
Notes:
This depends on the NTP helpers in PVE::Systemd from pve-common.
PVE/API2/Nodes.pm | 95 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 91 insertions(+), 4 deletions(-)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index aa35a696..c7d8b139 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1714,7 +1714,7 @@ __PACKAGE__->register_method({
permissions => {
check => ['perm', '/nodes/{node}', ['Sys.Audit']],
},
- description => "Read server time and time zone settings.",
+ description => "Read server time, time zone and NTP settings.",
proxyto => 'node',
parameters => {
additionalProperties => 0,
@@ -1730,6 +1730,32 @@ __PACKAGE__->register_method({
description => "Time zone",
type => 'string',
},
+ 'ntp-service' => {
+ description => "The active time synchronization service, if configuring its"
+ . " NTP servers is supported.",
+ type => 'string',
+ enum => ['chrony', 'systemd-timesyncd'],
+ optional => 1,
+ },
+ 'ntp-servers' => {
+ description => "Custom NTP servers. Neither these nor 'ntp-pools' are set if"
+ . " the time synchronization service uses its default sources.",
+ type => 'string',
+ format => 'address-list',
+ optional => 1,
+ },
+ 'ntp-pools' => {
+ description => "Custom NTP pools, of which multiple addresses are used.",
+ type => 'string',
+ format => 'address-list',
+ optional => 1,
+ },
+ 'ntp-pools-supported' => {
+ description => "Whether the active time synchronization service supports"
+ . " NTP pools.",
+ type => 'boolean',
+ optional => 1,
+ },
time => {
description => "Seconds since 1970-01-01 00:00:00 UTC.",
type => 'integer',
@@ -1755,15 +1781,26 @@ __PACKAGE__->register_method({
localtime => $ltime,
};
+ if (my $service = PVE::Systemd::get_ntp_service()) {
+ $res->{'ntp-service'} = $service;
+ $res->{'ntp-pools-supported'} = PVE::Systemd::is_ntp_pools_supported($service);
+ if (my $sources = PVE::Systemd::get_ntp_servers()) {
+ for my $type ('servers', 'pools') {
+ my $addresses = $sources->{$type};
+ $res->{"ntp-$type"} = join(',', @$addresses) if scalar(@$addresses);
+ }
+ }
+ }
+
return $res;
},
});
__PACKAGE__->register_method({
- name => 'set_timezone',
+ name => 'set_timesettings',
path => 'time',
method => 'PUT',
- description => "Set time zone.",
+ description => "Set time zone and NTP servers.",
permissions => {
check => ['perm', '/nodes/{node}', ['Sys.Modify']],
},
@@ -1777,6 +1814,32 @@ __PACKAGE__->register_method({
description =>
"Time zone. The file '/usr/share/zoneinfo/zone.tab' contains the list of valid names.",
type => 'string',
+ optional => 1,
+ },
+ 'ntp-servers' => {
+ description => "NTP servers replacing the default servers of the active time"
+ . " synchronization service. Supported for chrony and systemd-timesyncd. An"
+ . " empty list is the same as deleting the setting.",
+ type => 'string',
+ format => 'address-list',
+ optional => 1,
+ },
+ 'ntp-pools' => {
+ description => "NTP pools replacing the default sources of the active time"
+ . " synchronization service, of which multiple addresses are used. Not"
+ . " supported for systemd-timesyncd, which only uses a single server. An empty"
+ . " list is the same as deleting the setting.",
+ type => 'string',
+ format => 'address-list',
+ optional => 1,
+ },
+ delete => {
+ description => "A list of settings you want to delete. If neither 'ntp-servers'"
+ . " nor 'ntp-pools' remain set, the time synchronization service uses its"
+ . " default sources again.",
+ type => 'string',
+ format => 'pve-configid-list',
+ optional => 1,
},
},
},
@@ -1784,7 +1847,31 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
- PVE::Systemd::set_timezone($param->{timezone});
+ my $delete = { map { $_ => 1 } PVE::Tools::split_list($param->{delete} // '') };
+ for my $key (sort keys $delete->%*) {
+ raise_param_exc({ delete => "cannot delete '$key'" })
+ if $key ne 'ntp-servers' && $key ne 'ntp-pools';
+ raise_param_exc({ delete => "cannot set and delete '$key' at the same time" })
+ if defined($param->{$key});
+ }
+
+ my $changes = 0;
+ my $current = PVE::Systemd::get_ntp_servers() // { servers => [], pools => [] };
+ for my $type ('servers', 'pools') {
+ if (defined(my $value = $param->{"ntp-$type"})) {
+ $current->{$type} = [PVE::Tools::split_list($value)];
+ $changes = 1;
+ } elsif ($delete->{"ntp-$type"}) {
+ $current->{$type} = [];
+ $changes = 1;
+ }
+ }
+
+ # check the NTP servers before changing anything, so a failing request has no effect
+ PVE::Systemd::check_ntp_servers($current->{servers}, $current->{pools}) if $changes;
+
+ PVE::Systemd::set_timezone($param->{timezone}) if defined($param->{timezone});
+ PVE::Systemd::set_ntp_servers($current->{servers}, $current->{pools}) if $changes;
return;
},
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH manager 13/16] api: nodes: time: report clock synchronization status
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (11 preceding siblings ...)
2026-11-26 13:40 ` [PATCH manager 12/16] partially fix #3809: api: nodes: time: allow configuring NTP servers Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 14/16] ui: node: time: use journal for the NTP service log Jonas Theisen
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Return whether the system clock is synchronized, so admins can check
that a node's time synchronization works without logging in to the
shell, for example after changing the NTP servers.
If the status cannot be queried, for example because timedatectl
fails, it is left out and only a warning is logged, so reading the
time zone and NTP settings keeps working.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
Notes:
This depends on the clock synchronization helper in PVE::Systemd from
pve-common.
PVE/API2/Nodes.pm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index c7d8b139..819114c5 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1756,6 +1756,13 @@ __PACKAGE__->register_method({
type => 'boolean',
optional => 1,
},
+ 'ntp-synchronized' => {
+ description => "Whether the system clock is synchronized, independent of the"
+ . " time synchronization service in use. Not set if the status cannot be"
+ . " determined.",
+ type => 'boolean',
+ optional => 1,
+ },
time => {
description => "Seconds since 1970-01-01 00:00:00 UTC.",
type => 'integer',
@@ -1781,6 +1788,14 @@ __PACKAGE__->register_method({
localtime => $ltime,
};
+ # failing to query the status must not prevent reading the time zone and NTP settings
+ my $synchronized = eval { PVE::Systemd::is_clock_synchronized() };
+ if (my $err = $@) {
+ warn "unable to get clock synchronization status - $err";
+ } else {
+ $res->{'ntp-synchronized'} = $synchronized;
+ }
+
if (my $service = PVE::Systemd::get_ntp_service()) {
$res->{'ntp-service'} = $service;
$res->{'ntp-pools-supported'} = PVE::Systemd::is_ntp_pools_supported($service);
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH manager 14/16] ui: node: time: use journal for the NTP service log
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (12 preceding siblings ...)
2026-11-26 13:40 ` [PATCH manager 13/16] api: nodes: time: report clock synchronization status Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 15/16] api: nodes: time: add endpoint to synchronize the clock immediately Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 16/16] api: nodes: time: add endpoint to list the current NTP sources Jonas Theisen
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Show the log of the NTP service from the journal endpoint, the same way
as for the services in the System panel.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
Notes:
This depends on the service log button in the time view from
proxmox-widget-toolkit.
www/manager6/node/Config.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index 830e8542..4b818107 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -253,6 +253,7 @@ Ext.define('PVE.node.Config', {
itemId: 'time',
groups: ['services'],
nodename: nodename,
+ useJournalLog: true,
iconCls: 'fa fa-clock-o',
},
);
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH manager 15/16] api: nodes: time: add endpoint to synchronize the clock immediately
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (13 preceding siblings ...)
2026-11-26 13:40 ` [PATCH manager 14/16] ui: node: time: use journal for the NTP service log Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 16/16] api: nodes: time: add endpoint to list the current NTP sources Jonas Theisen
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Allow triggering an immediate synchronization of the system clock via
the active time synchronization service, and report whether that
service supports it, so clients can decide whether to offer it.
If the node is part of a cluster, a jump of the clock can severely
disrupt services that rely on synchronized clocks across all nodes,
such as Ceph. So the endpoint refuses to synchronize there unless the
new 'force' parameter is set. The time endpoint also reports whether
the node is part of a cluster, so clients can ask for an explicit
acknowledgement before forcing the synchronization.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
Notes:
This depends on the clock synchronization helpers in PVE::Systemd from
pve-common.
PVE/API2/Nodes.pm | 59 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 819114c5..dd5d0840 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -20,6 +20,7 @@ use PVE::APLInfo;
use PVE::AccessControl;
use PVE::Ceph::Releases;
use PVE::Cluster qw(cfs_read_file);
+use PVE::Corosync;
use PVE::DataCenterConfig;
use PVE::Exception qw(raise raise_perm_exc raise_param_exc);
use PVE::Firewall;
@@ -1756,6 +1757,18 @@ __PACKAGE__->register_method({
type => 'boolean',
optional => 1,
},
+ 'ntp-sync-supported' => {
+ description => "Whether the active time synchronization service supports"
+ . " synchronizing the clock immediately, see 'time/sync'.",
+ type => 'boolean',
+ optional => 1,
+ },
+ clustered => {
+ description => "Whether the node is part of a cluster, where jumps of the clock"
+ . " can disrupt the cluster, so 'time/sync' requires 'force'.",
+ type => 'boolean',
+ optional => 1,
+ },
'ntp-synchronized' => {
description => "Whether the system clock is synchronized, independent of the"
. " time synchronization service in use. Not set if the status cannot be"
@@ -1799,6 +1812,8 @@ __PACKAGE__->register_method({
if (my $service = PVE::Systemd::get_ntp_service()) {
$res->{'ntp-service'} = $service;
$res->{'ntp-pools-supported'} = PVE::Systemd::is_ntp_pools_supported($service);
+ $res->{'ntp-sync-supported'} = PVE::Systemd::is_ntp_sync_supported($service);
+ $res->{clustered} = PVE::Corosync::check_conf_exists(1) ? 1 : 0;
if (my $sources = PVE::Systemd::get_ntp_servers()) {
for my $type ('servers', 'pools') {
my $addresses = $sources->{$type};
@@ -1892,6 +1907,50 @@ __PACKAGE__->register_method({
},
});
+__PACKAGE__->register_method({
+ name => 'sync_time',
+ path => 'time/sync',
+ method => 'POST',
+ description => "Synchronize the system clock with the NTP servers immediately. Supported"
+ . " for chrony, which is triggered at runtime, and systemd-timesyncd, which is restarted."
+ . " Whether the clock is stepped or adjusted gradually depends on the configuration of"
+ . " the service, for chrony on its 'makestep' directive.",
+ permissions => {
+ check => ['perm', '/nodes/{node}', ['Sys.Modify']],
+ },
+ proxyto => 'node',
+ protected => 1,
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ force => {
+ description => "Synchronize even though the node is part of a cluster. Required"
+ . " there, as jumps of the clock can severely disrupt services that rely on"
+ . " synchronized clocks across all nodes, such as Ceph.",
+ type => 'boolean',
+ optional => 1,
+ default => 0,
+ },
+ },
+ },
+ returns => { type => "null" },
+ code => sub {
+ my ($param) = @_;
+
+ raise_param_exc({
+ force => "the node is part of a cluster, where a jump of the clock can severely"
+ . " disrupt services that rely on synchronized clocks, set 'force' to"
+ . " synchronize anyway",
+ })
+ if !$param->{force} && PVE::Corosync::check_conf_exists(1);
+
+ PVE::Systemd::sync_ntp();
+
+ return;
+ },
+});
+
__PACKAGE__->register_method({
name => 'aplinfo',
path => 'aplinfo',
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH manager 16/16] api: nodes: time: add endpoint to list the current NTP sources
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
` (14 preceding siblings ...)
2026-11-26 13:40 ` [PATCH manager 15/16] api: nodes: time: add endpoint to synchronize the clock immediately Jonas Theisen
@ 2026-11-26 13:40 ` Jonas Theisen
15 siblings, 0 replies; 17+ messages in thread
From: Jonas Theisen @ 2026-11-26 13:40 UTC (permalink / raw)
To: pve-devel
Report which sources the time synchronization service currently uses,
including the members of pools, together with their selection state,
reachability and offset. This allows checking why the clock is not
synchronized or how far off a node is, without logging in to the
shell.
Like for the immediate synchronization, the time endpoint reports
whether the active service supports listing its sources, so clients
can decide whether to offer it.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
Notes:
This depends on the NTP sources helper in PVE::Systemd from
pve-common.
PVE/API2/Nodes.pm | 87 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index dd5d0840..2a255294 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1763,6 +1763,12 @@ __PACKAGE__->register_method({
type => 'boolean',
optional => 1,
},
+ 'ntp-sources-supported' => {
+ description => "Whether the active time synchronization service supports"
+ . " listing its current sources, see 'time/sources'.",
+ type => 'boolean',
+ optional => 1,
+ },
clustered => {
description => "Whether the node is part of a cluster, where jumps of the clock"
. " can disrupt the cluster, so 'time/sync' requires 'force'.",
@@ -1813,6 +1819,7 @@ __PACKAGE__->register_method({
$res->{'ntp-service'} = $service;
$res->{'ntp-pools-supported'} = PVE::Systemd::is_ntp_pools_supported($service);
$res->{'ntp-sync-supported'} = PVE::Systemd::is_ntp_sync_supported($service);
+ $res->{'ntp-sources-supported'} = PVE::Systemd::is_ntp_sources_supported($service);
$res->{clustered} = PVE::Corosync::check_conf_exists(1) ? 1 : 0;
if (my $sources = PVE::Systemd::get_ntp_servers()) {
for my $type ('servers', 'pools') {
@@ -1951,6 +1958,86 @@ __PACKAGE__->register_method({
},
});
+__PACKAGE__->register_method({
+ name => 'time_sources',
+ path => 'time/sources',
+ method => 'GET',
+ description => "List the sources the time synchronization service currently uses, including"
+ . " the members of pools. Supported for chrony and systemd-timesyncd, which only reports"
+ . " the server it currently uses.",
+ permissions => {
+ check => ['perm', '/nodes/{node}', ['Sys.Audit']],
+ },
+ proxyto => 'node',
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ },
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => 'object',
+ properties => {
+ address => {
+ description => "The address of the source.",
+ type => 'string',
+ },
+ name => {
+ description => "The name the source was configured with, e.g. the name of"
+ . " its pool, if it differs from the address.",
+ type => 'string',
+ optional => 1,
+ },
+ state => {
+ description => "The selection state of the source. 'selected' is the source"
+ . " the clock is synchronized to, 'combined' sources are used in"
+ . " addition, 'candidate' sources could be used, 'falseticker' sources"
+ . " are inconsistent with the majority, and 'unusable' sources are, for"
+ . " example, unreachable or too variable.",
+ type => 'string',
+ enum => ['selected', 'combined', 'candidate', 'falseticker', 'unusable'],
+ },
+ stratum => {
+ description => "The stratum of the source.",
+ type => 'integer',
+ optional => 1,
+ },
+ poll => {
+ description => "The polling interval in seconds.",
+ type => 'number',
+ optional => 1,
+ },
+ reach => {
+ description => "The reachability register of the last 8 polls, with a bit"
+ . " set for each received response.",
+ type => 'integer',
+ minimum => 0,
+ maximum => 255,
+ optional => 1,
+ },
+ 'last-rx' => {
+ description => "Seconds since the last sample was received.",
+ type => 'integer',
+ optional => 1,
+ },
+ offset => {
+ description => "The offset of the local clock to the source in seconds, as"
+ . " of the last sample. Positive if the local clock is ahead.",
+ type => 'number',
+ optional => 1,
+ },
+ },
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+
+ return PVE::Systemd::get_ntp_sources();
+ },
+});
+
__PACKAGE__->register_method({
name => 'aplinfo',
path => 'aplinfo',
--
2.47.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
end of thread, other threads:[~2026-11-26 13:44 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
2026-11-26 13:39 ` [PATCH common 01/16] systemd: add helpers to get and set NTP servers Jonas Theisen
2026-11-26 13:39 ` [PATCH common 02/16] systemd: add helper to query clock synchronization status Jonas Theisen
2026-11-26 13:40 ` [PATCH common 03/16] systemd: add helpers to synchronize the clock immediately Jonas Theisen
2026-11-26 13:40 ` [PATCH common 04/16] systemd: add helper to list the current NTP sources Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 05/16] node: time: do not open the editor for the server time row Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 06/16] partially fix #3809: node: time: show and edit NTP servers if supported Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 07/16] node: time: show clock synchronization status Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 08/16] window: add reusable service log window Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 09/16] node: time: add button to open the NTP service log Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 10/16] node: time: add button to synchronize the clock immediately Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 11/16] node: time: add window listing the current NTP sources Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 12/16] partially fix #3809: api: nodes: time: allow configuring NTP servers Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 13/16] api: nodes: time: report clock synchronization status Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 14/16] ui: node: time: use journal for the NTP service log Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 15/16] api: nodes: time: add endpoint to synchronize the clock immediately Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 16/16] api: nodes: time: add endpoint to list the current NTP sources Jonas Theisen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.