public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager 1/2] fix #4351: vzdump: send mail if job-end hook fails with mailnotification=failure
@ 2022-11-16  8:30 Fiona Ebner
  2022-11-16  8:30 ` [pve-devel] [PATCH manager 2/2] vzdump: send mail if job-abort hook fails Fiona Ebner
  2022-11-16 10:31 ` [pve-devel] applied-series: [PATCH manager 1/2] fix #4351: vzdump: send mail if job-end hook fails with mailnotification=failure Fabian Grünbichler
  0 siblings, 2 replies; 3+ messages in thread
From: Fiona Ebner @ 2022-11-16  8:30 UTC (permalink / raw)
  To: pve-devel

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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index d5b3c500..9ef3c7b4 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -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,
 	);
-- 
2.30.2





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

* [pve-devel] [PATCH manager 2/2] vzdump: send mail if job-abort hook fails
  2022-11-16  8:30 [pve-devel] [PATCH manager 1/2] fix #4351: vzdump: send mail if job-end hook fails with mailnotification=failure Fiona Ebner
@ 2022-11-16  8:30 ` Fiona Ebner
  2022-11-16 10:31 ` [pve-devel] applied-series: [PATCH manager 1/2] fix #4351: vzdump: send mail if job-end hook fails with mailnotification=failure Fabian Grünbichler
  1 sibling, 0 replies; 3+ messages in thread
From: Fiona Ebner @ 2022-11-16  8:30 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/VZDump.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 9ef3c7b4..a04837e7 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -1287,9 +1287,9 @@ sub exec_backup {
     };
     my $err = $@;
 
-    $self->run_hook_script ('job-abort', undef, $job_end_fd) if $err;
-
     if ($err) {
+	eval { $self->run_hook_script ('job-abort', undef, $job_end_fd); };
+	$err .= $@ if $@;
 	debugmsg ('err', "Backup job failed - $err", undef, 1);
     } else {
 	if ($errcount) {
-- 
2.30.2





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

* [pve-devel] applied-series: [PATCH manager 1/2] fix #4351: vzdump: send mail if job-end hook fails with mailnotification=failure
  2022-11-16  8:30 [pve-devel] [PATCH manager 1/2] fix #4351: vzdump: send mail if job-end hook fails with mailnotification=failure Fiona Ebner
  2022-11-16  8:30 ` [pve-devel] [PATCH manager 2/2] vzdump: send mail if job-abort hook fails Fiona Ebner
@ 2022-11-16 10:31 ` Fabian Grünbichler
  1 sibling, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2022-11-16 10:31 UTC (permalink / raw)
  To: Proxmox VE development discussion

thanks!

On November 16, 2022 9:30 am, Fiona Ebner wrote:
> 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 | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
> index d5b3c500..9ef3c7b4 100644
> --- a/PVE/VZDump.pm
> +++ b/PVE/VZDump.pm
> @@ -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,
>  	);
> -- 
> 2.30.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




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

end of thread, other threads:[~2022-11-16 10:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16  8:30 [pve-devel] [PATCH manager 1/2] fix #4351: vzdump: send mail if job-end hook fails with mailnotification=failure Fiona Ebner
2022-11-16  8:30 ` [pve-devel] [PATCH manager 2/2] vzdump: send mail if job-abort hook fails Fiona Ebner
2022-11-16 10:31 ` [pve-devel] applied-series: [PATCH manager 1/2] fix #4351: vzdump: send mail if job-end hook fails with mailnotification=failure Fabian Grünbichler

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