Have consul state reutrn the lock ID

The lock ID isn't used because the lock is tied to the client, but
return the lock ID to match the behavior of other locks.
pull/11973/head
James Bardin 9 years ago
parent f2e496a14c
commit 67bbebce08

@ -120,7 +120,7 @@ func (c *RemoteClient) Lock(info *state.LockInfo) (string, error) {
lock, err := c.Client.LockOpts(opts)
if err != nil {
return "", nil
return "", err
}
c.consulLock = lock
@ -143,14 +143,15 @@ func (c *RemoteClient) Lock(info *state.LockInfo) (string, error) {
err = c.putLockInfo(info)
if err != nil {
err = multierror.Append(err, c.Unlock(""))
err = multierror.Append(err, c.Unlock(info.ID))
return "", err
}
return "", nil
return info.ID, nil
}
func (c *RemoteClient) Unlock(id string) error {
// this doesn't use the lock id, because the lock is tied to the consul client.
if c.consulLock == nil || c.lockCh == nil {
return nil
}

@ -85,6 +85,10 @@ func TestRemoteLocks(t *testing.T, a, b Client) {
t.Fatal("unable to obtain lock from client B")
}
if lockIDB == lockIDA {
t.Fatalf("duplicate lock IDs: %q", lockIDB)
}
if err = lockerB.Unlock(lockIDB); err != nil {
t.Fatal("error unlocking client B:", err)
}

Loading…
Cancel
Save