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

Fix retries to create consul client #610

Merged
merged 1 commit into from
Apr 27, 2017
Merged

Fix retries to create consul client #610

merged 1 commit into from
Apr 27, 2017

Conversation

fdawg4l
Copy link
Contributor

@fdawg4l fdawg4l commented Apr 27, 2017

The retry loop in NewConsulClient in kvstore was off by one. Added test to test the
retry behavior and a successful connection using a mock server.

@fdawg4l
Copy link
Contributor Author

fdawg4l commented Apr 27, 2017

Interesting. Looks like jenkins isn't using go1.8 which defines srv.Close(). No problem. I'll modify.

==> cilium-master: # github.com/cilium/cilium/pkg/kvstore
==> cilium-master: pkg/kvstore/consul_test.go:41: srv.Close undefined (type *http.Server has no field or method Close)```

Copy link
Contributor

@aalemayhu aalemayhu left a comment

Choose a reason for hiding this comment

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

Hei @fdawg4l , thanks for the PR. You are missing a Signed-off-by on your last commit. It would also be nice if your commit message started with a topic prefix like kvstore: or consul:. See previous commits for examples.

handler = func(w http.ResponseWriter, r *http.Request) {
triesAttempted++
io.WriteString(w, "\"nanananananananananleaaderrrr\"")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What does nanananananananananleaaderrrr mean? Please change it to something more meaningful.

Copy link
Member

Choose a reason for hiding this comment

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

It's just a test string :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is just a test string. And it's from The Simpsons. Because leader election... :-). https://www.youtube.com/watch?v=1aYN5XpWzpM

Copy link
Member

@tgraf tgraf left a comment

Choose a reason for hiding this comment

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

@fdawg4l
Copy link
Contributor Author

fdawg4l commented Apr 27, 2017

I'll squash my commits, include the SOA, and add the consul: verbiage to the commit summary. Thanks!

@fdawg4l
Copy link
Contributor Author

fdawg4l commented Apr 27, 2017

Interesting; the test failed. It seems buggy. I'll take a look. Please standby. Apologies!

The retry loop in NewConsulClient in kvstore was off by one.  Added test
to test the retry behavior and a successful connection using a mock
server.

Signed-off-by: Faiyaz Ahmed <faiyaza@gmail.com>
@fdawg4l
Copy link
Contributor Author

fdawg4l commented Apr 27, 2017

I couldn't repro locally, and to be honest i have no idea why it failed. It smells like it's because the handler is run asynchronously, but the error is only returned by the client after the handler runs. So the error collected (and tries count increment) should always happen in order. But it still failed. In any case, i refactored it with a channel which is only closed after maxRetries is reached.

...This change really wasn't suppose to be such a saga. Apologies :-). And thanks!

@tgraf
Copy link
Member

tgraf commented Apr 27, 2017

...This change really wasn't suppose to be such a saga. Apologies :-). And thanks!

Awesome work. Thanks!

@tgraf tgraf merged commit d8f4beb into cilium:master Apr 27, 2017
borkmann pushed a commit that referenced this pull request Apr 27, 2017
Related-to: #610 (Fix retries to create consul client)
Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
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.

3 participants