Merge lp:~gz/juju-core/api_endpoint_no_machine_local_1310258 into lp:~go-bot/juju-core/trunk
Proposed by
Martin Packman
Status: | Merged |
---|---|
Approved by: | Ian Booth |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2664 |
Proposed branch: | lp:~gz/juju-core/api_endpoint_no_machine_local_1310258 |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
59 lines (+40/-1) 2 files modified
juju/api.go (+5/-1) juju/apiconn_test.go (+35/-0) |
To merge this branch: | bzr merge lp:~gz/juju-core/api_endpoint_no_machine_local_1310258 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+216744@code.launchpad.net |
Commit message
juju: Omit IPv6 and local addresses from jenv
Until the jenv addresses cache gains the extra metadata
fields that are returned over the API, filter out the
addresses that are unlikely to be useful for connecting
to an API server.
Description of the change
juju: Omit IPv6 and local addresses from jenv
Until the jenv addresses cache gains the extra metadata
fields that are returned over the API, filter out the
addresses that are unlikely to be useful for connecting
to an API server.
To post a comment you must log in.
Reviewers: mp+216744_ code.launchpad. net,
Message:
Please take a look.
Description:
juju: Omit IPv6 and local addresses from jenv
Until the jenv addresses cache gains the extra metadata
fields that are returned over the API, filter out the
addresses that are unlikely to be useful for connecting
to an API server.
https:/ /code.launchpad .net/~gz/ juju-core/ api_endpoint_ no_machine_ local_1310258/ +merge/ 216744
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/90310043/
Affected files (+42, -1 lines): test.go
A [revision details]
M juju/api.go
M juju/apiconn_
Index: [revision details] 20140422051657- 1svpzqvmysbn4tq m
=== 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-
+New revision: <email address hidden>
Index: juju/api.go Ipv6Address && hostPort. NetworkScope != NetworkMachineL ocal {
=== modified file 'juju/api.go'
--- juju/api.go 2014-04-17 15:35:11 +0000
+++ juju/api.go 2014-04-22 15:00:21 +0000
@@ -353,7 +353,11 @@
var addrs []string
for _, serverHostPorts := range st.APIHostPorts() {
for _, hostPort := range serverHostPorts {
- addrs = append(addrs, hostPort.NetAddr())
+ // Only cache addresses that are likely to be usable,
+ // exclude IPv6 for now and localhost style ones.
+ if hostPort.Type != instance.
instance.
+ addrs = append(addrs, hostPort.NetAddr())
+ }
}
}
endpoint := info.APIEndpoint()
Index: juju/apiconn_ test.go test.go' test.go 2014-04-17 15:35:11 +0000 test.go 2014-04-22 14:34:29 +0000 endpoint. Addresses, gc.DeepEquals, []string{ "0.1.2. 3:1234" }) EnvSuite) TestAPIEndpoint NotMachineLocal (c *gc.C) { MakeEmptyFakeHo me(c).Restore( ) "env-name" , dummyStoreInfo) HostPort{ AddressesWithPo rt([]instance. Address{ NewAddress( "1.0.0. 1", instance. NetworkPublic) , NewAddress( "192.0. 0.1", instance. NetworkCloudLoc al), NewAddress( "127.0. 0.1", instance. NetworkMachineL ocal), NewAddress( "localhost" , instance. NetworkMachineL ocal), AddressesWithPo rt([]instance. Address{ NewAddress( "1.0.0. 2", instance. NetworkUnknown) , NewAddress( "2002:0: 0:0:0:0: 100:2", instance. NetworkUnknown) , NewAddress( "::1", instance. NetworkMachineL ocal), NewAddress( "127.0. 0.1", instance. NetworkMachineL ocal), NewAddress( "localhost" , instance. NetworkMachineL ocal), apiHostPorts: hostPorts} tInStore( "env-name" , true, store, apiOpen) endpoint. Ad...
=== modified file 'juju/apiconn_
--- juju/apiconn_
+++ juju/apiconn_
@@ -661,3 +661,38 @@
// This refresh now gives us the values return by APIHostPorts
c.Check(
}
+
+func (s *APIEndpointFor
+ defer coretesting.
+ store := newConfigStore(
+ called := 0
+ hostPorts := [][]instance.
+ instance.
+ instance.
+ instance.
+ instance.
+ instance.
+ }, 1234),
+ instance.
+ instance.
+ instance.
+ instance.
+ instance.
+ instance.
+ }, 1235),
+ }
+
+ expectState := &mockAPIState{
+ apiOpen := func(_ *api.Info, _ api.DialOpts) (juju.APIState, error) {
+ called++
+ return expectState, nil
+ }
+ endpoint, err := juju.APIEndpoin
+ c.Assert(err, gc.IsNil)
+ c.Check(called, gc.Equals, 1)
+ c.Check(