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

Issue 13164043: Replace agent.Conf with an interface

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 8 months ago by thumper
Modified:
10 years, 8 months ago
Reviewers:
mp+181450, jameinel, fwereade, rog
Visibility:
Public.

Description

Replace agent.Conf with an interface This was supposed to be smallish, but turned epic. I also unexported the Conf structure so construction now has to be through one of the two New* methods or the Read method. A lot of the changes are making the call sites work with the interface instead of directly poking at the structure. Quite a few of the tests in agent were testing for situations that can no longer occur. Those have been removed. https://code.launchpad.net/~thumper/juju-core/agent-conf-interface/+merge/181450 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 22

Patch Set 2 : Replace agent.Conf with an interface #

Total comments: 14
Unified diffs Side-by-side diffs Delta from patch set Stats (+808 lines, -879 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M agent/agent.go View 1 11 chunks +257 lines, -39 lines 12 comments Download
M agent/agent_test.go View 1 1 chunk +232 lines, -391 lines 0 comments Download
M cmd/jujud/agent.go View 5 chunks +12 lines, -29 lines 0 comments Download
M cmd/jujud/agent_test.go View 4 chunks +62 lines, -69 lines 0 comments Download
M cmd/jujud/bootstrap.go View 5 chunks +9 lines, -10 lines 0 comments Download
M cmd/jujud/bootstrap_test.go View 3 chunks +20 lines, -48 lines 0 comments Download
M cmd/jujud/deploy_test.go View 2 chunks +0 lines, -28 lines 0 comments Download
M cmd/jujud/machine.go View 7 chunks +11 lines, -10 lines 0 comments Download
M cmd/jujud/machine_test.go View 1 12 chunks +43 lines, -73 lines 0 comments Download
M cmd/jujud/unit.go View 2 chunks +4 lines, -4 lines 0 comments Download
M cmd/jujud/unit_test.go View 2 chunks +9 lines, -7 lines 0 comments Download
M environs/bootstrap.go View 3 chunks +1 line, -34 lines 0 comments Download
M environs/cloudinit/cloudinit.go View 1 1 chunk +35 lines, -26 lines 0 comments Download
M environs/cloudinit/cloudinit_test.go View 1 7 chunks +9 lines, -8 lines 0 comments Download
M provider/azure/config_test.go View 1 chunk +3 lines, -1 line 0 comments Download
M provider/azure/customdata_test.go View 2 chunks +7 lines, -4 lines 0 comments Download
M provider/ec2/config_test.go View 1 3 chunks +8 lines, -3 lines 0 comments Download
M provider/ec2/local_test.go View 1 4 chunks +4 lines, -0 lines 0 comments Download
M provider/local/environ.go View 1 2 chunks +36 lines, -43 lines 0 comments Download
M provider/maas/config_test.go View 1 chunk +3 lines, -1 line 0 comments Download
M provider/maas/environ_test.go View 1 chunk +1 line, -0 lines 0 comments Download
M provider/openstack/config_test.go View 4 chunks +4 lines, -5 lines 0 comments Download
M provider/openstack/local_test.go View 1 1 chunk +1 line, -0 lines 0 comments Download
M state/open.go View 1 5 chunks +5 lines, -6 lines 0 comments Download
M state/state.go View 1 3 chunks +4 lines, -2 lines 0 comments Download
M testing/mgo.go View 2 chunks +5 lines, -1 line 0 comments Download
M worker/deployer/simple.go View 3 chunks +15 lines, -21 lines 0 comments Download
M worker/deployer/simple_test.go View 5 chunks +6 lines, -16 lines 2 comments Download

Messages

Total messages: 6
thumper
Please take a look.
10 years, 8 months ago (2013-08-22 04:23:21 UTC) #1
fwereade
LGTM, this is awesome. Just a few trivial notes: https://codereview.appspot.com/13164043/diff/1/agent/agent_test.go File agent/agent_test.go (left): https://codereview.appspot.com/13164043/diff/1/agent/agent_test.go#oldcode25 agent/agent_test.go:25: ...
10 years, 8 months ago (2013-08-22 10:35:43 UTC) #2
jameinel
Some thoughts I wanted to make sure to get out since William did the review. ...
10 years, 8 months ago (2013-08-22 11:17:05 UTC) #3
thumper
https://codereview.appspot.com/13164043/diff/1/agent/agent.go File agent/agent.go (left): https://codereview.appspot.com/13164043/diff/1/agent/agent.go#oldcode59 agent/agent.go:59: } On 2013/08/22 11:17:05, jameinel wrote: > Is the ...
10 years, 8 months ago (2013-08-22 21:39:12 UTC) #4
thumper
Please take a look.
10 years, 8 months ago (2013-08-22 22:28:45 UTC) #5
rog
10 years, 8 months ago (2013-08-23 09:13:02 UTC) #6
I very much like it that this branch
hides some of the grungy details of the agent
configuration behind appropriate methods.
Thanks a lot for working on this.

I have some thoughts about some other
aspects of this though, outlined
below.

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go
File agent/agent.go (right):

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode27
agent/agent.go:27: type Config interface {
Doc comment, please.

And I'm a little puzzled as to what we gain by
making this an interface rather than simply
unexporting the component fields and defining
methods on the type. It doesn't reduce
coupling AFAICS, and it's not like the concrete
type is difficult or expensive to mock.

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode29
agent/agent.go:29: // containing the configuration files.
s/the/its/ ?

And I think this is wrong - the data dir is shared between all
agents, otherwise we wouldn't need a distincton between DataDir
and Dir below.

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode50
agent/agent.go:50: // the given Conf.
What given Conf?

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode53
agent/agent.go:53: // Write writes the agent configuration.
... to the agent's directory. ?

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode61
agent/agent.go:61: // GenerateNewPassword creates a new random password and
saves this.  The
This doesn't make it very clear what's going on.
Perhaps:

// GenerateNewPassword changes the Config's password
// to be a new random password and saves the
// new configuration by calling Config.Write.
// It returns the new password.

?

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode69
agent/agent.go:69: // APIServerDetails returns the details needed to run an API
server.
This could do with a little more documentation. It does
not say what port, cert or key are. The original documentation
for StateServerCert and StateServerKey was more clear.

Perhaps consider splitting this into two methods, one
to return the port and one to return the cert and key.

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode74
agent/agent.go:74: type conf struct {
"config" might be a better name here.

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode114
agent/agent.go:114: type AgentConfigParams struct {
Doc comment please. And on the fields too. The data
that is passed in here is the principal reason
for the existence of this type.

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode138
agent/agent.go:138: // blank.  This is by design.
The conflation of credentials and location is the underlying
problem here, I think (and the central problem with state.Info
as a concept). I'd love to see a branch that fixes that.

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode175
agent/agent.go:175: type StateMachineConfigParams struct {
Doc comment please.

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode434
agent/agent.go:434: func InitialStateConfiguration(agentConfig Config, cfg
*config.Config, timeout state.DialOpts) (*state.State, error) {
This isn't a great name - it sounds like it's returning a configuration
where actually it's highly active: it initializes the database.

I'd be tempted to call it InitializeState (or perhaps BootstrapState,
given "bootstrapUsers" below)

And it really needs a doc comment.

https://codereview.appspot.com/13164043/diff/12001/agent/agent.go#newcode435
agent/agent.go:435: c := agentConfig.(*conf)
This is a smell. Why are we using an interface at all
if we blithely assume that it always has the same static
type?

https://codereview.appspot.com/13164043/diff/12001/worker/deployer/simple_tes...
File worker/deployer/simple_test.go (right):

https://codereview.appspot.com/13164043/diff/12001/worker/deployer/simple_tes...
worker/deployer/simple_test.go:132: testing.LoggingSuite
I'm not wild about this. It breaks the
current pattern where we always call the
SetUpSuite/TearDownSuite methods of a
fixture as well as its SetUpTest/TearDownTest
methods.

Also, the LoggingSuite here is also redundant
in deployerSuite, which already includes it
by virtue of including JujuConnSuite.

I'd prefer to directly include LoggingSuite
into SimpleContextSuite.

Aside: at some point, I'd love to consistently move
away from calling our fixtures "Suites"
towards a model more like this SimpleToolsFixture
(or, better perhaps, a model where we always return a
function to undo the setup)

https://codereview.appspot.com/13164043/diff/12001/worker/deployer/simple_tes...
worker/deployer/simple_test.go:246: c.Assert(conf.DataDir(), gc.Equals,
fix.dataDir)
We've lost test coverage here, I think. We should still be checking
that the right arguments have been passed into NewAgentConfig.
Sign in to reply to this message.

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