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 <[email protected]>
---
 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
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to