[pve-devel] [PATCH ha-manager 1/3] cleanup manager status on start

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jul 14 14:49:06 CEST 2016


Cleanup  the manager state if we get promoted to manager to avoid
deletions of deprecated hash entries.
Just safe:
* service status: as it may contain unprocessed results
* relocate tried nodes: so we do not accidentally restart the start
  failure policy on a manager restart (e.g. update)
* manager_node: this is set only once before this cleanup so do not
  delete it.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
changes since prev. version:
* renamed key_withelist to ms_state_key_whitelist

 src/PVE/HA/Manager.pm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index 1208720..ff8a52b 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -30,6 +30,8 @@ sub new {
 	ss => $ss, # service status
     }, $class;
 
+    $self->cleanup_manager_status();
+
     return $self;
 }
 
@@ -39,6 +41,23 @@ sub cleanup {
     # todo: ?
 }
 
+sub cleanup_manager_status {
+    my ($self) = @_;
+
+    my $ms = $self->{ms};
+    my $new_state = {};
+
+    # safe only the state part of the manager which cannot be auto generated
+    my @ms_state_key_whitelist = qw(service_status relocate_tried_nodes master_node);
+
+    foreach my $k (@ms_state_key_whitelist) {
+	next if !$ms->{$k};
+	$new_state->{$k} = $ms->{$k};
+    }
+
+    $self->{ms} = $new_state;
+}
+
 sub flush_master_status {
     my ($self) = @_;
 
-- 
2.1.4





More information about the pve-devel mailing list