[pve-devel] [PATCH cluster] datacenter.cfg: add ha setting with shutdown_policy as format string property

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Dec 19 11:39:38 CET 2018


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 data/PVE/Cluster.pm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index f4dd1a3..e6421e7 100644
--- a/data/PVE/Cluster.pm
+++ b/data/PVE/Cluster.pm
@@ -1337,6 +1337,17 @@ my $migration_format = {
     },
 };
 
+my $ha_format = {
+    shutdown_policy => {
+	type => 'string',
+	enum => ['freeze', 'failover', 'default'],
+	description => "The policy for HA services on node shutdown. With freeze services will never get auto recovered. Failover ensures the service can get recovered. Default recovers on poweroff but does not on reboot.",
+	verbose_description => "Describes the policy for handling HA services on poweroff or reboot of a node. Freeze will always freeze services which are still located on the node on shutdown, those services won't be recovered by the manager. Failover will not mark the services a frozen and thus the services will get recovered to other nodes, if the shutdown node does not comes up again fast (< 2min). Default is dependent of the type of shutdown, i.e., on a reboot the service will be freezed but on a poweroff the service nill stay as is, and thus recovered after about 2 minutes.",
+	default => 'default',
+    }
+};
+
+
 my $datacenter_schema = {
     type => "object",
     additionalProperties => 0,
@@ -1420,6 +1431,11 @@ my $datacenter_schema = {
 	      " With both all two modes are used." .
 	      "\n\nWARNING: 'hardware' and 'both' are EXPERIMENTAL & WIP",
 	},
+	ha => {
+	    optional => 1,
+	    type => 'string', format => $ha_format,
+	    description => "Cluster wide HA settings.",
+	},
 	mac_prefix => {
 	    optional => 1,
 	    type => 'string',
@@ -1442,6 +1458,10 @@ sub parse_datacenter_config {
 	$res->{migration} = PVE::JSONSchema::parse_property_string($migration_format, $migration);
     }
 
+    if (my $ha = $res->{ha}) {
+	$res->{ha} = PVE::JSONSchema::parse_property_string($ha_format, $ha);
+    }
+
     # for backwards compatibility only, new migration property has precedence
     if (defined($res->{migration_unsecure})) {
 	if (defined($res->{migration}->{type})) {
@@ -1478,6 +1498,10 @@ sub write_datacenter_config {
 	$cfg->{migration} = PVE::JSONSchema::print_property_string($migration, $migration_format);
     }
 
+    if (my $ha = $cfg->{ha}) {
+	$cfg->{ha} = PVE::JSONSchema::print_property_string($ha, $ha_format);
+    }
+
     return PVE::JSONSchema::dump_config($datacenter_schema, $filename, $cfg);
 }
 
-- 
2.19.2





More information about the pve-devel mailing list