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 89AE11FF0C0 for ; Wed, 18 Nov 2026 14:30:45 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 64FB0217CF; Wed, 18 Nov 2026 14:30:00 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH v2 manager 07/20] vzdump: stop all running backup jobs of the node Date: Wed, 18 Nov 2026 14:18:31 +0100 Message-ID: <20261118132947.1093069-8-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118132947.1093069-1-t.lamprecht@proxmox.com> References: <20261118132947.1093069-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795008592417 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.173 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: SJWGNOJT7UX3FLLBHGVL5AN6MFXIBDLY X-Message-ID-Hash: SJWGNOJT7UX3FLLBHGVL5AN6MFXIBDLY X-MailFrom: t.lamprecht@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 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Stopping running backups only signalled the job recorded in the pid file, which is the one holding the global lock. Jobs waiting for the lock went on afterwards, and once jobs can run alongside each other, the pid file cannot represent all of them anyway. Signal every backup task of the node instead, including those still waiting to start, and drop the pid file. As when stopping a task, the signal goes to the whole process group. Signed-off-by: Thomas Lamprecht Reviewed-by: Fiona Ebner --- changes v1 -> v2: - use PVE::UPID, say "processes" if several are left [Fiona] PVE/VZDump.pm | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index 92a48babf..9842069a7 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -22,6 +22,7 @@ use PVE::JSONSchema qw(get_standard_option); use PVE::Notify; use PVE::RPCEnvironment; use PVE::Storage; +use PVE::UPID; use PVE::VZDump::Common; use PVE::VZDump::Plugin; use PVE::Tools qw(extract_param split_list); @@ -44,7 +45,6 @@ PVE::JSONSchema::register_standard_option( my @posix_filesystems = qw(ext3 ext4 nfs nfs4 reiserfs xfs); my $lockfile = '/var/run/vzdump.lock'; -my $pidfile = '/var/run/vzdump.pid'; my $logdir = '/var/log/vzdump'; my @plugins = qw(); @@ -816,8 +816,6 @@ sub getlock { debugmsg('info', "got global lock", undef, 1); } - PVE::Tools::file_set_contents($pidfile, $upid); - return $SERVER_FLCK; } @@ -1515,8 +1513,6 @@ sub exec_backup { die $err if $err; die "job errors\n" if $errcount; - - unlink $pidfile; } sub option_exists { @@ -1581,26 +1577,27 @@ sub verify_vzdump_parameters { } sub stop_running_backups { - my ($self) = @_; + my $nodename = PVE::INotify::nodename(); - my $upid = PVE::Tools::file_read_firstline($pidfile); - return if !$upid; + my $running = []; + for my $worker (PVE::RPCEnvironment::get()->active_workers()->@*) { + my $task = PVE::UPID::decode($worker->{upid}, 1) or next; + next if $task->{type} ne 'vzdump' || $task->{node} ne $nodename; + next if !PVE::ProcFSTools::check_process_running($task->{pid}, $task->{pstart}); - my $task = PVE::Tools::upid_decode($upid); + # the whole process group, like stopping the task does + kill(15, -$task->{pid}); + push $running->@*, $task; + } - if ( - PVE::ProcFSTools::check_process_running($task->{pid}, $task->{pstart}) - && PVE::ProcFSTools::read_proc_starttime($task->{pid}) == $task->{pstart} - ) { - kill(15, $task->{pid}); - # wait max 15 seconds to shut down (else, do nothing for now) - my $i; - for ($i = 15; $i > 0; $i--) { - last if !PVE::ProcFSTools::check_process_running(($task->{pid}, $task->{pstart})); - sleep(1); - } - die "stopping backup process $task->{pid} failed\n" if $i == 0; + for (1 .. 15) { + $running = [grep { PVE::ProcFSTools::check_process_running($_->{pid}, $_->{pstart}) } + $running->@*]; + return if !scalar($running->@*); + sleep(1); } + my $what = scalar($running->@*) > 1 ? 'processes' : 'process'; + die "stopping backup $what " . join(', ', map { $_->{pid} } $running->@*) . " failed\n"; } sub get_included_guests { -- 2.47.3