-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/etcd3 support with tests #308
base: master
Are you sure you want to change the base?
Feature/etcd3 support with tests #308
Conversation
Update our nokia/skydns repo to the skydns' repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and thank you!
Bunch of comments.
@@ -16,6 +16,7 @@ import ( | |||
"fmt" | |||
"github.com/coreos/etcd/mvcc/mvccpb" | |||
"encoding/json" | |||
//"github.com/skynetservices/skydns/backends/etcd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arrgh, yea my bad, missed deleting that one.
@@ -41,11 +42,15 @@ func NewBackendv3 (client etcdv3.Client, ctx context.Context, config *Config) *B | |||
} | |||
|
|||
func (g *Backendv3) Records(name string, exact bool) ([]msg.Service, error) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, whitespace is not but clutters this PR a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay will remove the whitespaces a bit
return r, e | ||
} | ||
}) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
if resp == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this? Isn't err != nil enough to bail out. Why not?
if w == "*" || w == "any"{ | ||
return true; | ||
} | ||
if keyParts[i] != w && (!(w == "*" || w == "any")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this hard to parse, can we just add another if statement?
func (g *Backendv3) loopNodes(kv []*mvccpb.KeyValue, nameParts []string, star bool, bx map[bareService]bool) (sx []msg.Service, err error) { | ||
if bx == nil { | ||
bx = make(map[bareService]bool) | ||
} | ||
Nodes: | ||
for _, item := range kv { | ||
|
||
s := string(item.Key[:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the [:]
} | ||
|
||
const ( | ||
KEYNOTFOUND = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment where this value comes from?
Also, go nit, use CamelCase. And does it need to be exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value is arbitrary, so to respect on what skydns has been using with etcdv2 I used the value of 100.
@@ -20,6 +20,7 @@ import ( | |||
etcd "github.com/coreos/etcd/client" | |||
"github.com/coreos/go-systemd/activation" | |||
"github.com/miekg/dns" | |||
etcd3 "github.com/skynetservices/skydns/backends/etcd3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please sort this with the other skydns imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh noticed just now, it is sorted alphabetically. Okay will do
// etcNameError return a NameError to the client if the error | ||
// returned from etcd has ErrorCode == 100. | ||
func isEtcdNameError(err error, s *server) bool { | ||
func verdictEtcdV2(err error, s *server) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsEtcd2NameError?
} | ||
return false | ||
} | ||
|
||
func verdictEtcdV3(err error, s *server) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEtcd3NameError?
updated with cleanup based on comments. |
etcd3-support feature tests.
fully utilizes the ones available in the server_test.go for etcdv2.
Also included are bug fixes for the ones caught by the testcases.
PS:
with this we would need etcd v3 running in Travis.