From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 1/1] vzdump: add 'logcomment' parameter
Date: Fri, 3 Dec 2021 14:35:08 +0100 [thread overview]
Message-ID: <20211203133508.925393-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211203133508.925393-1-d.csapak@proxmox.com>
and use it from the jobs to log the job id and schedule
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
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
prev parent reply other threads:[~2021-12-03 13:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-03 13:35 [pve-devel] [PATCH guest-common/manager] log id and schedule in backup job task Dominik Csapak
2021-12-03 13:35 ` [pve-devel] [PATCH guest-common 1/1] vzdump: skip 'logcomment' param for command_line Dominik Csapak
2021-12-03 13:35 ` Dominik Csapak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211203133508.925393-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox