Skip to content

Commit

Permalink
Verbose error message and remove unwanted prints (signed)
Browse files Browse the repository at this point in the history
Signed-off-by: vlaxman-px <[email protected]>
  • Loading branch information
vlaxman-px committed Sep 21, 2023
1 parent 83a49a1 commit 1762429
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 4 additions & 2 deletions etcd/v3/kv_etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package etcdv3
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"math/rand"
"strconv"
Expand Down Expand Up @@ -734,7 +733,10 @@ func (et *etcdKV) LockWithTimeout(
}
}
if err != nil && time.Since(startTime) > lockTryDuration {
return nil, errors.New("Lock already taken")
currLockerTag := ec.LockerIDInfo{LockerID: ""}
if _, errGet := et.GetVal(key, &currLockerTag); errGet == nil {
return nil, fmt.Errorf("failed to take a lock on %v: lock taken by: %v ", key, currLockerTag.LockerID)
}
}
}
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions test/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,6 @@ func lockTimeoutError(kv kvdb.Kvdb, t *testing.T) {
assert.Nil(t, kvPair2, "Lock acquired incorrectly")
assert.NoError(t, err1, "Unexpected error while trying to acquire lock")
assert.Error(t, err2, "Unexpected behaviour")
// error return while failing to acquire lock
fmt.Println(err2)

err := kv.Unlock(kvPair1)
assert.NoError(t, err, "Unexpected error while unlock")
Expand All @@ -920,7 +918,6 @@ func lockTimeoutError(kv kvdb.Kvdb, t *testing.T) {
}

func lockBasic(kv kvdb.Kvdb, t *testing.T) {
fmt.Println("Starting lock basic")
lockMethods := getLockMethods(kv)

for _, lockMethod := range lockMethods {
Expand Down

0 comments on commit 1762429

Please sign in to comment.