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

Automated cherry pick of #12438 #13121 upstream release 1.0 #13127

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkg/cloudprovider/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloudprovider/gce/gce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down