Merge lp://staging/~axwalk/juju-core/wire-up-prechecker into lp://staging/~go-bot/juju-core/trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp://staging/~axwalk/juju-core/wire-up-prechecker |
Merge into: | lp://staging/~go-bot/juju-core/trunk |
Diff against target: |
768 lines (+351/-69) (has conflicts) 20 files modified
cmd/jujud/agent.go (+9/-0) cmd/jujud/machine.go (+13/-0) environs/base.go (+22/-0) environs/interface.go (+5/-22) environs/jujutest/livetests.go (+4/-9) juju/conn.go (+28/-11) juju/conn_test.go (+36/-0) provider/azure/environ.go (+2/-2) provider/dummy/environs.go (+2/-0) provider/ec2/ec2.go (+2/-2) provider/ec2/local_test.go (+2/-4) provider/local/environ.go (+27/-1) provider/local/environ_test.go (+2/-5) provider/maas/environ.go (+2/-0) provider/null/environ.go (+12/-0) provider/openstack/local_test.go (+2/-4) provider/openstack/provider.go (+2/-2) state/open.go (+2/-2) state/state.go (+57/-5) state/state_test.go (+120/-0) Text conflict in provider/local/environ.go Text conflict in provider/null/environ.go Text conflict in state/state_test.go |
To merge this branch: | bzr merge lp://staging/~axwalk/juju-core/wire-up-prechecker |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+188001@code.staging.launchpad.net |
Description of the change
Wire up prechecker
This change is to set a Prechecker in
the CLI, and in cmd/jujud. The Environ
itself is a Prechecker, and that is
what is assigned to the state object.
State now calls the prechecker when
decoding to create instance/container
machine entries in state. The prechecker
calls are elided for "injected" machines.
Environ embeds the Prechecker interface.
All Environ implementations now embed
environs.
defaults for an environs.Environ. Currently
it only implements Prechecker, by
embedding a NilPrechecker (i.e. one that
allows everything through).
All Environs, apart from MAAS, disallow
containers. The null provider disallows
everything (unless done "manually").
Unmerged revisions
- 1904. By Andrew Wilkins
-
Address review comments
- Remove unnecessary admin-secret/
ca-private- key copy.
- Log/add bug number to TODO in cmd/jujud. - 1903. By Andrew Wilkins
-
Address review comments
Change juju.NewConn to always return a fresh Environ,
and use that as the Prechecker. - 1902. By Andrew Wilkins
-
juju: update Conn.Environ in NewConn
Always return a fresh, up-to-date Environ.
- 1901. By Andrew Wilkins
-
juju.NewConn: call SetPrechecker
But do it with an Environ whose
config was loaded from state. - 1900. By Andrew Wilkins
-
Address review comments
- Add Prechecker into environs.Environ,
introduce NilPrechecker for embedding
- Remove SetPrechecker from juju.NewConn
- Don't precheck instances for injected machines
- Don't set prechecker to nil for manual provisioning
- Learn to use mutexes properly ;) - 1899. By Andrew Wilkins
-
Address review comments
- Move Prechecker from environs to state.
- Add "var _" assertions for Prechecker implementation.
- Acquire Mutex in SetPrechecker.
- Move Environ loaded from state into StateWorker in cmd/jujud. - 1898. By Andrew Wilkins
-
Wire up Prechecker
Thoughts:
https:/ /codereview. appspot. com/14032043/ diff/1/ state/state. go
File state/state.go (right):
https:/ /codereview. appspot. com/14032043/ diff/1/ state/state. go#newcode292 Prechecker,
state/state.go:292: // Prechecker is a clone of environs.
here to avoid the dependency.
Better I think to define it in state, and document (in code) that
appropriate Environs implement it. environs already knows about state,
not vice versa, so we may as well just define the interface in the place
that uses it. After all, it really *doesn't* have to be just an environ
that satsisfies that interface: we'd surely want the state tests to be
written with a suitable test implementation, not of a whole environ.
https:/ /codereview. appspot. com/14032043/ diff/1/ state/state. go#newcode302
state/state.go:302: }
/me strokes chin
Leaving aside the fact that we'll need lots of locking, and that makes
me a bit suspicious, this is kinda wrong; I'm worried that we would not
in general be in a position to track changes to the environment, and are
therefore in some danger of screwing up by using out-of-date
environments.
But my spidey-sense is tingling wrt the provisioner. That too needs an
up-to-date environment, and we've tied ourselves in frightful knots over
it; and, really, I don't think we need to at all. An Environ is meant to
be goroutine-safe, after all, so it might be reasonable to get a single
Environ per (authorized) agent and run a task that keeps it updated via
the API by validating changes and calling SetConfig; we can then use
that single task to keep all the environs in sync.
(I'm thinking of a Task that also implements several one-method seThing
interfaces -- WaitPrechecker, WaitInstanceBroker, WaitPortOpenClo
-- that all share an implementation (return the single Environ held by
the task once it's available); and which just watches the API and does
the whole SetConfig lark.)
Can anyone think of a reason not to do this?
https:/ /codereview. appspot. com/14032043/