public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 manager 3/8] only use plugin after truthiness check
Date: Thu, 22 Oct 2020 12:30:12 +0200	[thread overview]
Message-ID: <20201022103017.19715-4-f.ebner@proxmox.com> (raw)
In-Reply-To: <20201022103017.19715-1-f.ebner@proxmox.com>

Commit 62fc2aa9fa2eb82596f98aa014d3b0ccfc0ec542 introduced
a usage of plugin before the truthiness check for plugin.

At the moment it might not be possible to trigger this anymore,
because of the guest inclusion rework that happened later on.
But to make tasks for inexistent guest IDs visibly fail again,
this check will be necessary. Also, to get the error message in
the mail, it needs to fail inside the eval block.

Thus, keep the check in the eval block and move the block of code
using the plugin to below the check.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/VZDump.pm | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index ee4e68b5..e6082f3b 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -672,25 +672,12 @@ sub exec_backup_task {
     my $cfg = PVE::Storage::config();
     my $vmid = $task->{vmid};
     my $plugin = $task->{plugin};
-    my $vmtype = $plugin->type();
 
     $task->{backup_time} = time();
 
     my $pbs_group_name;
     my $pbs_snapshot_name;
 
-    if ($self->{opts}->{pbs}) {
-	if ($vmtype eq 'lxc') {
-	    $pbs_group_name = "ct/$vmid";
-	} elsif  ($vmtype eq 'qemu') {
-	    $pbs_group_name = "vm/$vmid";
-	} else {
-	    die "pbs backup not implemented for plugin type '$vmtype'\n";
-	}
-	my $btime = strftime("%FT%TZ", gmtime($task->{backup_time}));
-	$pbs_snapshot_name = "$pbs_group_name/$btime";
-    }
-
     my $vmstarttime = time ();
 
     my $logfd;
@@ -708,6 +695,20 @@ sub exec_backup_task {
     eval {
 	die "unable to find VM '$vmid'\n" if !$plugin;
 
+	my $vmtype = $plugin->type();
+
+	if ($self->{opts}->{pbs}) {
+	    if ($vmtype eq 'lxc') {
+		$pbs_group_name = "ct/$vmid";
+	    } elsif  ($vmtype eq 'qemu') {
+		$pbs_group_name = "vm/$vmid";
+	    } else {
+		die "pbs backup not implemented for plugin type '$vmtype'\n";
+	    }
+	    my $btime = strftime("%FT%TZ", gmtime($task->{backup_time}));
+	    $pbs_snapshot_name = "$pbs_group_name/$btime";
+	}
+
 	# for now we deny backups of a running ha managed service in *stop* mode
 	# as it interferes with the HA stack (started services should not stop).
 	if ($opts->{mode} eq 'stop' &&
-- 
2.20.1





  parent reply	other threads:[~2020-10-22 10:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22 10:30 [pve-devel] [PATCH-SERIES v2 manager] Make backup with IDs for non-existent guests visibly fail Fabian Ebner
2020-10-22 10:30 ` [pve-devel] [PATCH v2 manager 1/8] remove unused variable Fabian Ebner
2020-10-22 10:30 ` [pve-devel] [PATCH v2 manager 2/8] remove outdated comment Fabian Ebner
2020-10-22 10:30 ` Fabian Ebner [this message]
2020-10-22 10:30 ` [pve-devel] [PATCH v2 manager 4/8] backup: include IDs for non-existent guests Fabian Ebner
2020-10-22 10:30 ` [pve-devel] [PATCH v2 manager 5/8] order guest IDs numerically in exec_backup Fabian Ebner
2020-10-22 10:30 ` [pve-devel] [PATCH v2 manager 6/8] sort the skip list numerically Fabian Ebner
2020-10-22 10:30 ` [pve-devel] [PATCH v2 manager 7/8] simplify get_included_vmids function Fabian Ebner
2020-10-22 10:30 ` [pve-devel] [RFC/PATCH v2 manager 8/8] don't group by node in get_included_guests Fabian Ebner
2020-10-22 16:52 ` [pve-devel] applied-partially: [PATCH-SERIES v2 manager] Make backup with IDs for non-existent guests visibly fail Thomas Lamprecht

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=20201022103017.19715-4-f.ebner@proxmox.com \
    --to=f.ebner@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