Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus committed Jan 8, 2020
1 parent 27332be commit d9f8413
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/cloudprovider/providers/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,21 +675,23 @@ func getServerByName(client *gophercloud.ServiceClient, name types.NodeName) (*S
// * interfaces private IPs
// * access IPs
// * metadata hostname
// * server object Addresses
// * server object Addresses (floating type)
func nodeAddresses(srv *servers.Server, interfaces []attachinterfaces.Interface, networkingOpts NetworkingOpts) ([]v1.NodeAddress, error) {
addrs := []v1.NodeAddress{}

// parse private IP addresses first in an ordered manner
for _, iface := range interfaces {
for _, fixedIP := range iface.FixedIPs {
isIPv6 := net.ParseIP(fixedIP.IPAddress).To4() == nil
if !(isIPv6 && networkingOpts.IPv6SupportDisabled) {
v1helper.AddToNodeAddresses(&addrs,
v1.NodeAddress{
Type: v1.NodeInternalIP,
Address: fixedIP.IPAddress,
},
)
if iface.PortState == "ACTIVE" {
isIPv6 := net.ParseIP(fixedIP.IPAddress).To4() == nil
if !(isIPv6 && networkingOpts.IPv6SupportDisabled) {
v1helper.AddToNodeAddresses(&addrs,
v1.NodeAddress{
Type: v1.NodeInternalIP,
Address: fixedIP.IPAddress,
},
)
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/cloudprovider/providers/openstack/openstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,11 @@ func TestNodeAddresses(t *testing.T) {
FixedIPs: []attachinterfaces.FixedIP{
{
IPAddress: "10.0.0.32",
PortState: "ACTIVE",
},
{
IPAddress: "10.0.0.31",
PortState: "ACTIVE",
},
},
},
Expand Down Expand Up @@ -671,9 +673,11 @@ func TestNodeAddressesCustomPublicNetwork(t *testing.T) {
FixedIPs: []attachinterfaces.FixedIP{
{
IPAddress: "10.0.0.32",
PortState: "ACTIVE",
},
{
IPAddress: "10.0.0.31",
PortState: "ACTIVE",
},
},
},
Expand Down Expand Up @@ -749,9 +753,11 @@ func TestNodeAddressesIPv6Disabled(t *testing.T) {
FixedIPs: []attachinterfaces.FixedIP{
{
IPAddress: "10.0.0.32",
PortState: "ACTIVE",
},
{
IPAddress: "10.0.0.31",
PortState: "ACTIVE",
},
},
},
Expand Down

0 comments on commit d9f8413

Please sign in to comment.