Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2720)

Issue 84540044: state/apiserver: connection dies when State dead

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years ago by rog
Modified:
10 years ago
Reviewers:
dimitern, mp+214303
Visibility:
Public.

Description

state/apiserver: connection dies when State dead When the State connection has died (for example because of a Mongo leadership change or a server going down) we want to make it reconnect, so we make the Server die when that happens. https://code.launchpad.net/~rogpeppe/juju-core/539-apiserver-mongo-ping/+merge/214303 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : state/apiserver: connection dies when State dead #

Total comments: 10

Patch Set 3 : state/apiserver: connection dies when State dead #

Unified diffs Side-by-side diffs Delta from patch set Stats (+112 lines, -21 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M juju/testing/conn.go View 1 chunk +11 lines, -3 lines 0 comments Download
M provider/dummy/environs.go View 1 2 2 chunks +12 lines, -4 lines 0 comments Download
M state/apiserver/admin.go View 1 chunk +1 line, -1 line 0 comments Download
M state/apiserver/apiserver.go View 1 3 chunks +24 lines, -0 lines 0 comments Download
M state/apiserver/export_test.go View 1 chunk +4 lines, -3 lines 0 comments Download
M state/apiserver/pinger_test.go View 1 2 3 chunks +35 lines, -2 lines 0 comments Download
M state/apiserver/root.go View 1 chunk +13 lines, -5 lines 0 comments Download
M testing/mgo.go View 2 chunks +10 lines, -3 lines 0 comments Download

Messages

Total messages: 3
rog
Please take a look.
10 years ago (2014-04-04 16:27:33 UTC) #1
dimitern
LGTM with a few suggestions. https://codereview.appspot.com/84540044/diff/20001/juju/testing/conn.go File juju/testing/conn.go (right): https://codereview.appspot.com/84540044/diff/20001/juju/testing/conn.go#newcode262 juju/testing/conn.go:262: serverAlive := testing.MgoServer.Addr() != ...
10 years ago (2014-04-04 16:42:37 UTC) #2
rog
10 years ago (2014-04-04 17:06:32 UTC) #3
Please take a look.

https://codereview.appspot.com/84540044/diff/20001/juju/testing/conn.go
File juju/testing/conn.go (right):

https://codereview.appspot.com/84540044/diff/20001/juju/testing/conn.go#newco...
juju/testing/conn.go:262: serverAlive := testing.MgoServer.Addr() != ""
On 2014/04/04 16:42:37, dimitern wrote:
> Is this enough to decide whether the server is up or not?

yes. (that's the test that's already used in some places)

https://codereview.appspot.com/84540044/diff/20001/provider/dummy/environs.go
File provider/dummy/environs.go (right):

https://codereview.appspot.com/84540044/diff/20001/provider/dummy/environs.go...
provider/dummy/environs.go:686: func mongoAlive() bool {
On 2014/04/04 16:42:37, dimitern wrote:
> Please add a doc comment here describing why that's checked.

Done.

https://codereview.appspot.com/84540044/diff/20001/state/apiserver/apiserver.go
File state/apiserver/apiserver.go (right):

https://codereview.appspot.com/84540044/diff/20001/state/apiserver/apiserver....
state/apiserver/apiserver.go:237: case <-timer.C:
On 2014/04/04 16:42:37, dimitern wrote:
> Why is this case doing nothing? Shouldn't we call the Ping code below in this
> case instead in tomb.Dying() case?

that's what we do.
the dying case returns. when the timer fires we fall through.

https://codereview.appspot.com/84540044/diff/20001/state/apiserver/apiserver....
state/apiserver/apiserver.go:242: logger.Infof("got error pinging mongo: %v",
err)
On 2014/04/04 16:42:37, dimitern wrote:
> msg := fmt.Sprintf("got error pinging mongo: %v", err)
> logger.Infof(msg)
> return fmt.Errorf(msg)
> 
> ?

They're different messages and should remain so I think.
The log message should probably start with a capital letter
actually.

https://codereview.appspot.com/84540044/diff/20001/state/apiserver/pinger_tes...
File state/apiserver/pinger_test.go (right):

https://codereview.appspot.com/84540044/diff/20001/state/apiserver/pinger_tes...
state/apiserver/pinger_test.go:118: if !a.HasNext() {
On 2014/04/04 16:42:37, dimitern wrote:
> I'd move this outside the loop and drop the if, and use return instead of
break
> in the block above, to make it a bit more compact, but your call.

yeah, we don't need the value of err, which is
why HasNext is usually used.
done.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b