From c09b0af556d1206041953356ec8f73ec2c97be0a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 29 Apr 2020 10:52:51 +0200 Subject: [PATCH] cfs_lock: re-raise exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit so that API paths that raise an exception while holding a CFS lock properly propagate that exception to the client, instead of the stringified version with added noise about locks added to the front. Signed-off-by: Fabian Grünbichler --- data/PVE/Cluster.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm index b4de989..cce681b 100644 --- a/data/PVE/Cluster.pm +++ b/data/PVE/Cluster.pm @@ -609,7 +609,13 @@ my $cfs_lock = sub { alarm($prev_alarm); if ($err) { - $@ = "error with cfs lock '$lockid': $err"; + if (ref($err) eq 'PVE::Exception') { + # re-raise defined exceptions + $@ = $err; + } else { + # add lock info for plain errors + $@ = "error with cfs lock '$lockid': $err"; + } return undef; } -- 2.39.2