mirror of
git://git.proxmox.com/git/pve-cluster.git
synced 2025-03-12 20:58:25 +03:00
cfs lock: avoid confusing lock prefix on error
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>
This commit is contained in:
parent
4942611503
commit
e085fe6f9f
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user