5
0
mirror of git://git.proxmox.com/git/pve-ha-manager.git synced 2025-02-25 21:57:21 +03:00

improve CRM state transitions

This commit is contained in:
Dietmar Maurer 2015-02-14 11:52:35 +01:00
parent 238a01a9a0
commit 618fbeda14
3 changed files with 47 additions and 14 deletions

View File

@ -66,6 +66,15 @@ sub select_service_node {
my $uid_counter = 0;
my $valid_service_states = {
stopped => 1,
request_stop => 1,
started => 1,
fence => 1,
migrate => 1,
error => 1,
};
my $change_service_state = sub {
my ($self, $sid, $new_state, %params) = @_;
@ -77,6 +86,8 @@ my $change_service_state = sub {
die "no state change" if $old_state eq $new_state; # just to be sure
die "invalid CRM service state '$new_state'\n" if !$valid_service_states->{$new_state};
my $changes = '';
foreach my $k (keys %params) {
my $v = $params{$k};
@ -199,13 +210,29 @@ sub manage {
} elsif ($last_state eq 'request_stop') {
#fixme: die "implement me";
# do nothing here
} else {
die "unknown service state '$last_state'";
}
# check results from LRM daemons
my $lrm_res = $sd->{uid} ? $lrm_status->{$sd->{uid}} : undef;
if ($lrm_res) {
my $exit_code = $lrm_res->{exit_code};
if ($sd->{state} eq 'request_stop') {
if ($exit_code == 0) {
&$change_service_state($self, $sid, 'stopped');
} else {
&$change_service_state($self, $sid, 'error'); # fixme: what state?
}
} elsif ($sd->{state} eq 'started') {
}
}
$repeat = 1 if $sd->{state} ne $last_state;
}

View File

@ -78,17 +78,7 @@ sub exec_resource_agent {
my $ss = $hardware->read_service_status();
if ($cmd eq 'request_stop') {
if (!$ss->{$sid}) {
print "WORKER status $sid: stopped\n";
return 0;
} else {
print "WORKER status $sid: running\n";
return 1;
}
} elsif ($cmd eq 'start') {
if ($cmd eq 'started') {
if ($ss->{$sid}) {
print "WORKER status $sid: running\n";
@ -105,7 +95,7 @@ sub exec_resource_agent {
return 0;
} elsif ($cmd eq 'stop') {
} elsif ($cmd eq 'request_stop' || $cmd eq 'stopped') {
if (!$ss->{$sid}) {
print "WORKER status $sid: stopped\n";
@ -123,7 +113,7 @@ sub exec_resource_agent {
return 0;
}
die "implement me";
die "implement me (cmd '$cmd')";
}
1;

16
README
View File

@ -66,6 +66,22 @@ service states by writing the global 'manager_status'. That data
structure is read by the Local Resource Manager, which performs the
real work (start/stop/migrate) services.
=== Possible CRM Service States ===
stopped: Service is stopped (confirmed by LRM)
request_stop: Service should be stopped. Waiting for
confirmation from LRM.
started: Service is active an LRM should start it asap.
fence: Wait for node fencing (service node is not inside
quorate cluster partition).
migrate: Migrate VM to other node
error: Service disabled because of LRM errors.
== Local Resource Manager (class PVE::HA::LRM) ==
The Local Resource Manager (LRM) daemon runs one each node, and