From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage] fix #4289: pbs: wait for backup verification to finish before updating volume attribute
Date: Mon, 2 Jan 2023 13:36:33 +0100 [thread overview]
Message-ID: <20230102123633.2493599-3-c.heiss@proxmox.com> (raw)
In-Reply-To: <20230102123633.2493599-1-c.heiss@proxmox.com>
This fixes an "unable to set protected flag" error when backing up to a
PBS datastore that has the 'Verify New' flag set.
This happens due to the volume being locked for verifiying after the
backup completes, but before the request to update the 'protected'
volume flag is made.
Thus delay the volume flag update until the verify job is finished.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
PVE/Storage.pm | 4 ++--
PVE/Storage/PBSPlugin.pm | 27 ++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 89c7116..47cb266 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -248,7 +248,7 @@ sub get_volume_attribute {
}
sub update_volume_attribute {
- my ($cfg, $volid, $attribute, $value) = @_;
+ my ($cfg, $volid, $attribute, $value, $logfunc) = @_;
my ($storeid, $volname) = parse_volume_id($volid);
my $scfg = storage_config($cfg, $storeid);
@@ -278,7 +278,7 @@ sub update_volume_attribute {
}
}
- return $plugin->update_volume_attribute($scfg, $storeid, $volname, $attribute, $value);
+ return $plugin->update_volume_attribute($scfg, $storeid, $volname, $attribute, $value, $logfunc);
}
sub volume_size_info {
diff --git a/PVE/Storage/PBSPlugin.pm b/PVE/Storage/PBSPlugin.pm
index 4320974..1cdbc11 100644
--- a/PVE/Storage/PBSPlugin.pm
+++ b/PVE/Storage/PBSPlugin.pm
@@ -906,8 +906,30 @@ sub get_volume_attribute {
return;
}
+sub wait_for_verify_finish {
+ my ($conn, $node, $datastore, $attrs) = @_;
+
+ my $param = {
+ running => 'true',
+ since => $attrs->{'backup-time'},
+ store => $datastore,
+ typefilter => 'verify',
+ };
+
+ my $taskname = sprintf('%s:%s/%s/%X',
+ $datastore,
+ @{$attrs}{qw(backup-type backup-id backup-time)},
+ );
+
+ while (1) {
+ my $res = eval { $conn->get("/api2/json/nodes/$node/tasks", $param); };
+ last if !grep { $_->{worker_id} eq $taskname } @$res;
+ sleep(1);
+ }
+}
+
sub update_volume_attribute {
- my ($class, $scfg, $storeid, $volname, $attribute, $value) = @_;
+ my ($class, $scfg, $storeid, $volname, $attribute, $value, $logfunc) = @_;
if ($attribute eq 'notes') {
return $class->update_volume_notes($scfg, $storeid, $volname, $value);
@@ -921,6 +943,9 @@ sub update_volume_attribute {
my $conn = pbs_api_connect($scfg, $password);
my $datastore = $scfg->{datastore};
+ $logfunc->('info', 'waiting for server to finish backup verification...') if $logfunc;
+ wait_for_verify_finish($conn, $scfg->{server}, $datastore, $param);
+
eval { $conn->put("/api2/json/admin/datastore/$datastore/$attribute", $param); };
if (my $err = $@) {
die "Server is not recent enough to support feature '$attribute'\n"
--
2.30.2
next prev parent reply other threads:[~2023-01-02 12:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-02 12:36 [pve-devel] [PATCH manager/storage] fix #4289: " Christoph Heiss
2023-01-02 12:36 ` [pve-devel] [PATCH manager] vzdump: pass logfunc down into storage plugin when " Christoph Heiss
2023-01-02 12:36 ` Christoph Heiss [this message]
2023-01-04 10:50 ` [pve-devel] [PATCH storage] fix #4289: pbs: wait for backup verification to finish before " Fiona Ebner
2023-01-10 11:11 ` Christoph Heiss
2023-01-10 12:34 ` Fiona Ebner
2023-01-10 12:44 ` Christoph Heiss
[not found] ` <159837ba-f916-7b03-2cab-8e486b38b6bb@proxmox.com>
2023-01-10 13:21 ` Fiona Ebner
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=20230102123633.2493599-3-c.heiss@proxmox.com \
--to=c.heiss@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