Merge lp:~natefinch/juju-core/051-agent-addresses into lp:~go-bot/juju-core/trunk

Proposed by Nate Finch
Status: Work in progress
Proposed branch: lp:~natefinch/juju-core/051-agent-addresses
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 42 lines (+6/-10)
2 files modified
agent/agent.go (+4/-3)
agent/agent_test.go (+2/-7)
To merge this branch: bzr merge lp:~natefinch/juju-core/051-agent-addresses
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+218878@code.launchpad.net

Description of the change

API should report all non-machine-local addresses

To support the manual provider, we need to report all addresses that are not machine-local for the API servers. Previously, we were only reporting cloud-local addresses, which often will not work if you're using the manual provider.

https://codereview.appspot.com/91270044/

To post a comment you must log in.
Revision history for this message
Nate Finch (natefinch) wrote :

Reviewers: mp+218878_code.launchpad.net,

Message:
Please take a look.

Description:
API should report all non-machine-local addresses

To support the manual provider, we need to report all addresses that are
not machine-local for the API servers. Previously, we were only
reporting cloud-local addresses, which often will not work if you're
using the manual provider.

https://code.launchpad.net/~natefinch/juju-core/051-agent-addresses/+merge/218878

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/91270044/

Affected files (+8, -10 lines):
   A [revision details]
   M agent/agent.go
   M agent/agent_test.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20140507125024-3qwgzgd4kzdr6prt
+New revision: <email address hidden>

Index: agent/agent.go
=== modified file 'agent/agent.go'
--- agent/agent.go 2014-04-23 08:50:28 +0000
+++ agent/agent.go 2014-05-08 20:12:21 +0000
@@ -440,9 +440,10 @@
   }
   var addrs []string
   for _, serverHostPorts := range servers {
- addr := instance.SelectInternalHostPort(serverHostPorts, false)
- if addr != "" {
- addrs = append(addrs, addr)
+ for _, hp := range serverHostPorts {
+ if hp.NetworkScope != instance.NetworkMachineLocal {
+ addrs = append(addrs, hp.NetAddr())
+ }
    }
   }
   c.apiDetails.addresses = addrs

Index: agent/agent_test.go
=== modified file 'agent/agent_test.go'
--- agent/agent_test.go 2014-04-23 08:50:28 +0000
+++ agent/agent_test.go 2014-05-08 20:12:21 +0000
@@ -508,12 +508,7 @@
   c.Assert(err, gc.IsNil)
   c.Assert(addrs, gc.DeepEquals, attributeParams.APIAddresses)

- // The first cloud-local address for each server is used,
- // else if there are none then the first public- or unknown-
- // scope address.
- //
- // If a server has only machine-local addresses, or none
- // at all, then it will be excluded.
+ // All addresses which are not machine-local will be used.
   server1 := instance.NewAddresses("0.1.2.3", "0.1.2.4", "zeroonetwothree")
   server1[0].NetworkScope = instance.NetworkCloudLocal
   server1[1].NetworkScope = instance.NetworkCloudLocal
@@ -530,5 +525,5 @@
   })
   addrs, err = conf.APIAddresses()
   c.Assert(err, gc.IsNil)
- c.Assert(addrs, gc.DeepEquals, []string{"0.1.2.3:123", "0.1.2.5:125"})
+ c.Assert(addrs, jc.SameContents,
[]string{"0.1.2.3:123", "0.1.2.5:125", "0.1.2.4:123", "zeroonetwothree:123", "zeroonetwofive:125"})
  }

Revision history for this message
William Reade (fwereade) wrote :

LGTM.

Only quibble is that it might be worth extracting that new logic to a
selection func that can live next to the original one.

https://codereview.appspot.com/91270044/diff/1/agent/agent.go
File agent/agent.go (right):

https://codereview.appspot.com/91270044/diff/1/agent/agent.go#newcode444
agent/agent.go:444: if hp.NetworkScope != instance.NetworkMachineLocal {
is there any possibility this will fail on the local provider?

https://codereview.appspot.com/91270044/diff/1/agent/agent_test.go
File agent/agent_test.go (left):

https://codereview.appspot.com/91270044/diff/1/agent/agent_test.go#oldcode516
agent/agent_test.go:516: // at all, then it will be excluded.
ok, I guess if machine-local was definitely already excluded we're fine
:)

