[pve-devel] [RFC ha-manager 2/3] move fence_delay to node status

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Apr 26 10:55:28 CEST 2016


we only need it there also helps us variable reuse in next patch

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/Manager.pm    | 6 ++----
 src/PVE/HA/NodeStatus.pm | 4 ++++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index 9b4e6f2..54e99b5 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -9,8 +9,6 @@ use PVE::Tools;
 use PVE::HA::Tools ':exit_codes';
 use PVE::HA::NodeStatus;
 
-my $fence_delay = 60;
-
 sub new {
     my ($this, $haenv) = @_;
 
@@ -548,7 +546,7 @@ sub next_state_started {
     my $ns = $self->{ns};
 
     if (!$ns->node_is_online($sd->{node})) {
-	if ($ns->node_is_offline_delayed($sd->{node}, $fence_delay)) {
+	if ($ns->node_is_offline_delayed($sd->{node})) {
 	    &$change_service_state($self, $sid, 'fence');
 	}
 	return;
@@ -651,7 +649,7 @@ sub next_state_error {
 	return;
     }
 
-    if ($ns->node_is_offline_delayed($sd->{node}, $fence_delay)) {
+    if ($ns->node_is_offline_delayed($sd->{node})) {
 	&$change_service_state($self, $sid, 'fence');
 	return;
     }
diff --git a/src/PVE/HA/NodeStatus.pm b/src/PVE/HA/NodeStatus.pm
index eb174cb..d9ef912 100644
--- a/src/PVE/HA/NodeStatus.pm
+++ b/src/PVE/HA/NodeStatus.pm
@@ -5,6 +5,8 @@ use warnings;
 
 use Data::Dumper;
 
+my $fence_delay = 60;
+
 sub new {
     my ($this, $haenv, $status) = @_;
 
@@ -45,6 +47,8 @@ sub node_is_online {
 sub node_is_offline_delayed {
     my ($self, $node, $delay) = @_;
 
+    $delay = $fence_delay if !defined($delay);
+
     my $haenv = $self->{haenv};
 
     return undef if $self->get_node_state($node) eq 'online';
-- 
2.1.4





More information about the pve-devel mailing list