Skip to content

Commit 4dbddc6

Browse files
committed
fix for netplugin service registeration repetitive failures
1 parent 50d58db commit 4dbddc6

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

etcdLock.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ func (ep *Lock) waitForLock() {
285285

286286
// Refresh lock
287287
func (ep *Lock) refreshLock() {
288-
// Refresh interval is 40% of TTL
289-
refreshIntvl := time.Second * time.Duration(ep.ttl*3/10)
288+
// Refresh interval is 1/3rd of TTL
289+
refreshIntvl := time.Second * time.Duration(ep.ttl/3)
290290
keyName := "/contiv.io/lock/" + ep.name
291291

292292
// Loop forever

etcdService.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,13 @@ func refreshService(client *etcd.Client, keyName string, keyVal string, stopChan
269269

270270
_, err := client.Update(keyName, keyVal, SERVICE_TTL)
271271
if err != nil {
272-
log.Errorf("Error updating key %s, Err: %v", keyName, err)
272+
log.Warnf("Error updating key %s, Err: %v", keyName, err)
273+
// In case of a TTL expiry, this key may have been deleted
274+
// from the etcd db. Hence use of Set instead of Update
275+
_, err := client.Set(keyName, keyVal, SERVICE_TTL)
276+
if err != nil {
277+
log.Errorf("Error setting key %s, Err: %v", keyName, err)
278+
}
273279
}
274280

275281
case <-stopChan:

0 commit comments

Comments
 (0)