[pve-devel] [PATCH ha-manager 1/1] api: resources: fix uninitialized value in check_service_state

Daniel Kral d.kral at proxmox.com
Mon Nov 10 15:36:16 CET 2025


check_service_state(...) calls get_service_status(...), which assumes
that a configured HA resource is already present in the manager status.

If a HA resource is added to the configuration file and interacted with
such that check_service_state(...) is called before the HA Manager loads
the new HA resource in its state, then $service_status->{state} will be
undefined.

Signed-off-by: Daniel Kral <d.kral at proxmox.com>
---
 src/PVE/API2/HA/Resources.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm
index acdd4992..9d3460e5 100644
--- a/src/PVE/API2/HA/Resources.pm
+++ b/src/PVE/API2/HA/Resources.pm
@@ -38,7 +38,11 @@ sub check_service_state {
     my ($sid, $req_state) = @_;
 
     my $service_status = PVE::HA::Config::get_service_status($sid);
-    if ($service_status->{managed} && $service_status->{state} eq 'error') {
+    if (
+        $service_status->{managed}
+        && $service_status->{state}
+        && $service_status->{state} eq 'error'
+    ) {
         # service in error state, must get disabled before new state request
         # can be executed
         return if defined($req_state) && $req_state eq 'disabled';
-- 
2.47.3





More information about the pve-devel mailing list