[pve-devel] [PATCH manager 2/2] fix #3955: vzdump: new: also send mail for error during job-init hook

Fabian Ebner f.ebner at proxmox.com
Tue Apr 19 10:45:22 CEST 2022


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/VZDump.pm | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index bdf270f7..3a394db7 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -497,13 +497,6 @@ sub new {
 	$opts->{storage} = 'local';
     }
 
-    $self->{job_init_log} = '';
-    open my $job_init_fd, '>', \$self->{job_init_log};
-    $self->run_hook_script('job-init', undef, $job_init_fd);
-    close $job_init_fd;
-
-    PVE::Cluster::cfs_update(); # Pick up possible changes made by the hook script.
-
     my $errors = '';
     my $add_error = sub {
 	my ($error) = @_;
@@ -512,6 +505,16 @@ sub new {
 	$errors .= $error;
     };
 
+    eval {
+	$self->{job_init_log} = '';
+	open my $job_init_fd, '>', \$self->{job_init_log};
+	$self->run_hook_script('job-init', undef, $job_init_fd);
+	close $job_init_fd;
+
+	PVE::Cluster::cfs_update(); # Pick up possible changes made by the hook script.
+    };
+    $add_error->($@) if $@;
+
     if ($opts->{storage}) {
 	my $storage_cfg = PVE::Storage::config();
 	eval { PVE::Storage::activate_storage($storage_cfg, $opts->{storage}) };
-- 
2.30.2






More information about the pve-devel mailing list