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

Issue 7394048: environs: rework instance creation

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 2 months ago by fwereade
Modified:
11 years, 2 months ago
Reviewers:
dimitern, mp+150286, rog
Visibility:
Public.

Description

environs: rework instance creation Bootstrap methods, and StartInstance-related methods, were hotbeds of gradually-diverging non-provider-specific code. They're still pretty bad, but the worst abuses have been factored out into environs.Bootstrap and environs.StartInstance. Thoughts? https://code.launchpad.net/~fwereade/juju-core/environs-rework-instance-launch/+merge/150286 Requires: https://code.launchpad.net/~fwereade/juju-core/config-default-agent-version/+merge/150248 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : environs: rework instance creation #

Total comments: 20
Unified diffs Side-by-side diffs Delta from patch set Stats (+415 lines, -330 lines) Patch
A [revision details] View 1 chunk +2 lines, -0 lines 0 comments Download
M environs/bootstrap.go View 2 chunks +194 lines, -40 lines 10 comments Download
M environs/cloudinit/cloudinit.go View 1 chunk +0 lines, -6 lines 0 comments Download
M environs/config.go View 2 chunks +0 lines, -22 lines 0 comments Download
M environs/ec2/ec2.go View 5 chunks +42 lines, -139 lines 6 comments Download
M environs/ec2/image.go View 1 chunk +12 lines, -3 lines 0 comments Download
M environs/ec2/live_test.go View 7 chunks +9 lines, -10 lines 0 comments Download
M environs/ec2/local_test.go View 2 chunks +2 lines, -2 lines 0 comments Download
A environs/instance.go View 1 chunk +55 lines, -0 lines 0 comments Download
M environs/interface.go View 4 chunks +24 lines, -27 lines 2 comments Download
M environs/jujutest/livetests.go View 11 chunks +33 lines, -35 lines 2 comments Download
M environs/jujutest/tests.go View 4 chunks +37 lines, -24 lines 0 comments Download
M worker/provisioner/provisioner.go View 5 chunks +5 lines, -22 lines 0 comments Download

Messages

Total messages: 3
dimitern
Looks very good so far. So StartInstance is gone, LaunchInstance is the new thing? https://codereview.appspot.com/7394048/diff/2001/environs/bootstrap.go ...
11 years, 2 months ago (2013-02-25 11:25:15 UTC) #1
rog
a few comments, incomplete - publishing just in the aid of continuing online conversation. https://codereview.appspot.com/7394048/diff/2001/environs/bootstrap.go ...
11 years, 2 months ago (2013-02-25 11:32:54 UTC) #2
fwereade
11 years, 2 months ago (2013-02-25 12:06:11 UTC) #3
a few thoughts

https://codereview.appspot.com/7394048/diff/2001/environs/bootstrap.go
File environs/bootstrap.go (right):

https://codereview.appspot.com/7394048/diff/2001/environs/bootstrap.go#newcode18
environs/bootstrap.go:18: // BootstrapParams contains the information required
to start a new
On 2013/02/25 11:25:15, dimitern wrote:
> I like this!

Cheers :).

https://codereview.appspot.com/7394048/diff/2001/environs/bootstrap.go#newcode44
environs/bootstrap.go:44: type WriteCACertFunc func(name string, cert, key
[]byte) error
On 2013/02/25 11:32:54, rog wrote:
> i'm not entirely sure that this justifies its own type.

I'ts not the type so much as it is the name, IYSWIM. Func types inside parameter
lists are prettier in  go than they are in C, but once you're past a single
param/result I find they become unreadable all too quickly anyway.

