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

Return an error from gce.EnsureTCPLoadBalancer with no hosts. #13336

Merged
merged 1 commit into from Aug 29, 2015

Conversation

cjcullen
Copy link
Member

It would be nicer if we could treat len(hosts) == 0 as valid, and create all the resources with a 0 VM target pool. Then the syncNode loop would be able to fix up the target pool when the cluster added nodes. But, we have no way of generating the hostTag for the firewall without any nodes. By returning an error, we let the servicecontroller know to keep trying.

@cjcullen
Copy link
Member Author

@a-robinson @fabioy @lavalamp thoughts?

@cjcullen
Copy link
Member Author

Addresses #13327

@k8s-bot
Copy link

k8s-bot commented Aug 28, 2015

GCE e2e build/test failed for commit 8305d28e48640c44b2f8e100ccf96b24a62cd2b4.

@a-robinson a-robinson self-assigned this Aug 28, 2015
@a-robinson
Copy link
Contributor

Travis, shippable, and Jenkins are all unhappy very quickly - can you fix whatever the issue is?

glog.V(2).Info("Checking if load balancer already exists: %s", name)
if len(hosts) == 0 {
glog.V(2).Error("Call to EnsureTCPLoadBalancer with no hosts")
return nil, errors.New("Cannot EnsureTCPLoadBalancer() with no hosts")
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this still delete any previous load balancer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure. My change would essentially make len(hosts) == 0 an error state for loadBalancers. As long as we are in that state, we are going to continue retrying this call. Does it matter whether we clear out the old LB now or when we actually have hosts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I also don't really think we want to do so - it seems best to keep the old load balancer's IP around.

Copy link
Contributor

Choose a reason for hiding this comment

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

Responding to @lavalamp's comment: "It seems like a problem if the old load balancer points to a bunch of things that no longer exist?"

The node sync loop part of the service controller already handles resizing the target pools down as the nodes in the cluster change. Not deleting the load balancer entirely enables a use case where you can scale down your cluster's nodes to zero but still have the same IP address for the service if you later re-add any nodes.

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

@k8s-bot
Copy link

k8s-bot commented Aug 28, 2015

GCE e2e build/test passed for commit f045ea280fa52f0b25740a10d3dbb360f1191a0a.

@@ -352,7 +352,12 @@ func makeFirewallName(name string) string {
// TODO(a-robinson): Don't just ignore specified IP addresses. Check if they're
// owned by the project and available to be used, and use them if they are.
func (gce *GCECloud) EnsureTCPLoadBalancer(name, region string, externalIP net.IP, ports []*api.ServicePort, hosts []string, affinityType api.ServiceAffinity) (*api.LoadBalancerStatus, error) {
glog.V(2).Info("Checking if load balancer already exists: %s", name)
if len(hosts) == 0 {
glog.Errorf("Call to EnsureTCPLoadBalancer with no hosts")
Copy link
Contributor

Choose a reason for hiding this comment

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

This log statement isn't really needed, the error you return will be logged at a higher level.

Copy link
Member

Choose a reason for hiding this comment

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

It seems like a problem if the old load balancer points to a bunch of things that no longer exist?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, that was supposed to be a reply to the other comment :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done (to @a-robinson's comment)

@k8s-bot
Copy link

k8s-bot commented Aug 29, 2015

GCE e2e build/test passed for commit cb7d3f0.

@a-robinson a-robinson added lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-merge labels Aug 29, 2015
@a-robinson
Copy link
Contributor

LGTM

@k8s-github-robot
Copy link

@k8s-bot test this [testing build queue, sorry for the noise]

@k8s-bot
Copy link

k8s-bot commented Aug 29, 2015

GCE e2e build/test passed for commit cb7d3f0.

@k8s-github-robot
Copy link

Automatic merge from SubmitQueue

k8s-github-robot pushed a commit that referenced this pull request Aug 29, 2015
Auto commit by PR queue bot
@k8s-github-robot k8s-github-robot merged commit c49466a into kubernetes:master Aug 29, 2015
@@ -352,7 +352,11 @@ func makeFirewallName(name string) string {
// TODO(a-robinson): Don't just ignore specified IP addresses. Check if they're
// owned by the project and available to be used, and use them if they are.
func (gce *GCECloud) EnsureTCPLoadBalancer(name, region string, externalIP net.IP, ports []*api.ServicePort, hosts []string, affinityType api.ServiceAffinity) (*api.LoadBalancerStatus, error) {
glog.V(2).Info("Checking if load balancer already exists: %s", name)
if len(hosts) == 0 {
return nil, fmt.Errorf("Cannot EnsureTCPLoadBalancer() with no hosts")
Copy link
Contributor

Choose a reason for hiding this comment

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

errors should start with a lower case letter :/

https://github.com/golang/go/wiki/CodeReviewComments#error-strings

roberthbailey referenced this pull request Sep 3, 2015
…3336-upstream-release-1.0

Return an error from gce.EnsureTCPLoadBalancer with no hosts.
@brendandburns brendandburns mentioned this pull request Sep 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants