all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Jonas Theisen <j.theisen@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH manager 13/16] api: nodes: time: report clock synchronization status
Date: Thu, 26 Nov 2026 14:40:10 +0100	[thread overview]
Message-ID: <20261126134128.316681-14-j.theisen@proxmox.com> (raw)
In-Reply-To: <20261126134128.316681-1-j.theisen@proxmox.com>

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





  parent reply	other threads:[~2026-11-26 13:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Jonas Theisen [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126134128.316681-14-j.theisen@proxmox.com \
    --to=j.theisen@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal