Skip to content

Commit 5bc375d

Browse files
author
Matthew Fisher
committed
fix(*): suppress "Key already exists" errors
1 parent 9ba8dc2 commit 5bc375d

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

cache/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func publishService(client *etcd.Client, host string, etcdPath string,
105105

106106
func setEtcd(client *etcd.Client, key, value string, ttl uint64) {
107107
_, err := client.Set(key, value, ttl)
108-
if err != nil {
108+
if err != nil && !strings.Contains(err.Error(), "Key already exists") {
109109
log.Println(err)
110110
}
111111
}

logger/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"os/signal"
99
"strconv"
10+
"strings"
1011
"syscall"
1112
"time"
1213

@@ -67,7 +68,7 @@ func publishService(client *etcd.Client, host string, etcdPath string, port stri
6768

6869
func setEtcd(client *etcd.Client, key, value string, ttl uint64) {
6970
_, err := client.Set(key, value, ttl)
70-
if err != nil {
71+
if err != nil && !strings.Contains(err.Error(), "Key already exists") {
7172
log.Println(err)
7273
}
7374
}

router/boot.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"os/exec"
99
"os/signal"
10+
"strings"
1011
"syscall"
1112
"time"
1213

@@ -211,7 +212,7 @@ func setDefaultEtcd(client *etcd.Client, key, value string) {
211212

212213
func mkdirEtcd(client *etcd.Client, path string) {
213214
_, err := client.CreateDir(path, 0)
214-
if err != nil {
215+
if err != nil && !strings.Contains(err.Error(), "Key already exists") {
215216
log.Warn(err)
216217
}
217218
}

swarm/swarm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func publishService(client *etcd.Client, host string, ttl uint64) {
7575

7676
func setEtcd(client *etcd.Client, key, value string, ttl uint64) {
7777
_, err := client.Set(key, value, ttl)
78-
if err != nil {
78+
if err != nil && !strings.Contains(err.Error(), "Key already exists") {
7979
log.Println(err)
8080
}
8181
}

0 commit comments

Comments
 (0)