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

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Dec 20 08:44:40 CET 2018


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

changes v1 -> v2
* fix various typos/grammar errors (thanks Fabian!)
* rename 'default' to 'conditional' to avoid the a bit weird (default => default)
  wording.

 data/PVE/Cluster.pm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index f4dd1a3..808cbda 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', 'conditional'],
+	description => "The policy for HA services on node shutdown. 'freeze' disables auto-recovery, 'failover' ensures recovery, 'conditional' recovers on poweroff and freezes on reboot. Running HA Services will always get stopped first on shutdown.",
+	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 HA manager. Failover will not mark the services as frozen and thus the services will get recovered to other nodes, if the shutdown node does not come up again quickly (< 1min). 'conditional' chooses automatically depending on the type of shutdown, i.e., on a reboot the service will be frozen but on a poweroff the service will stay as is, and thus get recovered after about 2 minutes.",
+	default => 'conditional',
+    }
+};
+
+
 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