https://codereview.appspot.com/7394048/diff/2001/environs/bootstrap.go#newcode54
environs/bootstrap.go:54: if bootstrapped, err := e.IsBootstrapped(); err != nil
{
On 2013/02/25 11:32:54, rog wrote:
> it's a pity that this makes the bootstrap process fundamentally racy
(previously
> it was possible for a given provider to implement Bootstrap in a race-free
way).

In theory, yes. In practice, no provider worthy of the name actually did so; if
we really want, though, I think SetStateServers could be implemented such that
bootstrap could be made be non-racy (in a race-free environment). I don't think
it's a showstopper.

https://codereview.appspot.com/7394048/diff/2001/environs/bootstrap.go#newcode71
environs/bootstrap.go:71: tools, err := PutTools(e.Storage(), nil)
On 2013/02/25 11:32:54, rog wrote:
> this is slightly questionable, i think. previously, the storage methods in
> Environ were not required to work before Bootstrap was called, so the
Bootstrap
> method was free to set up any storage required. we're changing that here.
> 
> i wonder if we should have a separate Environ.Init method which makes sure
that
> the environment is set up to be used. It could be that method that lets us
know
> if the environment is already bootstrapped.
> 
> Environ.PrepareForBootstrap, perhaps? then that would leave a provider free to
> hold some kind of lock between PrepareForBootstrap and... when the environment
> is bootstrapped, which i guess it doesn't know.

How would you feel about separating tools storage from everything-else storage
then? This would let us drop all the confusing private/public malarkey and have
simple, configurable, Storage (which can keep those guarantees) and ToolsStorage
(which has to be set up beforehand, and can usually just default to a public
place).

Remember, the only use case for upload tools is for development environments: we
need to write some stuff to populate buckets with tools *anyway*, so why not
just untangle tools storage from environ storage?

https://codereview.appspot.com/7394048/diff/2001/environs/bootstrap.go#newcode97
environs/bootstrap.go:97: if err2 := e.StopInstances(insts); err2 != nil {
On 2013/02/25 11:25:15, dimitern wrote:
> Nice to have err2, but I've been told repeatedly reusing the same err in
nested
> ifs is OK :)

Good point, thanks.

https://codereview.appspot.com/7394048/diff/2001/environs/ec2/ec2.go
File environs/ec2/ec2.go (right):

https://codereview.appspot.com/7394048/diff/2001/environs/ec2/ec2.go#newcode233
environs/ec2/ec2.go:233: func (e *environ) IsBootstrapped() (bool, error) {
On 2013/02/25 11:25:15, dimitern wrote:
> We should fix openstack and others eventually (probably in a follow-up though,
> unless the build breaks, which is inevitable with interface changes).

This DESTROYS the build, I'm afraid -- the dummy provider can't handle it
either, and that takes down much of the rest of the codebase. Definitely not
finished, think of this as a preview for sanity-checking :).

https://codereview.appspot.com/7394048/diff/2001/environs/ec2/ec2.go#newcode310
environs/ec2/ec2.go:310: func (e *environ) GetInstanceSpec(series string, cons
state.Constraints) (environs.InstanceSpec, error) {
On 2013/02/25 11:25:15, dimitern wrote:
> Comment?

I'm not sure duplicating interface method comments is that valuable.

https://codereview.appspot.com/7394048/diff/2001/environs/ec2/ec2.go#newcode344
environs/ec2/ec2.go:344: func (e *environ) LaunchInstance(spec
environs.InstanceSpec, mcfg *cloudinit.MachineConfig) (environs.Instance, error)
{
On 2013/02/25 11:25:15, dimitern wrote:
> Comment?

Ditto

https://codereview.appspot.com/7394048/diff/2001/environs/interface.go
File environs/interface.go (right):

https://codereview.appspot.com/7394048/diff/2001/environs/interface.go#newcod...
environs/interface.go:148: IsBootstrapped() (bool, error)
On 2013/02/25 11:25:15, dimitern wrote:
> Good to have this exposed.

Cheers

https://codereview.appspot.com/7394048/diff/2001/environs/jujutest/livetests.go
File environs/jujutest/livetests.go (right):

https://codereview.appspot.com/7394048/diff/2001/environs/jujutest/livetests....
environs/jujutest/livetests.go:26: func StartInstance(e environs.Environ,
machineId string) (environs.Instance, error) {
On 2013/02/25 11:25:15, dimitern wrote:
> Nice! About time to cut on the long list of mostly unused args.
Thanks :)
Sign in to reply to this message.

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