https://codereview.appspot.com/91270044/

Revision history for this message
John A Meinel (jameinel) wrote :

On 2014/05/08 21:07:17, fwereade wrote:
> LGTM.

> Only quibble is that it might be worth extracting that new logic to a
selection
> func that can live next to the original one.

> https://codereview.appspot.com/91270044/diff/1/agent/agent.go
> File agent/agent.go (right):

https://codereview.appspot.com/91270044/diff/1/agent/agent.go#newcode444
> agent/agent.go:444: if hp.NetworkScope != instance.NetworkMachineLocal
{
> is there any possibility this will fail on the local provider?

> https://codereview.appspot.com/91270044/diff/1/agent/agent_test.go
> File agent/agent_test.go (left):

https://codereview.appspot.com/91270044/diff/1/agent/agent_test.go#oldcode516
> agent/agent_test.go:516: // at all, then it will be excluded.
> ok, I guess if machine-local was definitely already excluded we're
fine :)

I'd be happier if we were doing HostPorts storage on this, so that we
could see the list of ones to try first, and then what to try second
(cloud-local first, etc).
Are there plans to push all the way to that point? This could be an ok
bridge-the-gap, I just worry that it will be good-enough-for-now and we
don't actually fix the underlying issues.

https://codereview.appspot.com/91270044/

Revision history for this message
Nate Finch (natefinch) wrote :

On 2014/05/09 09:15:52, jameinel wrote:
> I'd be happier if we were doing HostPorts storage on this, so that we
could see
> the list of ones to try first, and then what to try second
(cloud-local first,
> etc).
> Are there plans to push all the way to that point? This could be an ok
> bridge-the-gap, I just worry that it will be good-enough-for-now and
we don't
> actually fix the underlying issues.

I hadn't had plans to do that, though I do agree it's a better approach.
  I can do that if we think it's worth a little extra work.

https://codereview.appspot.com/91270044/

Revision history for this message
William Reade (fwereade) wrote :

OK, let's go with hostport storage for consistency's sake as well.

https://codereview.appspot.com/91270044/

Unmerged revisions

2705. By Nate Finch

report all addresses that aren't machine-local for API addresses

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'agent/agent.go'
2--- agent/agent.go 2014-04-23 08:50:28 +0000
3+++ agent/agent.go 2014-05-08 20:22:57 +0000
4@@ -440,9 +440,10 @@
5 }
6 var addrs []string
7 for _, serverHostPorts := range servers {
8- addr := instance.SelectInternalHostPort(serverHostPorts, false)
9- if addr != "" {
10- addrs = append(addrs, addr)
11+ for _, hp := range serverHostPorts {
12+ if hp.NetworkScope != instance.NetworkMachineLocal {
13+ addrs = append(addrs, hp.NetAddr())
14+ }
15 }
16 }
17 c.apiDetails.addresses = addrs
18
19=== modified file 'agent/agent_test.go'
20--- agent/agent_test.go 2014-04-23 08:50:28 +0000
21+++ agent/agent_test.go 2014-05-08 20:22:57 +0000
22@@ -508,12 +508,7 @@
23 c.Assert(err, gc.IsNil)
24 c.Assert(addrs, gc.DeepEquals, attributeParams.APIAddresses)
25
26- // The first cloud-local address for each server is used,
27- // else if there are none then the first public- or unknown-
28- // scope address.
29- //
30- // If a server has only machine-local addresses, or none
31- // at all, then it will be excluded.
32+ // All addresses which are not machine-local will be used.
33 server1 := instance.NewAddresses("0.1.2.3", "0.1.2.4", "zeroonetwothree")
34 server1[0].NetworkScope = instance.NetworkCloudLocal
35 server1[1].NetworkScope = instance.NetworkCloudLocal
36@@ -530,5 +525,5 @@
37 })
38 addrs, err = conf.APIAddresses()
39 c.Assert(err, gc.IsNil)
40- c.Assert(addrs, gc.DeepEquals, []string{"0.1.2.3:123", "0.1.2.5:125"})
41+ c.Assert(addrs, jc.SameContents, []string{"0.1.2.3:123", "0.1.2.5:125", "0.1.2.4:123", "zeroonetwothree:123", "zeroonetwofive:125"})
42 }

Subscribers

People subscribed via source and target branches

to status/vote changes: