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

clientv3: handle stale endpoints, clean up logging #8714

Merged
merged 2 commits into from
Oct 19, 2017
Merged

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Oct 19, 2017

No description provided.

@gyuho gyuho requested a review from xiang90 October 19, 2017 17:49
@@ -152,7 +152,9 @@ func (b *simpleBalancer) pinned() string {
return b.pinAddr
}

func (b *simpleBalancer) endpointError(addr string, err error) { return }
func (b *simpleBalancer) endpointError(host string, err error) {
panic("'endpointError' not implemented")
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to panic here? probably should keep it as a noop.

// unhealthy tracks the last unhealthy time of endpoints.
unhealthy map[string]time.Time
// unhealthyHosts tracks unhealthy hosts.
unhealthyHosts map[string]time.Time
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we rename this host? host does not include port. do we really track host here? for example, if we have two endpoints: localhost:1111, localhost:1112, we only track them as host (localhost)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was trying to differentiate from up(addr grpc.Address) where addr is [scheme]://[host]:[port], where hb.host2ep contains [host]:[port]. addr is kind of confusing because we actually pass keys from host2ep. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

addr == endpoint, which contains the fqdn (scheme://host:port). we need to make this accurate. if it is host, then use host. or use endpoint or addr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

endpoint sounds better. Will change to endpoint.

Copy link
Contributor

Choose a reason for hiding this comment

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

if you want to be accurate, then change everything to hostport if it only contains host:port.

return func(rpcCtx context.Context, f rpcFunc) error {
for {
pinned := c.balancer.pinned()
err := f(rpcCtx)
if err == nil {
return nil
}
if logger.V(4) {
logger.Infof("clientv3/auth-retry: error %v on pinned endpoint %s", err, pinned)
Copy link
Contributor

Choose a reason for hiding this comment

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

keep this as it is.

// always stop retry on etcd errors other than invalid auth token
if rpctypes.Error(err) == rpctypes.ErrInvalidAuthToken {
gterr := c.getToken(rpcCtx)
if gterr != nil {
if logger.V(4) {
logger.Infof("clientv3/auth-retry: error %q(%q) on pinned endpoint %q (returning)", err.Error(), gterr.Error(), pinned)
Copy link
Contributor

Choose a reason for hiding this comment

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

log here that we cannot retry due to error x

return err // return the original error for simplicity
}
if logger.V(4) {
logger.Infof("clientv3/auth-retry: error %q on pinned endpoint %q (retrying)", err, pinned)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this.

@gyuho gyuho force-pushed the aaa branch 3 times, most recently from 0976b3f to 832e4a0 Compare October 19, 2017 18:28
@gyuho
Copy link
Contributor Author

gyuho commented Oct 19, 2017

@xiang90 All addressed. PTAL. Thanks.

@gyuho gyuho force-pushed the aaa branch 2 times, most recently from 3ca37a5 to fd7e638 Compare October 19, 2017 18:33
endpoints() []string
// pinned returns the current pinned endpoint.
pinned() string
// endpointError handles error from server-side.
endpointError(addr string, err error)
endpointError(hostPort string, err error)
Copy link
Contributor

Choose a reason for hiding this comment

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

hostport error?

if _, ok := hb.hostPort2ep[k]; !ok {
delete(hb.unhealthy, k)
if logger.V(4) {
logger.Infof("clientv3/health-balancer: removes stale endpoint %q from unhealthy", k)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove stale hostport

}
}

func (hb *healthBalancer) mayPin(addr grpc.Address) bool {
hb.mu.RLock()
if _, ok := hb.hostPort2ep[addr.Addr]; !ok { // stale endpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

add.Addr is in host:port format?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor

@xiang90 xiang90 Oct 19, 2017

Choose a reason for hiding this comment

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

stale hostport on comments

}
// always stop retry on etcd errors other than invalid auth token
if rpctypes.Error(err) == rpctypes.ErrInvalidAuthToken {
gterr := c.getToken(rpcCtx)
if gterr != nil {
if logger.V(4) {
logger.Infof("clientv3/auth-retry: cannot retry due to error %q(%q) on pinned endpoint %q (returning)", err.Error(), gterr.Error(), pinned)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove (returning)

@@ -40,12 +40,12 @@ type balancer interface {
grpc.Balancer
ConnectNotify() <-chan struct{}

endpoint(host string) string
endpoint(hostPort string) string
endpoints() []string
// pinned returns the current pinned endpoint.
pinned() string
// endpointError handles error from server-side.
Copy link
Contributor

Choose a reason for hiding this comment

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

update comment.

@xiang90
Copy link
Contributor

xiang90 commented Oct 19, 2017

lgtm

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

Successfully merging this pull request may close these issues.

2 participants