public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH guest-common/manager] log id and schedule in backup job task
@ 2021-12-03 13:35 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 ` [pve-devel] [PATCH manager 1/1] vzdump: add 'logcomment' parameter Dominik Csapak
  0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2021-12-03 13:35 UTC (permalink / raw)
  To: pve-devel

by adding a generic 'logcomment' paramter and using it through the
jobs plugin

the patch in guest-common is only to filter it out when printing the
command line

(maybe we want a better name than 'logcomment' for the parameter though...)

pve-guest-common:

Dominik Csapak (1):
  vzdump: skip 'logcomment' param for command_line

 src/PVE/VZDump/Common.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

pve-manager:

Dominik Csapak (1):
  vzdump: add 'logcomment' parameter

 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(-)

-- 
2.30.2





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

* [pve-devel] [PATCH guest-common 1/1] vzdump: skip 'logcomment' param for command_line
  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 ` Dominik Csapak
  2021-12-03 13:35 ` [pve-devel] [PATCH manager 1/1] vzdump: add 'logcomment' parameter Dominik Csapak
  1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2021-12-03 13:35 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PVE/VZDump/Common.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/PVE/VZDump/Common.pm b/src/PVE/VZDump/Common.pm
index 83d7413..35bee49 100644
--- a/src/PVE/VZDump/Common.pm
+++ b/src/PVE/VZDump/Common.pm
@@ -376,7 +376,8 @@ sub command_line {
 
     foreach my $p (keys %$param) {
 	next if $p eq 'id' || $p eq 'vmid' || $p eq 'starttime' ||
-	        $p eq 'dow' || $p eq 'stdout' || $p eq 'enabled';
+	        $p eq 'dow' || $p eq 'stdout' || $p eq 'enabled' ||
+		$p eq 'logcomment';
 	my $v = $param->{$p};
 	my $pd = $confdesc->{$p} || die "no such vzdump option '$p'\n";
 	if ($p eq 'exclude-path') {
-- 
2.30.2





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

* [pve-devel] [PATCH manager 1/1] vzdump: add 'logcomment' parameter
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2021-12-03 13:35 UTC (permalink / raw)
  To: pve-devel

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





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

end of thread, other threads:[~2021-12-03 13:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pve-devel] [PATCH manager 1/1] vzdump: add 'logcomment' parameter Dominik Csapak

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