Refactor EnvironConfigGetter.CloudSpec() #7738

Merged
merged 1 commit into from Aug 15, 2017

Conversation

Projects
None yet
5 participants
Contributor

mjs commented Aug 14, 2017

Description of change

This surprisingly large change updates the environs.EnvironConfigGetter interface so the CloudSpec method no longer takes a model tag. This means that a single instance of an EnvironConfigGetter is now only ever responsible for a single model.

This change is required because it supports changes around state.Model creation. A CloudSpec method that takes a model tag encourages poor practices in EnvironConfigGetter implementations.

QA steps

Just confirmed general functionality:

$ juju bootstrap lxd
$ juju add-model foo
$ juju deploy ubuntu
# wait...
$ juju remove-application ubuntu

# Check logs for issues
$ juju debug-log --replay -l ERROR
$ juju debug-log -m controller --replay -l ERROR

# Remove the controller
$ juju destroy-controller -y --destroy-all-models --destroy-storage lxd

Documentation changes

N.A.

Bug reference

N.A.

api/common/cloudspec/cloudspec.go
-func NewCloudSpecAPI(facade base.FacadeCaller) *CloudSpecAPI {
- return &CloudSpecAPI{facade}
+func NewCloudSpecAPI(facade base.FacadeCaller, modelTag names.ModelTag) *CloudSpecAPI {
+ return &CloudSpecAPI{facade, modelTag}
}
// CloudSpec returns the cloud specification for the model
// with the given tag.
@mikemccracken

mikemccracken Aug 14, 2017

Member

I think this comment ("with the given tag") needs to be updated

@mjs

mjs Aug 15, 2017

Contributor

Good catch - fixed.

api/controller/controller.go
@@ -66,6 +65,11 @@ func (c *Client) AllModels() ([]base.UserModel, error) {
return result, nil
}
+func (c *Client) CloudSpec(modelTag names.ModelTag) (environs.CloudSpec, error) {
@mikemccracken

mikemccracken Aug 15, 2017

Member

This needs a docstring, right?

@mjs

mjs Aug 15, 2017

Contributor

Fixed.

api/agent/model_test.go
@@ -9,6 +9,7 @@ import (
"github.com/juju/juju/api/agent"
apitesting "github.com/juju/juju/api/testing"
jujutesting "github.com/juju/juju/juju/testing"
+ jc "github.com/juju/testing/checkers"
@mjs

mjs Aug 15, 2017

Contributor

fixed

}
// NewCloudSpecAPI creates a CloudSpecAPI using the provided
// FacadeCaller.
-func NewCloudSpecAPI(facade base.FacadeCaller) *CloudSpecAPI {
- return &CloudSpecAPI{facade}
+func NewCloudSpecAPI(facade base.FacadeCaller, modelTag names.ModelTag) *CloudSpecAPI {
@wallyworld

wallyworld Aug 15, 2017

Owner

I'd personally prefer we pass in a UUID since tags are supposed to be internal to the api/apiserver layers, but given we already leak them everywhere, I guess it doesn't matter.

@mjs

mjs Aug 15, 2017

Contributor

yeah I know. it needs a model tag and the caller already has a model tag so passing a model tag seemed the most pragmatic approach.

I think this looks good

Refactor EnvironConfigGetter.CloudSpec()
This surprisingly large change changes the
environs.EnvironConfigGetter interface so the CloudSpec method no
longer takes a model tag. This means that a single instance of an
EnvironConfigGetter is now only ever responsible for a single model.

This change is required because it supports changes around state.Model
creation. A CloudSpec method that takes a model tag encourages poor
practices in EnvironConfigGetter implementations.

axw approved these changes Aug 15, 2017

Contributor

mjs commented Aug 15, 2017

$$merge$$

Contributor

jujubot commented Aug 15, 2017

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

@jujubot jujubot merged commit 97519d2 into juju:develop Aug 15, 2017

1 check passed

continuous-integration/jenkins/pr-merge This commit looks good
Details

@mjs mjs deleted the mjs:EnvironConfigGetter-cleanup branch Aug 15, 2017

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