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 D1A9F8342A for ; Fri, 3 Dec 2021 14:35:10 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D00B42583F for ; Fri, 3 Dec 2021 14:35:10 +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 1E2FE25826 for ; Fri, 3 Dec 2021 14:35:09 +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 E88DA44D8C for ; Fri, 3 Dec 2021 14:35:08 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Fri, 3 Dec 2021 14:35:08 +0100 Message-Id: <20211203133508.925393-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211203133508.925393-1-d.csapak@proxmox.com> References: <20211203133508.925393-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.177 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [jobs.pm, vzdump.pm] Subject: [pve-devel] [PATCH manager 1/1] vzdump: add 'logcomment' parameter 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: Fri, 03 Dec 2021 13:35:10 -0000 and use it from the jobs to log the job id and schedule Signed-off-by: Dominik Csapak --- PVE/API2/VZDump.pm | 6 ++++++ PVE/Jobs.pm | 2 +- PVE/Jobs/VZDump.pm | 3 ++- PVE/VZDump.pm | 5 +++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm index 2c0df4c3..1071add6 100644 --- a/PVE/API2/VZDump.pm +++ b/PVE/API2/VZDump.pm @@ -40,6 +40,12 @@ __PACKAGE__->register_method ({ description => "Write tar to stdout, not to a file.", optional => 1, }, + logcomment => { + type => 'string', + description => 'Text to log at the beginning of the backup.', + optional => 1, + maxLength => 2048, + }, }), }, returns => { type => 'string' }, diff --git a/PVE/Jobs.pm b/PVE/Jobs.pm index ba3685ec..f18ab8e7 100644 --- a/PVE/Jobs.pm +++ b/PVE/Jobs.pm @@ -238,7 +238,7 @@ sub run_jobs { my $plugin = PVE::Jobs::Plugin->lookup($type); if (starting_job($id, $type)) { - my $upid = eval { $plugin->run($cfg) }; + my $upid = eval { $plugin->run($cfg, $id, $schedule) }; if (my $err = $@) { warn $@ if $@; started_job($id, $type, undef, $err); diff --git a/PVE/Jobs/VZDump.pm b/PVE/Jobs/VZDump.pm index 44fe33dc..c12408b9 100644 --- a/PVE/Jobs/VZDump.pm +++ b/PVE/Jobs/VZDump.pm @@ -65,7 +65,7 @@ sub encode_value { } sub run { - my ($class, $conf) = @_; + my ($class, $conf, $id, $schedule) = @_; # remove all non vzdump related options foreach my $opt (keys %$conf) { @@ -78,6 +78,7 @@ sub run { } $conf->{quiet} = 1; # do not write to stdout/stderr + $conf->{logcomment} = "Job '$id' triggered by schedule '$schedule'.\n"; PVE::Cluster::cfs_update(); # refresh vmlist diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index b5a5fadd..d02aea52 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -462,6 +462,7 @@ sub new { cmdline => $cmdline, opts => $opts, skiplist => $skiplist, + logcomment => delete $opts->{logcomment}, }, $class; my $findexcl = $self->{findexcl} = []; @@ -1126,6 +1127,10 @@ sub exec_backup { debugmsg ('info', "starting new backup job: $self->{cmdline}", undef, 1); + if (my $text = $self->{logcomment}) { + debugmsg ('info', "$text", undef, 1); + } + if (scalar(@{$self->{skiplist}})) { my $skip_string = join(', ', sort { $a <=> $b } @{$self->{skiplist}}); debugmsg ('info', "skip external VMs: $skip_string"); -- 2.30.2