shutdown_errors => 0,
# mode can be: active, reboot, shutdown, restart
mode => 'active',
+ cluster_state_update => 0,
}, $class;
$self->set_local_status({ state => 'wait_for_agent_lock' });
my ($shutdown, $reboot) = $haenv->is_node_shutdown();
+ my $dc_ha_cfg = $haenv->get_ha_settings();
+ my $shutdown_policy = $dc_ha_cfg->{shutdown_policy} // 'conditional';
+
+ if ($shutdown) { # don't log this on service restart, only on node shutdown
+ $haenv->log('info', "got shutdown request with shutdown policy '$shutdown_policy'");
+ }
+
+ my $freeze_all;
+ if ($shutdown_policy eq 'conditional') {
+ $freeze_all = $reboot;
+ } elsif ($shutdown_policy eq 'freeze') {
+ $freeze_all = 1;
+ } elsif ($shutdown_policy eq 'failover') {
+ $freeze_all = 0;
+ } else {
+ $haenv->log('err', "unknown shutdown policy '$shutdown_policy', fall back to conditional");
+ $freeze_all = $reboot;
+ }
+
if ($shutdown) {
# *always* queue stop jobs for all services if the node shuts down,
# independent if it's a reboot or a poweroff, else we may corrupt
}
if ($shutdown) {
- if ($reboot) {
- $haenv->log('info', "reboot LRM, stop and freeze all services");
+ if ($freeze_all) {
+ if ($reboot) {
+ $haenv->log('info', "reboot LRM, stop and freeze all services");
+ } else {
+ $haenv->log('info', "shutdown LRM, stop and freeze all services");
+ }
$self->{mode} = 'restart';
} else {
$haenv->log('info', "shutdown LRM, stop all services");
my $haenv = $self->{haenv};
+ $haenv->loop_start_hook();
+
+ $self->{cluster_state_update} = $haenv->cluster_state_update();
+
+ my $res = $self->work();
+
+ $haenv->loop_end_hook();
+
+ return $res;
+}
+
+sub work {
+ my ($self) = @_;
+
+ my $haenv = $self->{haenv};
+
if (!$wrote_lrm_status_at_startup) {
if ($self->update_lrm_status()) {
$wrote_lrm_status_at_startup = 1;
}
}
} else {
+ if (!$self->{cluster_state_update}) {
+ # update failed but we could still renew our lock (cfs restart?),
+ # safely skip manage and expect to update just fine next round
+ $haenv->log('notice', "temporary inconsistent cluster state " .
+ "(cfs restart?), skip round");
+ return;
+ }
$self->manage_resources();
my $nodename = $haenv->nodename();
- my (undef, $service_type, $service_name) = PVE::HA::Tools::parse_sid($sid);
+ my (undef, $service_type, $service_name) = $haenv->parse_sid($sid);
my $plugin = PVE::HA::Resources->lookup($service_type);
if (!$plugin) {