]> git.proxmox.com Git - pve-cluster.git/commitdiff
datacenter.cfg: add ha setting with shutdown_policy as format string property
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 20 Dec 2018 07:44:40 +0000 (08:44 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 7 Jan 2019 10:17:26 +0000 (11:17 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/Cluster.pm

index 68d644653e9436a587f6631995ea4fefff6123de..a4e5c3f22c6ca761fa5c6a9ab646e1e92cd1b293 100644 (file)
@@ -1341,6 +1341,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,
@@ -1424,6 +1435,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',
@@ -1446,6 +1462,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})) {
@@ -1482,6 +1502,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);
 }