From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 9B3C31FF0B0 for ; Fri, 09 Oct 2026 14:38:35 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D2A0121514; Fri, 09 Oct 2026 14:38:33 +0200 (CEST) From: Elias Huhsovitz To: pve-devel@lists.proxmox.com Subject: [PATCH manager v2] fix #8093: pvestatd: remove stale lxc console reaper Date: Fri, 9 Oct 2026 14:38:19 +0200 Message-ID: <20261009123819.136563-1-e.huhsovitz@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791549507716 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.522 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 7LLWVT5XWNUY5PLIXZYLOLJ5BHXHJQSJ X-Message-ID-Hash: 7LLWVT5XWNUY5PLIXZYLOLJ5BHXHJQSJ X-MailFrom: e.huhsovitz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Elias Huhsovitz X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: remove_stale_lxc_consoles() calls PVE::LXC::vmstatus() every cycle, which runs `lxc-info` once per running container. Since update_lxc_status() already calls vmstatus() in the same cycle, this doubles the overhead of running `lxc-info`. Thus, this overhead is scaling linearly with the number of containers. Under normal operation, lxc-console and dtach exit automatically when the container stops. The reaper only fires in broken system states, such as deleting the container config file while the container is still running. A continuous polling reaper is not an appropriate mechanism for these situations. Remove the reaper entirely. Signed-off-by: Elias Huhsovitz --- This patch removes the reaper entirely. No replacement mechanism is added. If a console process becomes orphaned due to manual system interference, the administrator can identify and kill it directly. A type of "replacement" machenanism that bridges this gap is currently being discussed [1], based on patch [2]. Alternatives considered ----------------------- * Wrapping console commands in transient systemd scopes bound via PartOf= to the container service. Verdict: rejected because lxc-stop ends the service without a systemd stop job, so PartOf= does not propagate. * A manual `pct cleanup console` CLI tool. Verdict: cleanup shouldn't be manual. * An ExecStopPost= hook on pve-container@.service. Changes v1->v2: --------------- * scrap the idea of binding console sessions to container lifetime via systemd scoopes. Previous versions ----------------- v1: https://lore.proxmox.com/pve-devel/20261007083726.26067-1-e.huhsovitz@proxmox.com/ References ---------- [1] https://lore.proxmox.com/pve-devel/82fceb8e-f52d-4e56-9dcf-5cd61393fa26@proxmox.com/ [2] https://lore.proxmox.com/pve-devel/20260121112335.84473-1-f.schauer@proxmox.com/ Summary of Changes ------------------ PVE/Service/pvestatd.pm | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm index 34f9da71..cec66e00 100755 --- a/PVE/Service/pvestatd.pm +++ b/PVE/Service/pvestatd.pm @@ -444,20 +444,6 @@ sub update_qemu_status { PVE::PullMetric::update($pull_txn, 'qemu', $vmstatus, $ctime); } -sub remove_stale_lxc_consoles { - - my $vmstatus = PVE::LXC::vmstatus(); - my $pidhash = PVE::LXC::find_lxc_console_pids(); - - foreach my $vmid (keys %$pidhash) { - next if defined($vmstatus->{$vmid}); - syslog('info', "remove stale lxc-console for CT $vmid"); - foreach my $pid (@{ $pidhash->{$vmid} }) { - kill(9, $pid); - } - } -} - my $rebalance_error_count = {}; my $NO_REBALANCE; @@ -848,10 +834,6 @@ sub update_status { $err = $@; syslog('err', "storage status update error: $err") if $err; - eval { remove_stale_lxc_consoles(); }; - $err = $@; - syslog('err', "lxc console cleanup error: $err") if $err; - eval { rotate_authkeys(); }; $err = $@; syslog('err', "authkey rotation error: $err") if $err; -- 2.47.3