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 State.GetModel() #7745
Conversation
mjs
added some commits
Aug 15, 2017
| gone := errors.IsNotFound(err) | ||
| dead := err == nil && model.Life() == state.Dead | ||
| if err != nil && !gone { | ||
| return errors.Trace(err) | ||
| } | ||
| + release() |
wallyworld
Aug 15, 2017
Owner
At this point, err could be not found. Will release() be valid then? Don't we want to check that err == nil?
| c.Assert(err, jc.ErrorIsNil) | ||
| - s.checkEnvironmentMatches(c, env.Model, stateEnv) | ||
| + defer release() |
mjs
Aug 15, 2017
Contributor
I guess checkEnvironmentMatches doesn't call anything on the model which relies on the DB so calling release here is safe enough... probably not worth it though.
| + if err != nil { | ||
| + return nil, nil, errors.Trace(err) | ||
| + } | ||
| + return m, func() { release() }, nil |
mjs
Aug 15, 2017
Contributor
Nope. The release func returned by GetModel is func () bool but the Pool interface simplifies that to func()
| } | ||
| - return m, nil | ||
| + return m, func() { release() }, nil |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
jujubot
merged commit c8d3e6c
into
juju:develop
Aug 15, 2017
1 check passed
continuous-integration/jenkins/pr-merge
This commit looks good
Details
mjs
deleted the
mjs:remove-GetModel
branch
Aug 15, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mjs commentedAug 15, 2017
•
Edited 1 time
-
mjs
Aug 15, 2017
Description of change
These changes remove the
GetModelmethod fromstate.State. This gets rid of the last remaining problematic way forstate.Modelinstances to be created.Modelinstances can now only be created usingState.Model()which means theStateaModelreferences is now guaranteed to be connected to the same model UUID as theModel. This paves the way for moving more functionality fromStateontoModeland is a prerequisite for upcoming feature work.A follow-up PR will clean up the internals of
state.Model, taking advantage of the fact that we know aModel'sStateis now the correct one.This change has had many positive follow-on effects. More uses of the evil
State.ForModel()were removed and the code and tests for some apiserver facades is now significantly cleaner. Some minor inefficiencies have also been dealt with.QA steps
The areas at risk of breakage as a result of this change are model/controller creation and destruction, and model migrations, so exercise those:
Documentation changes
N.A. - internal only
Bug reference
N.A.