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 9256f02
Show file tree
Hide file tree
Showing 2 changed files with 14 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
3 changes: 3 additions & 0 deletions pkg/cloudprovider/providers/openstack/openstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ func TestNodeAddresses(t *testing.T) {

interfaces := []attachinterfaces.Interface{
{
PortState: "ACTIVE",
FixedIPs: []attachinterfaces.FixedIP{
{
IPAddress: "10.0.0.32",
Expand Down Expand Up @@ -668,6 +669,7 @@ func TestNodeAddressesCustomPublicNetwork(t *testing.T) {

interfaces := []attachinterfaces.Interface{
{
PortState: "ACTIVE",
FixedIPs: []attachinterfaces.FixedIP{
{
IPAddress: "10.0.0.32",
Expand Down Expand Up @@ -746,6 +748,7 @@ func TestNodeAddressesIPv6Disabled(t *testing.T) {

interfaces := []attachinterfaces.Interface{
{
PortState: "ACTIVE",
FixedIPs: []attachinterfaces.FixedIP{
{
IPAddress: "10.0.0.32",
Expand Down

0 comments on commit 9256f02

Please sign in to comment.