]> git.proxmox.com Git - pve-manager.git/commitdiff
vzdump: add new 'next-run' field for vzdump job listing
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 2 Dec 2021 10:41:43 +0000 (11:41 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 13 Jan 2022 14:33:41 +0000 (15:33 +0100)
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
www/manager6/dc/Backup.js

index b1ad6afc7c662ea611b4465ce36dedd236b6631e..9953a704278301f26e1500e54b9720bd57d25e60 100644 (file)
@@ -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;
        }
 
index 6395ea2b74073617afe1ba2ae5edca65809046a2..e92ae4aa7425e380046ce5ee4908cb5239919cbb 100644 (file)
@@ -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',