Add remote firewaller facade #7021

Merged
merged 1 commit into from Feb 23, 2017

Conversation

Projects
None yet
3 participants
Owner

wallyworld commented Feb 23, 2017

Description of change

This PR adds a new remote firewaller facade. The facade will be used by the firewaller worker and provides firewall/network related functionality against a different (remote) model, where a cross model application is hosted and a relation established.

The only method currently is WatchSubnets() which notifies of changes to subnets in a remote model. The next PR will move the IngressSubnetsForRelation() method off the remote relation facade and onto this new remote firewaller facade.

The worker uses a helper method to construct a remote firewaller facade to access a given model - the remote relations worker uses the same methodology so some code to manage the underlying API connection itself was extracted to a helper. At the moment, the result is a facade pointing to a model on the same controller, but in future will be used to allow cross controller interactions transparent to the worker.

The PR includes all the components of the facade - api, apiserver, state functionality. The firewaller worker manifold was restructured to allow tests to be updated later to plug in mocks etc (as part of the work to plug in the remote firewaller facade).

QA steps

bootstrap aws
create 2 models and deploy an app to each
relate the apps across models
expose the app
check the ports

A few things. Most importantly: the location/dependency on worker/api, and the name of the new facade.

@@ -71,6 +71,7 @@ var facadeVersions = map[string]int{
"ProxyUpdater": 1,
"Reboot": 2,
"RelationUnitsWatcher": 1,
+ "RemoteFirewaller": 1,
@axw

axw Feb 23, 2017

Member

I'm not so sure about the name for this one. It's not so much about firewalling, as it is about networking in general is it? I mean, you connect to the remote controller to learn about its networks, so you can configure your own firewall; not to do any firewalling in the remote controller.

@wallyworld

wallyworld Feb 23, 2017

Owner

renamed to "networks"

apiserver/remotefirewaller/firewaller.go
+// NewRemoteFirewallerAPI creates a new server-side RemoteFirewallerAPI facade.
+func NewRemoteFirewallerAPI(
+ st State,
+ pool StatePool,
@axw

axw Feb 23, 2017

Member

the pool isn't needed now?

@wallyworld

wallyworld Feb 23, 2017

Owner

No, i was using it in an earlier iteration when model tags were passed in to the WatchSubnets() API. But I think the method of creating an API facade per model is the right way to go as it's how hosted juju works (albeit using redirection in the controller proxy).

I left it there for future use but perhaps it's YAGNI

worker/api/api.go
+// Copyright 2017 Canonical Ltd.
+// Licensed under the AGPLv3, see LICENCE file for details.
+
+package worker
@axw

axw Feb 23, 2017

Member

I don't think this belongs here, it has nothing to do with workers. Maybe in the "juju/juju/juju" package?

I think rather than having APIOpen in the manifold configs, you should pass in a function that returns an api.Connection given a model tag.

@wallyworld

wallyworld Feb 23, 2017

Owner

moved to juju/juju/api
added specific func to manifold

worker/firewaller/firewaller.go
+// defined on the environs.Environ interface.
+type Environ interface {
+ environs.Firewaller
+ Instances(ids []instance.Id) ([]instance.Instance, error)
@axw

axw Feb 23, 2017

Member

I think it would be better for this worker to accept two things: an environs.Firewaller, and an Instanceser (ha ha - real name TBD), an each of those just-so-happen to be satisfied by the same environs.Environ.

+
+// Config defines the operation of a Worker.
+type Config struct {
+ ModelUUID string
@axw

axw Feb 23, 2017

Member

what's the ModelUUID for? doesn't appear to be used

@wallyworld

wallyworld Feb 23, 2017

Owner

Not used in this PR. I expect to use it in the next one. If not, I'll remove it there.

worker/firewaller/firewaller.go
- remoteRelationsApi *remoterelations.Client,
-) (worker.Worker, error) {
+// NewFirewaller returns a new Firewaller.
+func NewFirewaller(cfg Config) (worker.Worker, error) {
fw := &Firewaller{
@axw

axw Feb 23, 2017

Member

call cfg.Validate above?

@wallyworld

wallyworld Feb 23, 2017

Owner

oops. done

axw approved these changes Feb 23, 2017

api/apiclient.go
@@ -270,6 +270,25 @@ func open(
return st, nil
}
+type ConnectionForModelFunc func(*Info) (func(string) (Connection, error), error)
+
+// APIConnForModelFunc provides a function which returns a model API
@axw

axw Feb 23, 2017

Member

// ConnectionForModel ...

@axw

axw Feb 23, 2017

Member

also, maybe "NewConnectionForModelFunc" would be more appropriate? ConnectionForModel does not itself return a Connection.

apiserver/networks/state.go
+ "github.com/juju/juju/state"
+)
+
+// StatePool provides the subset of a state pool required by the
@axw

axw Feb 23, 2017

Member

delete me

apiserver/networks/state.go
+ WatchSubnets() state.StringsWatcher
+}
+
+type statePoolShim struct {
@axw

axw Feb 23, 2017

Member

delete me

apiserver/networks/state.go
+ *state.State
+}
+
+func (st stateShim) WatchSubnets() state.StringsWatcher {
@axw

axw Feb 23, 2017

Member

this is unnecessary, since state.State already has the WatchSubnets method with the required signature

Owner

wallyworld commented Feb 23, 2017

$$merge$$

Contributor

jujubot commented Feb 23, 2017

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

Contributor

jujubot commented Feb 23, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/10357

Owner

wallyworld commented Feb 23, 2017

$$merge$$

Contributor

jujubot commented Feb 23, 2017

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

@jujubot jujubot merged commit b328000 into juju:develop Feb 23, 2017

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