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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 52AC996A5B for ; Thu, 26 Jan 2023 09:33:29 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AED61201CE for ; Thu, 26 Jan 2023 09:32:58 +0100 (CET) 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 for ; Thu, 26 Jan 2023 09:32:56 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DF85046584 for ; Thu, 26 Jan 2023 09:32:55 +0100 (CET) From: Friedrich Weber To: pve-devel@lists.proxmox.com Date: Thu, 26 Jan 2023 09:32:10 +0100 Message-Id: <20230126083214.711099-1-f.weber@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.796 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [status.pm, qemu.pm, proxmox.com, guesthelpers.pm] Subject: [pve-devel] [RFC manager/container/qemu-server/guest-common 0/4] fix #4474: stop tasks may overrule shutdown tasks 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: Thu, 26 Jan 2023 08:33:29 -0000 As reported in #4474 [0], a user may attempt to shutdown a VM/CT, realize that it is unresponsive, and decide to stop it instead. If the shutdown task has not timed out yet, the stop task will fail. The user needs to manually abort the shutdown task before stopping the VM, which is inconvenient. With this patch series, a stop task can optionally overrule active shutdown tasks. Summary of changes: * Backend: We add a new optional `overrule-shutdown` parameter to VM/CT `/stop` endpoints. If it is 1, we query for active `qmshutdown`/`vzshutdown` tasks by the current user for the given VMID, and abort them before attempting to stop the VM/CT. * Frontend: Before sending a stop command, we check whether there are active shutdown tasks. If yes, we ask the user whether they should be aborted, and send `overrule-shutdown=1` accordingly. Tested with a hung CentOS 7 container and a Debian VM where I edited /etc/systemd/logind.conf to set `HandlePowerKey=ignore`. Sending this as RFC, to make a first proposal and iterate from there. My most important questions: * Does it make sense to have overruling optional? Or should "stop" generally overrule shutdown? This might lead to confusing interactions, as Thomas noted [0]. * Backend: Is there a more elegant way to overrule shutdown tasks, and a better place than pve-guest-common? * Frontend: When stopping a VM/CT, we already ask for confirmation. Is an (occasional) second modal dialog with a lot of text a good user experience? Alternatively, I could imagine a checkbox in the first dialog saying "Overrule any active shutdown tasks". * This patch series forbids `overrule-shutdown=1` for HA-managed VMs/CTs because I didn't know how overruling should work in a HA setting. Do you have any suggestions? Since this is my first patch with more than a few lines, I'm especially happy about feedback regarding coding style, naming, anything. :) [0]: https://bugzilla.proxmox.com/show_bug.cgi?id=4474 pve-manager: Friedrich Weber (1): fix #4474: ui: vm stop: ask if active shutdown tasks should be aborted www/manager6/Utils.js | 27 +++++++++++++++++++++++++++ www/manager6/dc/Tasks.js | 2 +- www/manager6/lxc/CmdMenu.js | 14 +++++++++++++- www/manager6/lxc/Config.js | 6 +++++- www/manager6/qemu/CmdMenu.js | 14 +++++++++++++- www/manager6/qemu/Config.js | 9 ++++++++- 6 files changed, 67 insertions(+), 5 deletions(-) pve-container: Friedrich Weber (1): fix #4474: lxc api: add overrule-shutdown parameter to stop endpoint src/PVE/API2/LXC/Status.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) qemu-server: Friedrich Weber (1): fix #4474: qemu api: add overrule-shutdown parameter to stop endpoint PVE/API2/Qemu.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) pve-guest-common: Friedrich Weber (1): guest helpers: add helper to overrule active tasks of a specific type src/PVE/GuestHelpers.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.30.2