]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
fix #4351: vzdump: send mail if job-end hook fails with mailnotification=failure
authorFiona Ebner <f.ebner@proxmox.com>
Wed, 16 Nov 2022 08:30:13 +0000 (09:30 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 16 Nov 2022 10:25:58 +0000 (11:25 +0100)
Since all tasks succeeded, previously no mail was sent in that case.

Note that the error passed to $self->sendmail() is added to the
subject of the mail if it is a single line or the beginning of the
mail otherwise. Thus changing the mail slightly compared to previously
for the case where the job-start hook fails and the case where the
job-end hook fails with mailnotification=always. But can be considered
an improvement, because the user sees the error right away.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
PVE/VZDump.pm

index d5b3c50028ff258c742848ee0ad6f54d4708e8a9..9ef3c7b4bd3bb7fa8db164bf571260c869177d11 100644 (file)
@@ -1305,10 +1305,14 @@ sub exec_backup {
     my $totaltime = time() - $starttime;
 
     eval {
+       # otherwise $self->sendmail() will interpret it as multiple problems
+       my $chomped_err = $err;
+       chomp($chomped_err) if $chomped_err;
+
        $self->sendmail(
            $tasklist,
            $totaltime,
-           undef,
+           $chomped_err,
            $self->{job_init_log} . $job_start_log,
            $job_end_log,
        );