Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Remove various state.Model constructors #7710
Conversation
| @@ -99,21 +101,13 @@ var _ ModelManagerBackend = (*modelManagerStateShim)(nil) | ||
| type modelManagerStateShim struct { | ||
| *state.State | ||
| + pool *state.StatePool |
wallyworld
Aug 8, 2017
Owner
Not sure i agree with this - the state shim is supposed to only wrap state to provide access to its methods.
I rather stick to keeping state and state pool separate in these shim objects to reflect the semantics of those structs
mjs
Aug 8, 2017
Contributor
I had them separate initially but it worked out much nicer to wrap them together. The backend interface then just represents everything to do with "state". It make the tests cleaner too.
| @@ -91,7 +91,7 @@ func NewOffersAPI(ctx facade.Context) (*OffersAPI, error) { | ||
| return createOffersAPI( | ||
| GetApplicationOffers, | ||
| environFromModel, | ||
| - GetStateAccess(ctx.State()), | ||
| + GetStateAccess(ctx.State(), ctx.StatePool()), |
mjs
Aug 8, 2017
Contributor
I had missed that a pool was being used separately here. I would actually like to update the PR to extend the Backend interface to have a GetBackend method and not pass the pool directly to createOffersAPI at all.
Happy to discuss further of course.
wallyworld
Aug 8, 2017
Owner
as in GetBackend(uuid)? Like is done for model manager backend I'm guessing
| - } | ||
| - return result, nil | ||
| -} | ||
| - | ||
| // ModelsForUser returns a list of models that the user |
wallyworld
Aug 8, 2017
Owner
It really returns the UUIDs right?
SHould these methods that still say "Models" be renamed to "ModelUUIDs" for better clarity?
wallyworld
approved these changes
Aug 9, 2017
Please add a todo (or two) to alter the backends to just take a state pool
mjs
added some commits
Aug 1, 2017
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
mjs commentedAug 8, 2017
•
Edited 1 time
-
mjs
Aug 8, 2017
Description of change
This change makes most of the steps so that
state.Modelinstances can only be created fromstate.Stateassociated to that model. There were many ways to create astate.Modelfrom anyStatewhich meant that theModelreferred to astate.Stateassociated with the wrong model. This is dangerous - requiring great care - and limits what can be done byModelinstances.Much functionality will soon be moved onto
state.Model, requiring that thestate.Stateit references is the correct one.Change highlights:
State.ControllerModel()has been replaced byState.ControllerModelTag()andState.ControllerModelUUID()State.AllModels()has been replaced byState.AllModelUUIDs()State.ModelsForUser()now returns UUIDs instead ofUserModels.state.UserModelno longer exists.State.ModelsForUser()where dead or importing models could be reported for admin users.Modelinstances is now done viastate.Statein most cases. Added aStatePool.GetModel()helper as a convenience.State.ForModel()being removed (bug 1698702)There is still one
state.Modelconstructor to remove:state.State.GetModel(). This will be done in the next PR - this one was getting big enough.QA steps
Confirmed that core model, controller and migration functionality worked:
Documentation changes
N.A. - internal only
Bug reference
Drive-by changes fixed https://bugs.launchpad.net/juju/+bug/1698702