[pve-devel] [PATCH container] Use crm-command stop to allow shutdown with timeout and hard stop for HA

Fabian Ebner f.ebner at proxmox.com
Tue Nov 12 11:03:53 CET 2019


The minimum value for timeout in vm_shutdown is changed from 0 to 1, since a
value of 0 would trigger a hard stop for HA managed containers. Like this the
API description stays valid for all cases.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 src/PVE/API2/LXC/Status.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm
index 1b7a71d..20b376a 100644
--- a/src/PVE/API2/LXC/Status.pm
+++ b/src/PVE/API2/LXC/Status.pm
@@ -243,7 +243,7 @@ __PACKAGE__->register_method({
 
 		print "Requesting HA stop for CT $vmid\n";
 
-		my $cmd = ['ha-manager', 'set',  "ct:$vmid", '--state', 'stopped'];
+		my $cmd = ['ha-manager', 'crm-command', 'stop', "ct:$vmid", '0'];
 		PVE::Tools::run_command($cmd);
 	    };
 
@@ -291,7 +291,7 @@ __PACKAGE__->register_method({
 	    timeout => {
 		description => "Wait maximal timeout seconds.",
 		type => 'integer',
-		minimum => 0,
+		minimum => 1,
 		optional => 1,
 		default => 60,
 	    },
@@ -325,7 +325,7 @@ __PACKAGE__->register_method({
 
 		print "Requesting HA stop for CT $vmid\n";
 
-		my $cmd = ['ha-manager', 'set',  "ct:$vmid", '--state', 'stopped'];
+		my $cmd = ['ha-manager', 'crm-command', 'stop',  "ct:$vmid", "$timeout"];
 		PVE::Tools::run_command($cmd);
 	    };
 
-- 
2.20.1





More information about the pve-devel mailing list