public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH container/manager 0/2] fix #8093: console: bind console sessions to container lifetime via systemd scopes
@ 2026-10-07  8:37 Elias Huhsovitz
  2026-10-07  8:37 ` [PATCH manager 1/2] fix #8093: pvestatd: remove cleanup of stale lxc consoles Elias Huhsovitz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Elias Huhsovitz @ 2026-10-07  8:37 UTC (permalink / raw)
  To: pve-devel; +Cc: Elias Huhsovitz

The current Problem
-------------------
Console session processes can outlive their container when it stops or
is destroyed. The cleanup currently runs in pvestatd every 10 seconds.
It calls vmstatus() and kills stale processes by PID.

The killing of the process can result in a race condition:
If the console gets closed by something else, just before the kill
command is executed, a different process can reuse the PID and we kill
a completely unrelated process.

Also checking this every 10s is too much unnecessary overhead IMO.

My understanding of a "better" architecture
-------------------------------------------
IMO console deletion should be tied to the state of the underlying
container. Also I was unable to find a "convenient" time/event for a
cleanup job to run.

Proposed implementation
-----------------------
Wrap console commands in transient systemd scopes and bind them to the
container service via the PartOf= property. When the container stops,
systemd stops the scope, terminating the console session and the dtach
session. This allows removing the pvestatd periodic cleanup entirely.

Summary of Changes
------------------

pve-manager:

Elias Huhsovitz (1):
  fix #8093: pvestatd: remove cleanup of stale lxc consoles

 PVE/Service/pvestatd.pm | 18 ------------------
 1 file changed, 18 deletions(-)


pve-container:

Elias Huhsovitz (1):
  fix #8093: console: bind console sessions to container lifetime via
    systemd scopes

 src/PVE/API2/LXC.pm |  6 +++---
 src/PVE/CLI/pct.pm  | 10 +++++++---
 src/PVE/LXC.pm      | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 6 deletions(-)


Summary over all repositories:
  4 files changed, 51 insertions(+), 24 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-07 13:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07  8:37 [PATCH container/manager 0/2] fix #8093: console: bind console sessions to container lifetime via systemd scopes Elias Huhsovitz
2026-10-07  8:37 ` [PATCH manager 1/2] fix #8093: pvestatd: remove cleanup of stale lxc consoles Elias Huhsovitz
2026-10-07  8:37 ` [PATCH container 2/2] fix #8093: console: bind console sessions to container lifetime via systemd scopes Elias Huhsovitz
2026-10-07 13:38 ` [PATCH container/manager 0/2] " Filip Schauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal