Skip to content

Commit

Permalink
Fix a bug in ket refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
shaleman committed Mar 25, 2016
1 parent 606217c commit aae4e15
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ func testLockAcquireKill(t *testing.T, dbclient API) {
}
}()

time.Sleep(time.Second * 2)
time.Sleep(time.Second * time.Duration(lockTTL*2))

log.Infof("2s timer. killing Lock1")
log.Infof("%ds timer. killing Lock1", (2 * lockTTL))
// At this point, lock1 should be holding the lock
if !lock1.IsAcquired() {
t.Fatalf("Lock1 failed to acquire lock")
Expand Down Expand Up @@ -566,7 +566,7 @@ func testServiceRegisterDeregister(t *testing.T, dbClient API) {
}

// Wait a while to make sure background refresh is working correctly
time.Sleep(time.Duration(srvTTL * 2))
time.Sleep(time.Duration(srvTTL*2) * time.Second)

resp, err = dbClient.GetService("athena")
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion etcdLock.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package objdb

import (
"strings"
"sync"
"time"

Expand Down Expand Up @@ -349,7 +350,8 @@ func (lk *etcdLock) watchLock() {
}
for {
resp, err := watcher.Next(lk.watchCtx)
if err != nil && err.Error() == client.ErrClusterUnavailable.Error() {
if err != nil && (err.Error() == client.ErrClusterUnavailable.Error() ||
strings.Contains(err.Error(), "context canceled")) {
log.Infof("Stopping watch on key %s", keyName)
return
} else if err != nil {
Expand Down
1 change: 1 addition & 0 deletions etcdService.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func (ep *EtcdClient) RegisterService(serviceInfo ServiceInfo) error {
// create service state
srvState := etcdServiceState{
ServiceName: serviceInfo.ServiceName,
KeyName: keyName,
TTL: ttl,
HostAddr: serviceInfo.HostAddr,
Port: serviceInfo.Port,
Expand Down

0 comments on commit aae4e15

Please sign in to comment.