Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadbalancers: Support nodes where nodeName is the private or public IP #75

Merged
merged 1 commit into from Apr 14, 2018
Merged

Conversation

klausenbusk
Copy link
Contributor

@klausenbusk klausenbusk commented Apr 6, 2018

Fix #69

for _, droplet := range droplets {
if node.Name == droplet.Name {
dropletIDs = append(dropletIDs, droplet.ID)
break
}
addresses, _ := nodeAddresses(&droplet)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we handle this error here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only log it for now or change the nodeAddresses function, right now a single node without private network would cause a error. Why do we require private network anyway? It should be optional.

func nodeAddresses(droplet *godo.Droplet) ([]v1.NodeAddress, error) {
var addresses []v1.NodeAddress
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeHostName, Address: droplet.Name})
privateIP, err := droplet.PrivateIPv4()
if err != nil || privateIP == "" {
return nil, fmt.Errorf("could not get private ip: %v", err)
}
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeInternalIP, Address: privateIP})
publicIP, err := droplet.PublicIPv4()
if err != nil || publicIP == "" {
return nil, fmt.Errorf("could not get public ip: %v", err)
}
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeExternalIP, Address: publicIP})
return addresses, nil
}

We do not handle error in

addresses, _ := nodeAddresses(&droplet)
either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is very reasonable, just logging works for me :)

@andrewsykim
Copy link
Contributor

@klausenbusk thanks so much for this PR. Just had one minor comment and it should good to go

@klausenbusk klausenbusk changed the title [WIP] Fix #69 loadbalancers: Support nodes where nodeName is the private or public IP Apr 13, 2018
@klausenbusk
Copy link
Contributor Author

Ready for merge I suppose. I'm not sure if I did the logging thing correctly (?).

for _, droplet := range droplets {
if node.Name == droplet.Name {
dropletIDs = append(dropletIDs, droplet.ID)
break
}
addresses, err := nodeAddresses(&droplet)
if err != nil {
glog.Errorf("error getting node addresses for %s: %v", droplet.Name, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a continue here otherwise there would be a panic on the next for loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, are you sure about the panic? The spec says For a nil slice, the number of iterations is 0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL :)

@andrewsykim
Copy link
Contributor

sorry @klausenbusk one more comment

@andrewsykim
Copy link
Contributor

LGTM thanks!

@andrewsykim andrewsykim merged commit 5cf8fac into digitalocean:master Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants