Consume details for an offer now includes the connection details for the host controller #7504

Merged
merged 4 commits into from Jun 16, 2017

Conversation

Projects
None yet
3 participants
Owner

wallyworld commented Jun 15, 2017

Description of change

When consuming offers from another controller, we need to record details for how to connect to that controller in the consuming model. We also need to record against the remote application on the consuming side a macaroon that proves permission to consume; this macaroon will be used when communicating with the offering model once the relation is set up.

The various params structs have been modified to cater for passing the macaroon, but it's not used yet. Also, CMR is still for single controller, so the external controller details are not used yet either. This is all ground work for enabling multi-controller CMR.

QA steps

No visible changes yet - all infrastructure for later.
bootstrap and perform a consumer/relate.

mjs approved these changes Jun 16, 2017

LGTM with the understanding (discussed verbally) that refreshing of macaroons and keeping controller addresses up to date still need to figured out.

One idea for helping to keep controller addresses up to date was to update externalControllers using the addresses in the login response following any login to a remote controller.

@@ -120,6 +123,13 @@ type stateShim struct {
*state.State
}
+type ExternalController state.ExternalController
@mjs

mjs Jun 16, 2017

Contributor

As per comment in state package, maybe the ExternalController interface should be here.

apiserver/application/mock_test.go
"github.com/juju/juju/environs"
"github.com/juju/juju/instance"
"github.com/juju/juju/network"
"github.com/juju/juju/state"
statestorage "github.com/juju/juju/state/storage"
coretesting "github.com/juju/juju/testing"
+ "gopkg.in/macaroon.v1"
@mjs

mjs Jun 16, 2017

Contributor

wrong grouping

state/externalcontroller.go
+)
+
+// ExternalController represents the state of a controller hosting
+// models involved in cross-model relations.
@mjs

mjs Jun 16, 2017

Contributor

Might it better to leave this as generic and not mention CMR?

+type ExternalControllers interface {
+ Save(_ crossmodel.ControllerInfo, modelUUIDs ...string) (ExternalController, error)
+ ControllerForModel(modelUUID string) (ExternalController, error)
+}
@mjs

mjs Jun 16, 2017

Contributor

I haven't always been good at this myself, but shouldn't this interface live where it's used not next to the concrete implementation?

@wallyworld

wallyworld Jun 16, 2017

Owner

discussed on irc, will leave it here for now, because state is awesome

state/externalcontroller.go
+}
+
+// NewExternalControllers creates an external controllers instance backed by a state.
+func NewExternalControllers(st *State) ExternalControllers {
@mjs

mjs Jun 16, 2017

Contributor

As per above, this should perhaps return a concrete type

state/externalcontroller.go
+ defer closer()
+
+ var doc []externalControllerDoc
+ err := coll.Find(bson.D{{"models", bson.D{{"$all", []string{modelUUID}}}}}).All(&doc)
@mjs

mjs Jun 16, 2017

Contributor

It would be more logical to use $in here. bson.M would also aid readability. Something like:

coll.Find(bson.M{"models": bson.M{"$in": []string{modelUUID}}})
Consume details for an offer now includes the connection details for …
…the host controller; these are recorded in the consuming model. We also allow for a macaroon to get passed to the consuming model.
Owner

wallyworld commented Jun 16, 2017

This is WIP, behind a feature flag, so macaroon stuff not fully cooked yet. This PR is more of an infrastructure one to get the api params and other building blocks in place.

wallyworld added some commits Jun 15, 2017

Consume details for an offer now includes the connection details for …
…the host controller; these are recorded in the consuming model. We also allow for a macaroon to get passed to the consuming model.
Split the remote relations publication apis off the remote relations …
…facade onto a new cross model relations facade
Merge pull request #38 from wallyworld/split-remoterelations-facade
Split the remote relations publication apis off the remote relations facade
Owner

wallyworld commented Jun 16, 2017

$$merge$$

Contributor

jujubot commented Jun 16, 2017

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

@jujubot jujubot merged commit 6b150d9 into juju:develop Jun 16, 2017

1 check passed

github-check-merge-juju Ran tests against PR. Use !!.*!! to request another build. IE, !!build!!, !!retry!!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment