Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(312)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Issue 85590044: Various address logic fixes

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 9 months ago by axw
Modified:
11 years, 9 months ago
Reviewers:
gz , mp+215085, rog
Visibility:
Public.
Various address logic fixes - Unified logic for Select{Public,Internal}Address. Now they both return the first public/private address, or the first address with a usable scope. - instance.NewAddress will now derive the scope of IPv4 address from the network range. Loopback addresses are machine-local, private network addresses are cloud- local, all others are public. - Now using instance.NewAddress in provider/openstack and worker/machiner so scope derivation logic is used. Live-tested on HP Cloud and Canonistack. - Dropped instance.HostAddresses; it is no longer used. - Fixed state.mergedAddresses to maintain order. Fixes lp:1303735 https://code.launchpad.net/~axwalk/juju-core/lp1303735-fix-address-logic/+merge/215085 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 8

Patch Set 2 : Various address logic fixes #

Total comments: 11

Patch Set 3 : Various address logic fixes #

Patch Set 4 : Various address logic fixes #

Created: 11 years, 9 months ago
Download [raw] [tar.bz2]
Unified diffs Side-by-side diffs Delta from patch set Stats (+284 lines, -198 lines) Patch
A [revision details] View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/juju/status_test.go View 3 chunks +3 lines, -3 lines 0 comments Download
M instance/address.go View 1 4 chunks +133 lines, -90 lines 0 comments Download
M instance/address_test.go View 5 chunks +49 lines, -49 lines 0 comments Download
M provider/common/state.go View 1 chunk +0 lines, -1 line 0 comments Download
M provider/maas/instance.go View 1 chunk +1 line, -1 line 0 comments Download
M provider/openstack/provider.go View 1 2 1 chunk +4 lines, -6 lines 0 comments Download
M provider/openstack/provider_test.go View 1 2 3 2 chunks +8 lines, -8 lines 0 comments Download
M state/api/machiner/machiner_test.go View 2 chunks +2 lines, -1 line 0 comments Download
M state/api/state.go View 1 chunk +2 lines, -6 lines 0 comments Download
M state/apiserver/machine/machiner.go View 1 chunk +1 line, -1 line 0 comments Download
M state/machine.go View 3 chunks +15 lines, -13 lines 0 comments Download
M state/machine_test.go View 1 chunk +30 lines, -1 line 0 comments Download
M state/unit_test.go View 1 chunk +25 lines, -0 lines 0 comments Download
M worker/machiner/machiner.go View 1 chunk +1 line, -8 lines 0 comments Download
M worker/machiner/machiner_test.go View 2 chunks +6 lines, -4 lines 0 comments Download
M worker/peergrouper/worker_test.go View 1 chunk +2 lines, -6 lines 0 comments Download
Total messages: 7
|
axw
Please take a look.
11 years, 9 months ago (2014年04月10日 06:54:29 UTC) #1
Please take a look.
Sign in to reply to this message.
rog
Nice, LGTM. https://codereview.appspot.com/85590044/diff/1/instance/address.go File instance/address.go (right): https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode34 instance/address.go:34: Ipv4Address AddressType = "ipv4" It would be ...
11 years, 9 months ago (2014年04月10日 07:31:08 UTC) #2
Nice, LGTM.
https://codereview.appspot.com/85590044/diff/1/instance/address.go
File instance/address.go (right):
https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode34
instance/address.go:34: Ipv4Address AddressType = "ipv4"
It would be great if we could fix the spelling of these to
conform with Go convention (IPv4Address, IPv6Address).
No particular need to do it now though - it's just
been bugging me occasionally when I see it.
https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode119
instance/address.go:119: if ip != nil {
if ip == nil {
 return HostName
}
then lose an indent level below?
or even:
switch {
case ip == nil:
 return HostName
case ip.To4() != nil:
 return Ipv4Address
case ip.To6() != nil:
 return Ipv6Address
default:
 panic("Unknown form of IP address"
}
oops, wrote that, then realised it wasn't new code.
feel free to ignore.
https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode132
instance/address.go:132: func isIpv4PrivateNetworkAddress(ip net.IP) bool {
s/Ip/IP/
https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode170
instance/address.go:170: func NewAddress(value string, scope NetworkScope)
Address {
Perhaps move scope to the first argument here, so that if we add
the same argument to NewAddresses, the two functions can be consistent?
Sign in to reply to this message.
axw
Please take a look. https://codereview.appspot.com/85590044/diff/1/instance/address.go File instance/address.go (right): https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode34 instance/address.go:34: Ipv4Address AddressType = "ipv4" On ...
11 years, 9 months ago (2014年04月10日 08:13:31 UTC) #3
Please take a look.
https://codereview.appspot.com/85590044/diff/1/instance/address.go
File instance/address.go (right):
https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode34
instance/address.go:34: Ipv4Address AddressType = "ipv4"
On 2014年04月10日 07:31:08, rog wrote:
> It would be great if we could fix the spelling of these to
> conform with Go convention (IPv4Address, IPv6Address).
> No particular need to do it now though - it's just
> been bugging me occasionally when I see it.
Agreed, but not now as discussed.
https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode119
instance/address.go:119: if ip != nil {
On 2014年04月10日 07:31:08, rog wrote:
> if ip == nil {
> return HostName
> }
> 
> then lose an indent level below?
> or even:
> 
> switch {
> case ip == nil:
> return HostName
> case ip.To4() != nil:
> return Ipv4Address
> case ip.To6() != nil:
> return Ipv6Address
> default:
> panic("Unknown form of IP address"
> }
> 
> oops, wrote that, then realised it wasn't new code.
> feel free to ignore.
Easy win, done.
https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode132
instance/address.go:132: func isIpv4PrivateNetworkAddress(ip net.IP) bool {
On 2014年04月10日 07:31:08, rog wrote:
> s/Ip/IP/
Done.
https://codereview.appspot.com/85590044/diff/1/instance/address.go#newcode170
instance/address.go:170: func NewAddress(value string, scope NetworkScope)
Address {
On 2014年04月10日 07:31:08, rog wrote:
> Perhaps move scope to the first argument here, so that if we add
> the same argument to NewAddresses, the two functions can be consistent?
Maybe another time, but this is going to create a lot of noise I'd rather not
have to backport.
Sign in to reply to this message.
gz
LGTM. Only one real thing to fix, and some other general comments. https://codereview.appspot.com/85590044/diff/20001/instance/address.go File instance/address.go ...
11 years, 9 months ago (2014年04月10日 11:23:27 UTC) #4
LGTM. Only one real thing to fix, and some other general comments.
https://codereview.appspot.com/85590044/diff/20001/instance/address.go
File instance/address.go (left):
https://codereview.appspot.com/85590044/diff/20001/instance/address.go#oldcod...
instance/address.go:196: mostPublicIndex = i
We're losing a subtle hack here, which is public addresses fallback to the last,
not the first, non-public addr. This is to support the HP style case where
adding a floating ip goes on the end of the list of addresses. Obviously, that
was pretty fragile anyway. With the public/private bits being auto-filled for
openstack anyway, this is probably okay.
https://codereview.appspot.com/85590044/diff/20001/instance/address.go
File instance/address.go (right):
https://codereview.appspot.com/85590044/diff/20001/instance/address.go#newcod...
instance/address.go:159: return NetworkPublic
I'm not super-happy with this statement, but I think it will work for all the
cases we care about.
https://codereview.appspot.com/85590044/diff/20001/instance/address_test.go
File instance/address_test.go (right):
https://codereview.appspot.com/85590044/diff/20001/instance/address_test.go#n...
instance/address_test.go:165: "first unknown address selected",
Okay, and here's the test change to go with the logic flip.
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
File provider/openstack/provider.go (left):
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
provider/openstack/provider.go:419: NetworkName: network,
FIX: You've lost the recording of NetworkName - we really do want this when it's
available.
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
File provider/openstack/provider_test.go (left):
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
provider/openstack/provider_test.go:63: private: []nova.IPAddress{{4,
"127.0.0.4"}, {4, "8.8.4.4"}},
And this is the real world example (mostly, not sure why I used a 127. address
not a 10. address) we expect to work... I'm not sure about your changes to this
test? The code should still pick the 8. address if a non-public one is first,
due to the private address range matching?
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
File provider/openstack/provider_test.go (right):
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
provider/openstack/provider_test.go:82: private: []nova.IPAddress{{4,
"127.0.0.4"}, {4, "192.168.0.1"}},
Hm, okay, as I'm not actually doing the network name checking any more, making
these 'private' labelled addresses all cloud-local is reasonable.
https://codereview.appspot.com/85590044/diff/20001/worker/machiner/machiner.go
File worker/machiner/machiner.go (right):
https://codereview.appspot.com/85590044/diff/20001/worker/machiner/machiner.g...
worker/machiner/machiner.go:80: address := instance.NewAddress(ip.String(),
instance.NetworkUnknown)
Good change. We probably still don't want to use this function too widely, as
using machine-reported addresses is a bad idea for most providers. That's a
slight problem with NewAddress actually becoming useful rather than a stub, it
will mostly work in more cases.
Sign in to reply to this message.
axw
Please take a look. https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provider.go File provider/openstack/provider.go (left): https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provider.go#oldcode419 provider/openstack/provider.go:419: NetworkName: network, On 2014年04月10日 11:23:27, ...
11 years, 9 months ago (2014年04月10日 11:57:54 UTC) #5
Please take a look.
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
File provider/openstack/provider.go (left):
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
provider/openstack/provider.go:419: NetworkName: network,
On 2014年04月10日 11:23:27, gz wrote:
> FIX: You've lost the recording of NetworkName - we really do want this when
it's
> available.
Good catch! Thanks, done.
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
File provider/openstack/provider_test.go (left):
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
provider/openstack/provider_test.go:63: private: []nova.IPAddress{{4,
"127.0.0.4"}, {4, "8.8.4.4"}},
On 2014年04月10日 11:23:27, gz wrote:
> And this is the real world example (mostly, not sure why I used a 127. address
> not a 10. address) we expect to work... I'm not sure about your changes to
this
> test? The code should still pick the 8. address if a non-public one is first,
> due to the private address range matching?
I changed it because 127.0.0.4 is machine-local, and hence will never match.
Likewise for the other test changes.
Sign in to reply to this message.
gz
LGTM. https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provider_test.go File provider/openstack/provider_test.go (left): https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provider_test.go#oldcode63 provider/openstack/provider_test.go:63: private: []nova.IPAddress{{4, "127.0.0.4"}, {4, "8.8.4.4"}}, On 2014年04月10日 11:57:54, ...
11 years, 9 months ago (2014年04月10日 12:20:04 UTC) #6
LGTM.
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
File provider/openstack/provider_test.go (left):
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
provider/openstack/provider_test.go:63: private: []nova.IPAddress{{4,
"127.0.0.4"}, {4, "8.8.4.4"}},
On 2014年04月10日 11:57:54, axw wrote:
> On 2014年04月10日 11:23:27, gz wrote:
> > And this is the real world example (mostly, not sure why I used a 127.
address
> > not a 10. address) we expect to work... I'm not sure about your changes to
> this
> > test? The code should still pick the 8. address if a non-public one is
first,
> > due to the private address range matching?
> 
> I changed it because 127.0.0.4 is machine-local, and hence will never match.
> Likewise for the other test changes.
So, specifically, the test should be (and should work as) {"10.0.0.1",
"8.8.4.4"} -> "8.8.4.4".
Sign in to reply to this message.
axw
Please take a look. https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provider_test.go File provider/openstack/provider_test.go (left): https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provider_test.go#oldcode63 provider/openstack/provider_test.go:63: private: []nova.IPAddress{{4, "127.0.0.4"}, {4, "8.8.4.4"}}, ...
11 years, 9 months ago (2014年04月10日 13:22:24 UTC) #7
Please take a look.
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
File provider/openstack/provider_test.go (left):
https://codereview.appspot.com/85590044/diff/20001/provider/openstack/provide...
provider/openstack/provider_test.go:63: private: []nova.IPAddress{{4,
"127.0.0.4"}, {4, "8.8.4.4"}},
On 2014年04月10日 12:20:04, gz wrote:
> On 2014年04月10日 11:57:54, axw wrote:
> > On 2014年04月10日 11:23:27, gz wrote:
> > > And this is the real world example (mostly, not sure why I used a 127.
> address
> > > not a 10. address) we expect to work... I'm not sure about your changes to
> > this
> > > test? The code should still pick the 8. address if a non-public one is
> first,
> > > due to the private address range matching?
> > 
> > I changed it because 127.0.0.4 is machine-local, and hence will never match.
> > Likewise for the other test changes.
> 
> So, specifically, the test should be (and should work as) {"10.0.0.1",
> "8.8.4.4"} -> "8.8.4.4".
Done.
Sign in to reply to this message.
|
Powered by Google App Engine
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /