Skip to content

Commit

Permalink
add cluster name while joining if there isn't already a cluster name …
Browse files Browse the repository at this point in the history
…configured (#2)
  • Loading branch information
charless-splunk authored Mar 26, 2019
1 parent 6ce1f71 commit 9a8ae20
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions embetcd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ func clusterNameConflicts(ctx context.Context, client *Client, clusterName strin
// then you run the risk of breaking quorum and stalling out on the cluster name check
resp, err = client.Get(ctx, "/name")
if err == nil {
if len(resp.Kvs) == 0 || string(resp.Kvs[0].Value) != clusterName {
err = ErrClusterNameConflict

if len(resp.Kvs) == 0 || string(resp.Kvs[0].Value) == "" {
_, _ = client.Put(ctx, "/name", clusterName)
return nil
}
if len(resp.Kvs) != 0 && string(resp.Kvs[0].Value) != clusterName {
return ErrClusterNameConflict
}
break
}
Expand Down

0 comments on commit 9a8ae20

Please sign in to comment.