public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] vzdump: add new 'next-run' field for vzdump job listing
Date: Thu,  2 Dec 2021 11:41:43 +0100	[thread overview]
Message-ID: <20211202104143.2565096-1-d.csapak@proxmox.com> (raw)

and calculate it by getting the next event after 'now' since
we currently have no way to get the last run time for jobs only running
on different cluster nodes

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/API2/Backup.pm        | 11 +++++++++++
 www/manager6/dc/Backup.js | 16 ++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/PVE/API2/Backup.pm b/PVE/API2/Backup.pm
index b1ad6afc..9953a704 100644
--- a/PVE/API2/Backup.pm
+++ b/PVE/API2/Backup.pm
@@ -16,6 +16,7 @@ use PVE::Exception qw(raise_param_exc);
 use PVE::VZDump;
 use PVE::VZDump::Common;
 use PVE::Jobs; # for VZDump Jobs
+use PVE::RS::CalendarEvent;
 
 use base qw(PVE::RESTHandler);
 
@@ -117,6 +118,16 @@ __PACKAGE__->register_method({
 	foreach my $jobid (sort { $order->{$a} <=> $order->{$b} } keys %$jobs) {
 	    my $job = $jobs->{$jobid};
 	    next if $job->{type} ne 'vzdump';
+
+	    if (my $schedule = $job->{schedule}) {
+		# vzdump jobs are cluster wide, there maybe was no local run
+		# so simply calculate from now
+		my $last_run = time();
+		my $calspec = PVE::RS::CalendarEvent->new($schedule);
+		my $next_run = $calspec->compute_next_event($last_run);
+		$job->{'next-run'} = $next_run if defined($next_run);
+	    }
+
 	    push @$res, $job;
 	}
 
diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index 6f2d39bb..409ba48f 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -765,6 +765,22 @@ Ext.define('PVE.dc.BackupView', {
 		    sorter: (a, b) => (a.data.comment || '').localeCompare(b.data.comment || ''),
 		    flex: 1,
 		},
+		{
+		    text: gettext('Next Run'),
+		    dataIndex: 'next-run',
+		    width: 150,
+		    renderer: function(value) {
+			if (!value) {
+			    return '-';
+			}
+
+			let now = new Date(), next = new Date(value * 1000);
+			if (next < now) {
+			    return gettext('pending');
+			}
+			return Proxmox.Utils.render_timestamp(value);
+		    },
+		},
 		{
 		    header: gettext('Retention'),
 		    dataIndex: 'prune-backups',
-- 
2.30.2





             reply	other threads:[~2021-12-02 10:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 10:41 Dominik Csapak [this message]
2021-12-02 10:43 ` Dominik Csapak

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=20211202104143.2565096-1-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal