From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3714F71295 for ; Fri, 24 Jun 2022 16:06:15 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 24A711024 for ; Fri, 24 Jun 2022 16:05:45 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D9A251018 for ; Fri, 24 Jun 2022 16:05:43 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9E8C943CA7 for ; Fri, 24 Jun 2022 16:05:43 +0200 (CEST) From: Daniel Tschlatscher To: pve-devel@lists.proxmox.com Date: Fri, 24 Jun 2022 16:02:09 +0200 Message-Id: <20220624140209.411405-1-d.tschlatscher@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.106 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH container v2] fix #3927: no error code when stopping a stopped container X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2022 14:06:15 -0000 Stopping a container that was already stopped now no longer returns an error code. This behaviour was adapted to match the return values for VMs, to get a more consistent API. Both VMs and containers now return an error when starting an already started guest, and both do not show an error when stopping an already stopped guest. Even though this is a really small change, some users might rely on the containers returning the error. Therefore, this should probably be considered a breaking change. This change also has another side effect: When the stop command for an HA-managed container was invoked, but the container would stop in the meantime (e.g. because it crashed, ...), a condition would arise which meant that the API call would die and never reach the HA manager. Therefore not updating the requested HA state for the container. As a result, the container would be started again once the next HA check was scheduled, in spite of the expected HA state being 'stopped' This patches fixes this issue and brings it more in line with the expected behaviour. Signed-off-by: Daniel Tschlatscher --- Changes from v2: * This patch no longer includes also changing the return codes for already started containers. src/PVE/API2/LXC/Status.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm index f7e3128..2c8fb4a 100644 --- a/src/PVE/API2/LXC/Status.pm +++ b/src/PVE/API2/LXC/Status.pm @@ -238,8 +238,6 @@ __PACKAGE__->register_method({ raise_param_exc({ skiplock => "Only root may use this option." }) if $skiplock && $authuser ne 'root@pam'; - die "CT $vmid not running\n" if !PVE::LXC::check_running($vmid); - if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') { my $hacmd = sub { @@ -260,6 +258,8 @@ __PACKAGE__->register_method({ syslog('info', "stopping CT $vmid: $upid\n"); + return if !PVE::LXC::check_running($vmid); + my $conf = PVE::LXC::Config->load_config($vmid); if (!$skiplock && !PVE::LXC::Config->has_lock($conf, 'mounted')) { PVE::LXC::Config->check_lock($conf); -- 2.30.2