* [pve-devel] [PATCH manager 1/2] vzdump: new: add add_error helper
@ 2022-04-19 8:45 Fabian Ebner
2022-04-19 8:45 ` [pve-devel] [PATCH manager 2/2] fix #3955: vzdump: new: also send mail for error during job-init hook Fabian Ebner
2022-04-27 8:38 ` [pve-devel] applied-series: [PATCH manager 1/2] vzdump: new: add add_error helper Thomas Lamprecht
0 siblings, 2 replies; 3+ messages in thread
From: Fabian Ebner @ 2022-04-19 8:45 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
PVE/VZDump.pm | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index f34a5969..bdf270f7 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -505,19 +505,21 @@ sub new {
PVE::Cluster::cfs_update(); # Pick up possible changes made by the hook script.
my $errors = '';
+ my $add_error = sub {
+ my ($error) = @_;
+ $errors .= "\n" if $errors;
+ chomp($error);
+ $errors .= $error;
+ };
if ($opts->{storage}) {
my $storage_cfg = PVE::Storage::config();
eval { PVE::Storage::activate_storage($storage_cfg, $opts->{storage}) };
- if (my $err = $@) {
- chomp($err);
- $errors .= "could not activate storage '$opts->{storage}': $err";
- }
+ $add_error->("could not activate storage '$opts->{storage}': $@") if $@;
my $info = eval { storage_info ($opts->{storage}) };
if (my $err = $@) {
- chomp($err);
- $errors .= "could not get storage information for '$opts->{storage}': $err";
+ $add_error->("could not get storage information for '$opts->{storage}': $err");
} else {
$opts->{dumpdir} = $info->{dumpdir};
$opts->{scfg} = $info->{scfg};
@@ -525,7 +527,7 @@ sub new {
$opts->{'prune-backups'} //= $info->{'prune-backups'};
}
} elsif ($opts->{dumpdir}) {
- $errors .= "dumpdir '$opts->{dumpdir}' does not exist"
+ $add_error->("dumpdir '$opts->{dumpdir}' does not exist")
if ! -d $opts->{dumpdir};
} else {
die "internal error";
@@ -537,8 +539,7 @@ sub new {
$opts->{remove} = 0 if $opts->{'prune-backups'}->{'keep-all'};
if ($opts->{tmpdir} && ! -d $opts->{tmpdir}) {
- $errors .= "\n" if $errors;
- $errors .= "tmpdir '$opts->{tmpdir}' does not exist";
+ $add_error->("tmpdir '$opts->{tmpdir}' does not exist");
}
if ($errors) {
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH manager 2/2] fix #3955: vzdump: new: also send mail for error during job-init hook
2022-04-19 8:45 [pve-devel] [PATCH manager 1/2] vzdump: new: add add_error helper Fabian Ebner
@ 2022-04-19 8:45 ` Fabian Ebner
2022-04-27 8:38 ` [pve-devel] applied-series: [PATCH manager 1/2] vzdump: new: add add_error helper Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Fabian Ebner @ 2022-04-19 8:45 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Fabian Ebner <f.ebner@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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] applied-series: [PATCH manager 1/2] vzdump: new: add add_error helper
2022-04-19 8:45 [pve-devel] [PATCH manager 1/2] vzdump: new: add add_error helper Fabian Ebner
2022-04-19 8:45 ` [pve-devel] [PATCH manager 2/2] fix #3955: vzdump: new: also send mail for error during job-init hook Fabian Ebner
@ 2022-04-27 8:38 ` Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2022-04-27 8:38 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Ebner
On 19.04.22 10:45, Fabian Ebner wrote:
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
> PVE/VZDump.pm | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
>
applied both patches, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-27 8:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 8:45 [pve-devel] [PATCH manager 1/2] vzdump: new: add add_error helper Fabian Ebner
2022-04-19 8:45 ` [pve-devel] [PATCH manager 2/2] fix #3955: vzdump: new: also send mail for error during job-init hook Fabian Ebner
2022-04-27 8:38 ` [pve-devel] applied-series: [PATCH manager 1/2] vzdump: new: add add_error helper Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox