public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH ha-manager 2/7] consistently use correct priority levels for log calls
Date: Fri, 17 Apr 2026 14:27:17 +0200	[thread overview]
Message-ID: <20260417122728.330123-3-d.kral@proxmox.com> (raw)
In-Reply-To: <20260417122728.330123-1-d.kral@proxmox.com>

The correct priority string for warnings is 'warning' and for errors is
'err' as this is relayed directly to the PVE::SafeSyslog::syslog() in
the PVE::HA::Env::PVE2::log() implementation.

This doesn't change the test log output as its log() implementation
trims the priority level to the first four characters.

This doesn't have any functional changes, because PVE::SafeSyslog
already handles the 'warn' string correctly and the log calls with
'error' are only for tests, but it's better to be consistent here.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
 src/PVE/HA/Env.pm                  | 2 ++
 src/PVE/HA/Env/PVE2.pm             | 2 +-
 src/PVE/HA/Fence.pm                | 2 +-
 src/PVE/HA/Manager.pm              | 6 +++---
 src/PVE/HA/Sim/Env.pm              | 1 +
 src/PVE/HA/Sim/Hardware.pm         | 8 ++++----
 src/PVE/HA/Sim/Resources/VirtCT.pm | 2 +-
 7 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/PVE/HA/Env.pm b/src/PVE/HA/Env.pm
index 44c26854..cd31de73 100644
--- a/src/PVE/HA/Env.pm
+++ b/src/PVE/HA/Env.pm
@@ -169,6 +169,8 @@ sub get_node_info {
     return $self->{plug}->get_node_info();
 }
 
