]> git.proxmox.com Git - pve-cluster.git/commitdiff
cfs lock: avoid confusing lock prefix on error
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 22 Apr 2021 19:38:26 +0000 (21:38 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 22 Apr 2021 19:40:30 +0000 (21:40 +0200)
we have lots of forum posts where users think that the locking was
the error, not the actual error message from the called code.

This has limited value as general-applied prefix, if a code requires
the lockid or whatever to be included in the error message they can
already do so, so just re-raise the error and be done, at least if it
is a error from the code and not from the lock setup,.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/Cluster.pm

index 8ed1db55575a362e4d510b9453c9f39e634dfc9f..91eda72ec725859b2f66cd5b1e9936bcf5ba3963 100644 (file)
@@ -583,6 +583,7 @@ my $cfs_lock = sub {
 
     my $filename = "$lockdir/$lockid";
 
+    my $is_code_err = 0;
     eval {
 
        mkdir $lockdir;
@@ -610,11 +611,13 @@ my $cfs_lock = sub {
 
        # fixed command timeout: cfs locks have a timeout of 120
        # using 60 gives us another 60 seconds to abort the task
-       local $SIG{ALRM} = sub { die "got lock timeout - aborting command\n"; };
+       local $SIG{ALRM} = sub { die "'$lockid'-locked command timed out - aborting\n"; };
        alarm(60);
 
        cfs_update(); # make sure we read latest versions inside code()
 
+       $is_code_err = 1; # allows to differ between locking and actual-work errors
+
        $res = &$code(@param);
 
        alarm(0);
@@ -629,12 +632,12 @@ my $cfs_lock = sub {
     alarm($prev_alarm);
 
     if ($err) {
-       if (ref($err) eq 'PVE::Exception') {
+       if (ref($err) eq 'PVE::Exception' || $is_code_err) {
            # re-raise defined exceptions
            $@ = $err;
        } else {
-           # add lock info for plain errors
-           $@ = "error during cfs-locked '$lockid' operation: $err";
+           # add lock info for plain errors comming from the locking itself
+           $@ = "cfs-lock '$lockid' error: $err";
        }
         return undef;
     }