From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id BBCCF1FF0C0 for ; Wed, 18 Nov 2026 14:31:13 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 22D6D21853; Wed, 18 Nov 2026 14:30:06 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH v2 manager 09/20] vzdump: run job-init hook and set up target once the job may start Date: Wed, 18 Nov 2026 14:18:33 +0100 Message-ID: <20261118132947.1093069-10-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: 1795008592581 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: 5RM2UNAUMK7DQKL4BOKPGYTFMCDQS5UW X-Message-ID-Hash: 5RM2UNAUMK7DQKL4BOKPGYTFMCDQS5UW 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: The job-init hook and the activation of the backup storage ran before taking the global lock. A job waiting for another one thus already called its hook script, for example to mount or wake up its target, while the other job was still running, and then possibly waited for hours. Take the lock first and do the job setup afterwards, handling setup errors like a failure to get the lock. Hook scripts now see the job phases of different jobs strictly in sequence. Signed-off-by: Thomas Lamprecht --- no changes since v1 PVE/API2/VZDump.pm | 4 +++- PVE/VZDump.pm | 20 ++++++++++++-------- test/vzdump_new_test.pl | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm index ef3b9d169..4e59432f2 100644 --- a/PVE/API2/VZDump.pm +++ b/PVE/API2/VZDump.pm @@ -137,7 +137,9 @@ __PACKAGE__->register_method({ my $vzdump = PVE::VZDump->new($cmdline, $param, $skiplist); my $LOCK_FH = eval { - $vzdump->getlock($upid); # only one process allowed + my $lock_fh = $vzdump->getlock($upid); # only one process allowed + $vzdump->init_job(); + $lock_fh; }; if (my $err = $@) { chomp($err); # otherwise reported as multiple problems diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index 9842069a7..352c8f0ba 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -680,6 +680,16 @@ sub new { delete $opts->{$_} for qw(notes-template protected); } + $self->{'default-prune-backups'} = $defaults->{'prune-backups'}; + + return $self; +} + +sub init_job { + my ($self) = @_; + + my $opts = $self->{opts}; + my $errors = ''; my $add_error = sub { my ($error) = @_; @@ -720,7 +730,7 @@ sub new { die "internal error"; } - $opts->{'prune-backups'} //= $defaults->{'prune-backups'}; + $opts->{'prune-backups'} //= $self->{'default-prune-backups'}; # avoid triggering any remove code path if keep-all is set $opts->{remove} = 0 if $opts->{'prune-backups'}->{'keep-all'}; @@ -729,13 +739,7 @@ sub new { $add_error->("tmpdir '$opts->{tmpdir}' does not exist"); } - if ($errors) { - eval { $self->send_notification([], 0, $errors); }; - debugmsg('err', $@) if $@; - die "$errors\n"; - } - - return $self; + die "$errors\n" if $errors; } sub get_mount_info { diff --git a/test/vzdump_new_test.pl b/test/vzdump_new_test.pl index db829e70f..490ae4482 100755 --- a/test/vzdump_new_test.pl +++ b/test/vzdump_new_test.pl @@ -539,6 +539,7 @@ foreach my $test (@tests) { PVE::VZDump::parse_mailto_exclude_path($test->{cli_param}); my $vzdump = PVE::VZDump->new('fake cmdline', $test->{cli_param}, undef); + $vzdump->init_job(); my $opts = $vzdump->{opts} or die "did not get options\n"; -- 2.47.3