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

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Jul 18 11:17:47 CEST 2016


Cleanup the manager state in a general way if we get promoted to
manager. This safes us code as instead of having to check all
deprecated entries and delete them, each one extra, we just safe the
state part needed to change master without loosing any result of the
manager status and just delete the rest.
This would include the following keys:
* service status: as it may contain unprocessed results
* 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 v3:
* ms_state_key_whitelist does not includes 'relocate_tried_nodes'
  anymore as we save that information in service status in the
  next patch

 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 b6b612d..2dfe492 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 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