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 4/7] use log with warning priority instead of warn where possible
Date: Fri, 17 Apr 2026 14:27:19 +0200	[thread overview]
Message-ID: <20260417122728.330123-5-d.kral@proxmox.com> (raw)
In-Reply-To: <20260417122728.330123-1-d.kral@proxmox.com>

The HA Manager should relay all output through its PVE::HA::Env::log()
interface to allow consistent output.

In the case for PVE::HA::Sim::Hardware::unlock_service(), the
test-locked-service2 integration test didn't capture the expected
behavior in its expected log output.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
 src/PVE/HA/Env/PVE2.pm                   | 2 +-
 src/PVE/HA/Resources/PVEVM.pm            | 2 +-
 src/PVE/HA/Sim/Hardware.pm               | 2 +-
 src/test/test-locked-service2/log.expect | 9 +++++++++
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm
index 68bbe8d2..782d19db 100644
--- a/src/PVE/HA/Env/PVE2.pm
+++ b/src/PVE/HA/Env/PVE2.pm
@@ -439,7 +439,7 @@ sub loop_end_hook {
 
     my $delay = $self->get_time() - $self->{loop_start};
 
-    warn "loop took too long ($delay seconds)\n" if $delay > 30;
+    $self->log('warning', "loop took too long ($delay seconds)") if $delay > 30;
 }
 
 sub cluster_state_update {
diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm
index 1621c15b..dceb08e3 100644
--- a/src/PVE/HA/Resources/PVEVM.pm
+++ b/src/PVE/HA/Resources/PVEVM.pm
@@ -146,7 +146,7 @@ sub check_running {
         my $conf = PVE::QemuConfig->load_config($vmid, $nodename);
         if (defined($conf->{lock}) && $conf->{lock} eq 'backup') {
             my $qmpstatus = eval { PVE::QemuServer::Monitor::mon_cmd($vmid, 'query-status') };
-            warn "$@\n" if $@;
+            $haenv->log('warning', "$@") if $@;
 
             return 0 if defined($qmpstatus) && $qmpstatus->{status} eq 'prelaunch';
         }
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 88fd64e8..4ebe2adf 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -326,7 +326,7 @@ sub unlock_service {
     }
 
     if (defined($lock) && $service_lock ne $lock) {
-        warn "found lock '$service_lock' trying to remove '$lock' lock\n";
+        $self->log('warning', "found lock '$service_lock' trying to remove '$lock' lock");
         return undef;
     }
 
diff --git a/src/test/test-locked-service2/log.expect b/src/test/test-locked-service2/log.expect
index bfdc8ab0..a932f14b 100644
--- a/src/test/test-locked-service2/log.expect
+++ b/src/test/test-locked-service2/log.expect
@@ -39,6 +39,15 @@ info    340    node1/crm: node 'node3': state changed from 'fence' => 'unknown'
 emai    340    node1/crm: SUCCEED: fencing: acknowledged - got agent lock for node 'node3'
 info    340    node1/crm: service 'vm:103': state changed from 'fence' to 'recovery'
 info    340    node1/crm: recover service 'vm:103' from fenced node 'node3' to node 'node1'
+warn    340     hardware: found lock 'create' trying to remove 'backup' lock
+warn    340     hardware: found lock 'create' trying to remove 'mounted' lock
+warn    340     hardware: found lock 'create' trying to remove 'migrate' lock
+warn    340     hardware: found lock 'create' trying to remove 'clone' lock
+warn    340     hardware: found lock 'create' trying to remove 'rollback' lock
+warn    340     hardware: found lock 'create' trying to remove 'snapshot' lock
+warn    340     hardware: found lock 'create' trying to remove 'snapshot-delete' lock
+warn    340     hardware: found lock 'create' trying to remove 'suspending' lock
+warn    340     hardware: found lock 'create' trying to remove 'suspended' lock
 info    340    node1/crm: service 'vm:103': state changed from 'recovery' to 'started'  (node = node1)
 info    341    node1/lrm: got lock 'ha_agent_node1_lock'
 info    341    node1/lrm: status change wait_for_agent_lock => active
-- 
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 ` [PATCH ha-manager 2/7] consistently use correct priority levels for log calls Daniel Kral
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 ` Daniel Kral [this message]
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-5-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