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: [pve-devel] [PATCH ha-manager 1/1] api: resources: fix uninitialized value in check_service_state
Date: Mon, 10 Nov 2025 15:36:16 +0100	[thread overview]
Message-ID: <20251110143627.365434-2-d.kral@proxmox.com> (raw)
In-Reply-To: <20251110143627.365434-1-d.kral@proxmox.com>

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@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



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-11-10 14:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10 14:36 [pve-devel] [PATCH container/ha-manager/qemu-server 0/5] Small HA-on-create improvements Daniel Kral
2025-11-10 14:36 ` Daniel Kral [this message]
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 1/3] api: create_vm: use ha-manager command to add VM as an HA resource Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 2/3] qmrestore: allow starting a VM after it was restored successfully Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 3/3] qmrestore: allow adding a VM as an HA resource after it was restored Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH container 1/1] api: create_vm: use ha-manager command to add container as an HA resource 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=20251110143627.365434-2-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