Improvements to ingress address watcher #7184

Merged
merged 2 commits into from Apr 1, 2017

Conversation

Projects
None yet
3 participants
Owner

wallyworld commented Mar 31, 2017

Description of change

The way the firewaller watches for ingress address changes is altered to use a stringswatcher instead of a notifywatcher. The watcher event now contains the working set of ingress addresses; there is no need for a separate api call to get the addresses, so this facade method is removed.

A new IngressAddressWatcher is added which watches for units on a given relation to enter'leave scope, and returns the set of public addresses for all units in scope. This is not used yet but will be in a subsequent PR.

QA steps

Run up a CMR scenario on AWS.
Ensure the units can talk to each other.
Check the AWS sec group rules to ensure the expected subnets are used.

+ return result
+}
+
+func (w *IngressAddressWatcher) Changes() <-chan []string {
@axw

axw Mar 31, 2017

Member

// Changes is part of the StringsWatcher interface.

@axw

axw Mar 31, 2017

Member

I think it would be helpful to group the interface methods together, either above or below the guts.

+
+ u, err := w.backend.Unit(name)
+ if errors.IsNotFound(err) {
+ logger.Warningf("unit %s is not found, can't get address", name)
@axw

axw Mar 31, 2017

Member

does this really need a warning? isn't it normal for to get

  1. RUW.Changed
  2. (unit departed, then removed)
  3. RUW.Departed

?
so just ignore the NotFound, and we'll report the address removal when the Departed event comes along

@wallyworld

wallyworld Mar 31, 2017

Owner

removed the warning

+
+ // TODO - start watcher to pick up machine address changes
+ // We need to know whether to look at the public or cloud local address.
+ // For now, we'll use the public address and later if needed use a watcher
@axw

axw Mar 31, 2017

Member

that's probably fine in general, but we still need to watch addresses in case (a) the machine doesn't have an address yet, or (b) the public address changes

@wallyworld

wallyworld Mar 31, 2017

Owner

agreed, hence the todo.

+ // For now, we'll use the public address and later if needed use a watcher
+ // parameter to look at the cloud local address.
+ addr, err := u.PublicAddress()
+ if errors.IsNotAssigned(err) {
@axw

axw Mar 31, 2017

Member

both of these warnings should be removed (or changed to debug) when we start watching addresses

@wallyworld

wallyworld Mar 31, 2017

Owner

i'll make debug now

+ w.known[name] = addr.Value
+ }
+ for _, name := range c.Departed {
+ // If the unit is departing and we have seen it's address,
@axw

axw Mar 31, 2017

Member

s/it's/its/

+ address, ok := w.known[name]
+ if ok {
+ delete(w.known, name)
+ result.Remove(address)
@axw

axw Mar 31, 2017

Member

this assumes that there's 1:1 between RUW and address, which is not necessarily true. you could have two units on the same machine. so I think you need a counter as well.

@wallyworld

wallyworld Mar 31, 2017

Owner

Yep, good point,fixed

+ return result, nil
+}
+
+func (w *IngressAddressWatcher) Kill() {
@axw

axw Mar 31, 2017

Member

doc comments

axw approved these changes Mar 31, 2017

Owner

wallyworld commented Mar 31, 2017

$$merge$$

Contributor

jujubot commented Mar 31, 2017

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

Contributor

jujubot commented Mar 31, 2017

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

Owner

wallyworld commented Apr 1, 2017

$$merge$$

Contributor

jujubot commented Apr 1, 2017

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

Contributor

jujubot commented Apr 1, 2017

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

Owner

wallyworld commented Apr 1, 2017

$$merge$$

Contributor

jujubot commented Apr 1, 2017

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

@jujubot jujubot merged commit 0227008 into juju:develop Apr 1, 2017

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