From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 5F44C61889 for ; Mon, 17 Jan 2022 16:37:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 51F051CD9A for ; Mon, 17 Jan 2022 16:37:39 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6AF761CD8F for ; Mon, 17 Jan 2022 16:37:38 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 279D9417D1 for ; Mon, 17 Jan 2022 16:37:38 +0100 (CET) Date: Mon, 17 Jan 2022 16:37:30 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20220117113559.77636-1-f.ebner@proxmox.com> <20220117113559.77636-2-f.ebner@proxmox.com> In-Reply-To: <20220117113559.77636-2-f.ebner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1642433537.xfl9w24g55.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.220 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH v2 manager 2/2] close #3476: vzdump: add job-init hook X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jan 2022 15:37:39 -0000 On January 17, 2022 12:35 pm, Fabian Ebner wrote: > which allows users to prepare the backup storage for activation (e.g. > by waking up a remote node). >=20 > Suggested-by: Fabian Gr=C3=BCnbichler > Signed-off-by: Fabian Ebner Reviewed-by: Fabian Gr=C3=BCnbichler =20 but giving others a chance to object to the new phase before applying ;) > --- >=20 > Changes from v1: > * Different approach: add a new hook rather than trying to re-use > job-start. > * Add example to the example hook script to clarify when job-init > should/can be used. >=20 > PVE/VZDump.pm | 17 ++++++++++++++++- > vzdump-hook-script.pl | 12 +++++++++++- > 2 files changed, 27 insertions(+), 2 deletions(-) >=20 > diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm > index b5a5fadd..e526eef8 100644 > --- a/PVE/VZDump.pm > +++ b/PVE/VZDump.pm > @@ -497,6 +497,13 @@ sub new { > $opts->{storage} =3D 'local'; > } > =20 > + $self->{job_init_log} =3D ''; > + 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 eventual changes made by the h= ook script. small nit for when this gets applied: s/eventual/possible eventual means 'final' or something else happening 'later'[0] (not=20 'eventuell' ;)) 0: https://www.merriam-webster.com/thesaurus/eventual > + > my $errors =3D ''; > =20 > if ($opts->{storage}) { > @@ -1194,7 +1201,15 @@ sub exec_backup { > =20 > my $totaltime =3D time() - $starttime; > =20 > - eval { $self->sendmail ($tasklist, $totaltime, undef, $job_start_log= , $job_end_log); }; > + eval { > + $self->sendmail( > + $tasklist, > + $totaltime, > + undef, > + $self->{job_init_log} . $job_start_log, > + $job_end_log, > + ); > + }; > debugmsg ('err', $@) if $@; > =20 > die $err if $err; > diff --git a/vzdump-hook-script.pl b/vzdump-hook-script.pl > index 60edbc04..81b9b10f 100755 > --- a/vzdump-hook-script.pl > +++ b/vzdump-hook-script.pl > @@ -11,11 +11,13 @@ print "HOOK: " . join (' ', @ARGV) . "\n"; > =20 > my $phase =3D shift; > =20 > -if ($phase eq 'job-start' || > +if ($phase eq 'job-init' || > + $phase eq 'job-start' || > $phase eq 'job-end' || > $phase eq 'job-abort') { > =20 > # undef for Proxmox Backup Server storages > + # undef in phase 'job-init' except when --dumpdir is used directly > my $dumpdir =3D $ENV{DUMPDIR}; > =20 > # undef when --dumpdir is used directly > @@ -26,6 +28,14 @@ if ($phase eq 'job-start' || > print "storeid=3D$storeid;" if defined($storeid); > print "\n"; > =20 > + # example: wake up remote storage node and enable storage > + if ($phase eq 'job-init') { > + #system ("") =3D=3D 0 || > + # die "waking up remote node failed"; > + #system ("/sbin/pvesm set $storeid --disable 0") =3D=3D 0 || > + # die "enabling storage $storeid failed"; > + } > + > # do what you want > =20 > } elsif ($phase eq 'backup-start' || > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20