Refactor some calls to avoid repeatition. #7193

Merged
merged 2 commits into from Apr 3, 2017

Conversation

Projects
None yet
3 participants
Member

anastasiamac commented Apr 3, 2017

Description of change

Consolidating calls to avoid duplicating the same functionality in different places. I've noticed these while investigating model destruction failures.

QA steps

internal change - no additional QA

Documentation changes

n/a

Bug reference

n/a

apiserver/common/modeldestroy.go
@@ -48,10 +48,11 @@ func DestroyModel(st ModelManagerBackend, modelTag names.ModelTag) error {
func destroyModel(st ModelManagerBackend, modelTag names.ModelTag, destroyHostedModels bool) error {
var err error
if modelTag != st.ModelTag() {
- if st, err = st.ForModel(modelTag); err != nil {
+ st, err = st.ForModel(modelTag)
+ defer st.Close()
@axw

axw Apr 3, 2017

Member

this is incorrect. you should not be calling Close if the error is non-nil

@anastasiamac

anastasiamac Apr 3, 2017

Member

oops \o/ Thank you for paying attention - reverted :)

axw approved these changes Apr 3, 2017

Member

anastasiamac commented Apr 3, 2017

$$merge$$

Contributor

jujubot commented Apr 3, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 55d95c5 into juju:develop Apr 3, 2017

@anastasiamac anastasiamac deleted the anastasiamac:tiny-consolidation branch Apr 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment