]> git.proxmox.com Git - pve-ha-manager.git/blobdiff - src/PVE/HA/Tools.pm
fix #1919, #1920: improve handling zombie (without node) services
[pve-ha-manager.git] / src / PVE / HA / Tools.pm
index 9d037f5058fa8017f7a69f25dfba1685cab4b8b1..81785efbd3f5d9c6086d26d09e4f89bf098ab5c6 100644 (file)
@@ -41,7 +41,7 @@ sub pve_verify_ha_resource_id {
 PVE::JSONSchema::register_standard_option('pve-ha-resource-id', {
     description => "HA resource ID. This consists of a resource type followed by a resource specific name, separated with colon (example: vm:100 / ct:100).",
     typetext => "<type>:<name>",
-    type => 'string', format => 'pve-ha-resource-id',                                   
+    type => 'string', format => 'pve-ha-resource-id',
 });
 
 PVE::JSONSchema::register_format('pve-ha-resource-or-vm-id', \&pve_verify_ha_resource_or_vm_id);
@@ -58,7 +58,7 @@ sub pve_verify_ha_resource_or_vm_id {
 PVE::JSONSchema::register_standard_option('pve-ha-resource-or-vm-id', {
     description => "HA resource ID. This consists of a resource type followed by a resource specific name, separated with colon (example: vm:100 / ct:100). For virtual machines and containers, you can simply use the VM or CT id as a shortcut (example: 100).",
     typetext => "<type>:<name>",
-    type => 'string', format => 'pve-ha-resource-or-vm-id',                                     
+    type => 'string', format => 'pve-ha-resource-or-vm-id',
 });
 
 PVE::JSONSchema::register_format('pve-ha-group-node', \&pve_verify_ha_group_node);
@@ -111,7 +111,7 @@ sub count_fenced_services {
     my ($ss, $node) = @_;
 
     my $count = 0;
-    
+
     foreach my $sid (keys %$ss) {
        my $sd = $ss->{$sid};
        next if !$sd->{node};
@@ -123,7 +123,7 @@ sub count_fenced_services {
            next;
        }
     }
-    
+
     return $count;
 }
 
@@ -133,6 +133,8 @@ sub get_verbose_service_state {
     my $req = $service_conf->{state} // 'ignored';
     return 'ignored' if $req eq 'ignored';
 
+    return 'not found' if !defined($service_conf->{node});
+
     # service not yet processed by manager
     return 'queued' if !defined($service_state);
     my $cur = $service_state->{state};
@@ -174,6 +176,11 @@ sub upid_wait {
 
 # bash auto completion helper
 
+# NOTE: we use PVE::HA::Config here without declaring an 'use' clause above as
+# an hack. It uses the PVE::Cluster module from pve-cluster, which we do not
+# have nor want as dependency in the simulator - where the completion helpers
+# are never called. The PVE::CLI::ha_manager package pulls it in for us.
+
 sub complete_sid {
     my ($cmd, $pname, $cur) = @_;