Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

fbdlampayan
Copy link

@fbdlampayan fbdlampayan commented Nov 29, 2016

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.

Copy link

@miekg miekg left a 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"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Author

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) {

Copy link

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.

Copy link
Author

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 {
Copy link

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")) {
Copy link

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[:])
Copy link

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
Copy link

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?

Copy link
Author

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"
Copy link

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.

Copy link
Author

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 {
Copy link

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 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isEtcd3NameError?

@fbdlampayan
Copy link
Author

updated with cleanup based on comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants