fix #1578: api/resource hastate: fallback to resource cfg state
With ignored or still queued services we have no hastate for a service in the manager status available. As we use hastate in the web UI to determine if a service is configured for HA this could lead to confusion there. For example, the VM/CT 'Manage HA' window thinks tries to add the service again if its in the 'ignored' state, and then the backend errors out because it is already configured. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
1ca8a8f20a
commit
8ad1127a16
@ -14,6 +14,7 @@ use PVE::Storage;
|
||||
use PVE::API2Tools;
|
||||
use PVE::API2::Backup;
|
||||
use PVE::API2::HAConfig;
|
||||
use PVE::HA::Env::PVE2;
|
||||
use PVE::HA::Config;
|
||||
use PVE::API2::ClusterConfig;
|
||||
use JSON;
|
||||
@ -188,6 +189,7 @@ __PACKAGE__->register_method({
|
||||
my $idlist = $vmlist->{ids} || {};
|
||||
|
||||
my $hastatus = PVE::HA::Config::read_manager_status();
|
||||
my $haresources = PVE::HA::Config::read_resources_config();
|
||||
my $hatypemap = {
|
||||
'qemu' => 'vm',
|
||||
'lxc' => 'ct'
|
||||
@ -245,8 +247,11 @@ __PACKAGE__->register_method({
|
||||
# get ha status
|
||||
if (my $hatype = $hatypemap->{$entry->{type}}) {
|
||||
my $sid = "$hatype:$vmid";
|
||||
if (defined($hastatus->{service_status}->{$sid})) {
|
||||
$entry->{hastate} = $hastatus->{service_status}->{$sid}->{state};
|
||||
my $service;
|
||||
if ($service = $hastatus->{service_status}->{$sid}) {
|
||||
$entry->{hastate} = $service->{state};
|
||||
} elsif ($service = $haresources->{ids}->{$sid}) {
|
||||
$entry->{hastate} = $service->{state};
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user