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

Issue 22870045: Migrate juju destroy-environment to use API

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 5 months ago by axw
Modified:
10 years, 5 months ago
Reviewers:
william.reade, mp+194801, jameinel
Visibility:
Public.

Description

Migrate juju destroy-environment to use API This change introduces a new client API method, DestroyJuju. This method does the following, server-side, in order: - marks the environment as Dying, preventing the addition of machines and services to state - ensures there are no non-manager manually- provisioned machines in state - marks all services as Dying, thus prevening units from being added - stops all non-manager machine instances - marks the environment as Dead Machine agents watch, via the machiner API, for changes to the environment's lifecycle, and terminate themselves when the environment becomes Dead. This is how we terminate manual bootstrap nodes. A followup will update agent termination logic to uninstall mongo on state servers, and also remove the data-dir/log-dir. Fixes #1218688 Fixes #1246343 https://code.launchpad.net/~axwalk/juju-core/lp1246983-cli-api-removeagents/+merge/194801 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 9

Patch Set 2 : Migrate juju destroy-environment to use API #

Total comments: 24
Unified diffs Side-by-side diffs Delta from patch set Stats (+566 lines, -49 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/juju/destroyenvironment.go View 1 2 chunks +12 lines, -4 lines 0 comments Download
M cmd/jujud/machine.go View 1 chunk +3 lines, -0 lines 0 comments Download
M environs/manual/provisioner.go View 1 1 chunk +1 line, -1 line 0 comments Download
M provider/dummy/environs.go View 1 1 chunk +3 lines, -1 line 0 comments Download
M provider/null/environ.go View 1 chunk +1 line, -1 line 0 comments Download
M state/api/client.go View 1 1 chunk +6 lines, -0 lines 0 comments Download
A state/api/machiner/environ.go View 1 chunk +41 lines, -0 lines 2 comments Download
M state/api/machiner/machine.go View 3 chunks +2 lines, -20 lines 0 comments Download
M state/api/machiner/machiner.go View 1 4 chunks +39 lines, -3 lines 2 comments Download
M state/api/params/internal.go View 1 1 chunk +6 lines, -0 lines 0 comments Download
A state/apiserver/client/destroyjuju.go View 1 1 chunk +126 lines, -0 lines 4 comments Download
A state/apiserver/client/destroyjuju_test.go View 1 1 chunk +118 lines, -0 lines 0 comments Download
M state/apiserver/machine/machiner.go View 1 2 chunks +31 lines, -3 lines 2 comments Download
M state/environ.go View 3 chunks +64 lines, -12 lines 6 comments Download
M state/interface.go View 1 chunk +1 line, -0 lines 0 comments Download
M state/state.go View 1 5 chunks +23 lines, -2 lines 2 comments Download
M state/state_test.go View 1 2 chunks +36 lines, -0 lines 4 comments Download
M state/watcher.go View 1 chunk +5 lines, -0 lines 0 comments Download
M worker/machiner/machiner.go View 1 2 chunks +46 lines, -2 lines 2 comments Download

Messages

Total messages: 6
axw
Please take a look.
10 years, 5 months ago (2013-11-12 07:29:34 UTC) #1
jameinel
some thougts. we did most of the discussion on IRC, I think. https://codereview.appspot.com/22870045/diff/1/cmd/juju/destroyenvironment.go File cmd/juju/destroyenvironment.go ...
10 years, 5 months ago (2013-11-12 08:39:25 UTC) #2
axw
So, based on conversations on IRC, I'm going to rework this. From fwereade: "(1) abort ...
10 years, 5 months ago (2013-11-12 10:03:08 UTC) #3
axw
Please take a look.
10 years, 5 months ago (2013-11-13 05:14:44 UTC) #4
william.reade
Some good bits, some I'ma bit alarmed about. Can we do a single CL for ...
10 years, 5 months ago (2013-11-18 14:43:36 UTC) #5
axw
10 years, 5 months ago (2013-11-19 03:07:17 UTC) #6
I'll create a new CL for the state bits, as requested.

https://codereview.appspot.com/22870045/diff/20001/state/api/machiner/environ.go
File state/api/machiner/environ.go (right):

https://codereview.appspot.com/22870045/diff/20001/state/api/machiner/environ...
state/api/machiner/environ.go:39: func (e *Environment) Watch()
(watcher.NotifyWatcher, error) {
On 2013/11/18 14:43:37, william.reade wrote:
> Environment?

Are you talking about the comment? Fixed.

https://codereview.appspot.com/22870045/diff/20001/state/api/machiner/machine...
File state/api/machiner/machiner.go (right):

https://codereview.appspot.com/22870045/diff/20001/state/api/machiner/machine...
state/api/machiner/machiner.go:65: tag:  result.EnvironmentTag,
On 2013/11/18 14:43:37, william.reade wrote:
> Whoa. I hope this doesn't include a name -- the moment we start messing around
> with environment tags we need to un-screw-up this situation (environment names
> are not globally unique -- any time we use it we must be aware it's only an
> alias).
> 
> Regardless I don't think there's a justification for talking about more than
one
> environment at this level anyway.

I'm not sure what you mean by "talking about more than one environment". That
tag is just a handle so we can get a watcher, and is always expected to be the
same.

Do you have a preferred API here?

https://codereview.appspot.com/22870045/diff/20001/state/apiserver/client/des...
File state/apiserver/client/destroyjuju.go (right):

https://codereview.appspot.com/22870045/diff/20001/state/apiserver/client/des...
state/apiserver/client/destroyjuju.go:97: return env.StopInstances(instances)
On 2013/11/18 14:43:37, william.reade wrote:
> There's a wrinkle here in that some machines may be missing for random stupid
> provider reasons, and those won't end up getting stopped. I'm becoming
convinced
> that it's really stupid to have StopInstances take Instances instead of ids --
> it means that we need to go through all the hassle of finding out everything
> about one (ie hitting the provider api, potentially triggering rate limiting,
> etc) before we can just simply stop them.

Agreed.

https://codereview.appspot.com/22870045/diff/20001/state/apiserver/client/des...
state/apiserver/client/destroyjuju.go:124: // Due to an import loop in tests, we
cannot import manual.
On 2013/11/18 14:43:37, william.reade wrote:
> In tests? I'm surprised by that.

The environs/manual tests import something that imports state/apiserver. Thus,
importing environs/manual here prevents running the environs/manual tests.

https://codereview.appspot.com/22870045/diff/20001/state/apiserver/machine/ma...
File state/apiserver/machine/machiner.go (right):

https://codereview.appspot.com/22870045/diff/20001/state/apiserver/machine/ma...
state/apiserver/machine/machiner.go:60: var result
params.MachineEnvironmentResult
On 2013/11/18 14:43:37, william.reade wrote:
> Why do we persist in naming things after the entities that call them? This is
> surely an EnvironmentResult.

The idea here was "give me the environment which this machine belongs to", not
an arbitrary naming-after-the-caller. In light of previous discussions about not
caring about multi tenancy today, this can be renamed.

> And FWIW, the whole domain-object-centricity is not something we want to
> encourage. This is a new API for new functionality, let's not even bother
> calling the API at this stage: just call Life() directly, and only when we
need
> it, ie in response to a watcher event.

Life requires an entity tag. Watch requires an entity tag. How can we "call
Life() directly, and only when we need it, ie in response to a watcher event"
without the tag?

https://codereview.appspot.com/22870045/diff/20001/state/environ.go
File state/environ.go (left):

https://codereview.appspot.com/22870045/diff/20001/state/environ.go#oldcode56
state/environ.go:56: return names.EnvironTag(e.doc.Name)
On 2013/11/18 14:43:37, william.reade wrote:
> Right, yeah, this is completely broken. Not your fault, it was a bad call I
made
> in atlanta, but it needs to be resolved.
> 
> I suggest that anything currently using an environment tag be changed to
ignore
> the name, and anything producing an environment tag use the UUID instead of
the
> name.

Okay. I'll do that in the new CL.

https://codereview.appspot.com/22870045/diff/20001/state/environ.go
File state/environ.go (right):

https://codereview.appspot.com/22870045/diff/20001/state/environ.go#newcode83
state/environ.go:83: return e.advanceLifecycle(Dead)
On 2013/11/18 14:43:37, william.reade wrote:
> What does it mean for an environment to jump straight to Dead from Alive? I'm
> not sure this is a sane operation.

No, probably not.

> In fact, I think an environment is like a Service or a Relation, not like a
Unit
> or Machine, and so Dead makes no sense for it. When does it ever make sense
for
> an Environment object to exist but access to it be invalid? That's what Dead
> means basically.

I will drop EnsureDead, and add Remove instead. Does that make more sense?

https://codereview.appspot.com/22870045/diff/20001/state/environ.go#newcode130
state/environ.go:130: }
On 2013/11/18 14:43:37, william.reade wrote:
> How does all this handle existing environments without Life fields? Is it that
> Alive == 0 and so nobody notices? It's a bit of a potential timebomb when it
> comes to selecting them, but I guess it's enough of an edge case...

Right, I verified that lack of Life is equivalent to Life==0, which is Alive.
This doesn't handle existing environments with Dying/Dead machines, but I
consider that an edge case that we could live with.

> ...ah, hmm. You assert on setting to Dead, but not to Dying? Is that why?

The assertion is the other way around: setting to Dead always succeeds, but
Dying only if it's not Dead. Anyway, I don't see what that has to do with
missing Life?

https://codereview.appspot.com/22870045/diff/20001/state/state.go
File state/state.go (left):

https://codereview.appspot.com/22870045/diff/20001/state/state.go#oldcode753
state/state.go:753: // already exists.
On 2013/11/18 14:43:37, william.reade wrote:
> This comment is now a lie.

Thanks, updated.

https://codereview.appspot.com/22870045/diff/20001/state/state_test.go
File state/state_test.go (right):

https://codereview.appspot.com/22870045/diff/20001/state/state_test.go#newcod...
state/state_test.go:223: c.Assert(err, gc.ErrorMatches, ".*environment is being
destroyed")
On 2013/11/18 14:43:37, william.reade wrote:
> Never use leading .*s in error tests, please -- they just hide ugly messages
> that subsequently slap our users in the face.

Fixed.

https://codereview.appspot.com/22870045/diff/20001/state/state_test.go#newcod...
state/state_test.go:554: // Check that machines cannot be added if the
environment is Dying.
On 2013/11/18 14:43:37, william.reade wrote:
> s/machines/services/

Done.

https://codereview.appspot.com/22870045/diff/20001/worker/machiner/machiner.go
File worker/machiner/machiner.go (right):

https://codereview.appspot.com/22870045/diff/20001/worker/machiner/machiner.g...
worker/machiner/machiner.go:126: }
On 2013/11/18 14:43:37, william.reade wrote:
> I question the utility of this type. We're terminating all provider instances,
> so machine teardown is moot; and allowing the possibility for manual machines
to
> do this doesn't seem like a good idea, because it'll leave the units lying
> around.

The environment won't be destroyed until there are no units remaining, so that
cannot happen.
Sign in to reply to this message.

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