+# $level must match a valid value as the priority levels in Sys::Syslog, which are:
+# 'emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', and 'debug'.
 sub log {
     my ($self, $level, @args) = @_;
 
diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm
index 3caf32fc..68bbe8d2 100644
--- a/src/PVE/HA/Env/PVE2.pm
+++ b/src/PVE/HA/Env/PVE2.pm
@@ -447,7 +447,7 @@ sub cluster_state_update {
 
     eval { PVE::Cluster::cfs_update(1) };
     if (my $err = $@) {
-        $self->log('warn', "cluster file system update failed - $err");
+        $self->log('warning', "cluster file system update failed - $err");
         return 0;
     }
 
diff --git a/src/PVE/HA/Fence.pm b/src/PVE/HA/Fence.pm
index 49d673f4..84d86794 100644
--- a/src/PVE/HA/Fence.pm
+++ b/src/PVE/HA/Fence.pm
@@ -191,7 +191,7 @@ sub process_fencing {
             $tried_device_count++; # try next available device
             return if run_fence_jobs($node, $tried_device_count);
 
-            $haenv->log('warn', "could not start fence job at try '$tried_device_count'");
+            $haenv->log('warning', "could not start fence job at try '$tried_device_count'");
         }
 
         $results->{$node}->{failure} = 1;
diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index b69a6bba..5ebf9caa 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -682,7 +682,7 @@ sub update_crm_commands {
             my $state = $ns->get_node_state($node);
             if ($ms->{disarm}) {
                 $haenv->log(
-                    'warn',
+                    'warning',
                     "ignoring maintenance command for node $node - HA stack is disarmed",
                 );
             } elsif ($state eq 'online') {
@@ -701,7 +701,7 @@ sub update_crm_commands {
             my $state = $ns->get_node_state($node);
             if ($state ne 'maintenance') {
                 $haenv->log(
-                    'warn',
+                    'warning',
                     "clearing maintenance of node $node requested, but it's in state $state",
                 );
             }
@@ -906,7 +906,7 @@ sub handle_disarm {
     for my $sid (sort keys %$ss) {
         my $state = $ss->{$sid}->{state};
         if ($state eq 'fence' || $state eq 'recovery') {
-            $haenv->log('warn', "deferring disarm - service '$sid' is in '$state' state");
+            $haenv->log('warning', "deferring disarm - service '$sid' is in '$state' state");
             $deferred_sids->{$sid} = 1;
         } elsif ($state eq 'migrate' || $state eq 'relocate') {
             $haenv->log('info', "deferring disarm - service '$sid' is in '$state' state");
diff --git a/src/PVE/HA/Sim/Env.pm b/src/PVE/HA/Sim/Env.pm
index 63368117..38ac1d03 100644
--- a/src/PVE/HA/Sim/Env.pm
+++ b/src/PVE/HA/Sim/Env.pm
@@ -348,6 +348,7 @@ sub send_notification {
     $subject = $subject =~ s/\{\{fence-status}}/$properties->{"fence-status"}/r;
 
     # only log subject, do not spam the logs
+    # allow invalid 'email' priority level here as it's only for test log output
     $self->log('email', $subject);
 }
 
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 163e35af..891d552f 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -455,7 +455,7 @@ sub read_static_service_stats {
 
     my $filename = "$self->{statusdir}/static_service_stats";
     my $stats = eval { PVE::HA::Tools::read_json_from_file($filename) };
-    $self->log('error', "loading static service stats failed - $@") if $@;
+    $self->log('err', "loading static service stats failed - $@") if $@;
 
     return $stats;
 }
@@ -465,7 +465,7 @@ sub read_dynamic_service_stats {
 
     my $filename = "$self->{statusdir}/dynamic_service_stats";
     my $stats = eval { PVE::HA::Tools::read_json_from_file($filename) };
-    $self->log('error', "loading dynamic service stats failed - $@") if $@;
+    $self->log('err', "loading dynamic service stats failed - $@") if $@;
 
     return $stats;
 }
@@ -475,7 +475,7 @@ sub write_static_service_stats {
 
     my $filename = "$self->{statusdir}/static_service_stats";
     eval { PVE::HA::Tools::write_json_to_file($filename, $stats) };
-    $self->log('error', "writing static service stats failed - $@") if $@;
+    $self->log('err', "writing static service stats failed - $@") if $@;
 }
 
 sub write_dynamic_service_stats {
@@ -483,7 +483,7 @@ sub write_dynamic_service_stats {
 
     my $filename = "$self->{statusdir}/dynamic_service_stats";
     eval { PVE::HA::Tools::write_json_to_file($filename, $stats) };
-    $self->log('error', "writing dynamic service stats failed - $@") if $@;
+    $self->log('err', "writing dynamic service stats failed - $@") if $@;
 }
 
 sub new {
diff --git a/src/PVE/HA/Sim/Resources/VirtCT.pm b/src/PVE/HA/Sim/Resources/VirtCT.pm
index 594dba56..3f6df85e 100644
--- a/src/PVE/HA/Sim/Resources/VirtCT.pm
+++ b/src/PVE/HA/Sim/Resources/VirtCT.pm
@@ -25,7 +25,7 @@ sub migrate {
     my $ss = $hardware->read_service_status($nodename);
 
     if ($online && $ss->{$sid}) {
-        $haenv->log('warn', "unable to live migrate running container, fallback to relocate");
+        $haenv->log('warning', "unable to live migrate running container, fallback to relocate");
         $online = 0;
     }
 
-- 
2.47.3





  parent reply	other threads:[~2026-04-17 12:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17 12:27 [PATCH ha-manager 0/7] some test logging output improvements Daniel Kral
2026-04-17 12:27 ` [PATCH ha-manager 1/7] sim: always limit the priority level to 4 characters Daniel Kral
2026-04-17 12:27 ` Daniel Kral [this message]
2026-04-17 12:27 ` [PATCH ha-manager 3/7] sim: hardware: factor common service lock hash access in unlock_service Daniel Kral
2026-04-17 12:27 ` [PATCH ha-manager 4/7] use log with warning priority instead of warn where possible Daniel Kral
2026-04-17 12:27 ` [PATCH ha-manager 5/7] pve-ha-tester: capture and fail for unexpected perl warnings Daniel Kral
2026-04-17 12:27 ` [PATCH ha-manager 6/7] test: ha-tester: use consistent word casing for failed test messages Daniel Kral
2026-04-17 12:27 ` [PATCH ha-manager 7/7] test: ha-tester: use colorized diff for unexpected test log outputs Daniel Kral

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=20260417122728.330123-3-d.kral@proxmox.com \
    --to=d.kral@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal