-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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: Do no stop keep alive loop by server side errors #7890
Conversation
746697f
to
4fa2607
Compare
Codecov Report
@@ Coverage Diff @@
## master #7890 +/- ##
=========================================
Coverage ? 76.04%
=========================================
Files ? 332
Lines ? 26233
Branches ? 0
=========================================
Hits ? 19950
Misses ? 4867
Partials ? 1416
Continue to review full report at Codecov.
|
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.
looks ok in general
clientv3/client.go
Outdated
if err == nil { | ||
return false | ||
} | ||
if err != context.Canceled && err != context.DeadlineExceeded { |
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.
return err == context.Canceled || err == context.DeadlineExceeded
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.
Fixed. I just wanted to return true
at the end of the function (now it's false
, false
, true
, false
).
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.
huh? the if isn't needed, the predicate can be returned directly..
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.
ah! sorry, I misunderstood your first comment (I thought it was a if
statement). Yes, your way is much simpler and easy to understand :) Fixed!
clientv3/lease.go
Outdated
} | ||
|
||
err = toErr(l.stopCtx, err) | ||
if err == rpctypes.ErrNoLeader { |
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.
if toErr(l.stopCtx, err) == rpctypes.ErrNoLeader
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.
Fixed
5cb3418
to
cf7eac5
Compare
lgtm |
clientv3/client.go
Outdated
@@ -503,3 +503,14 @@ func toErr(ctx context.Context, err error) error { | |||
} | |||
return err | |||
} | |||
|
|||
func canceledByCaller(ctx context.Context, err error) bool { | |||
if ctx.Err() == 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.
if ctx.Err() == nil || err == nil {
return false
}
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.
probably also rename ctx to stopCtx.
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.
Thanks. Done.
cf7eac5
to
aa85b0c
Compare
@yudai We probably want a test to cover this. It can be a different PR though. LGTM. |
@xiang90 Adding a test could take a little bit time. Because I think we need a mock server that returns unexpected (not in |
CI is fixed on master. Merging. |
For #7880