Merge pull request #13127 from a-robinson/automated-cherry-pick-of-#12438-#13121-upstream-release-1.0

Automated cherry pick of #12438 #13121 upstream release 1.0
This commit is contained in:
Robert Bailey
2015-08-24 23:36:03 -07:00
2 changed files with 12 additions and 2 deletions

View File

@@ -443,9 +443,15 @@ func (gce *GCECloud) CreateTCPLoadBalancer(name, region string, externalIP net.I
}
// This is kind of hacky, but the managed instance group adds 4 random chars and a hyphen
// to the base name.
// to the base name. Older naming schemes put a hyphen and an incrementing index after
// the base name. Thus we pull off the characters after the final dash to support both.
func (gce *GCECloud) computeHostTag(host string) string {
return host[:len(host)-5]
host = strings.SplitN(host, ".", 2)[0]
lastHyphen := strings.LastIndex(host, "-")
if lastHyphen == -1 {
return host
}
return host[:lastHyphen]
}
// UpdateTCPLoadBalancer is an implementation of TCPLoadBalancer.UpdateTCPLoadBalancer.

View File

@@ -50,6 +50,10 @@ func TestGetHostTag(t *testing.T) {
host: "gke-test-ea6e8c80-node-8ytk",
expected: "gke-test-ea6e8c80-node",
},
{
host: "kubernetes-minion-559o.c.PROJECT_NAME.internal",
expected: "kubernetes-minion",
},
}
gce := &GCECloud{}