Handle full hostname when computing host tag on GCE

The current code assumes the full domain name will not be included,
which is not always the case. This patch adds support for computing the
host tag from a fully qualified domain name.
This commit is contained in:
Derek Parker
2015-08-08 10:20:29 -05:00
committed by Alex Robinson
parent b9a88a7d0e
commit 36deb14f58
2 changed files with 5 additions and 0 deletions

View File

@@ -445,6 +445,7 @@ 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.
func (gce *GCECloud) computeHostTag(host string) string {
host = strings.SplitN(host, ".", 2)[0]
return host[:len(host)-5]
}

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{}