diff --git a/pkg/cloudprovider/providers/gce/gce_instances.go b/pkg/cloudprovider/providers/gce/gce_instances.go index 90506911d81..497464bcc9f 100644 --- a/pkg/cloudprovider/providers/gce/gce_instances.go +++ b/pkg/cloudprovider/providers/gce/gce_instances.go @@ -67,6 +67,11 @@ func getZone(n *v1.Node) string { return zone } +func makeHostURL(projectsApiEndpoint, projectID, zone, host string) string { + host = canonicalizeInstanceName(host) + return projectsApiEndpoint + strings.Join([]string{projectID, "zones", zone, "instances", host}, "/") +} + // ToInstanceReferences returns instance references by links func (gce *GCECloud) ToInstanceReferences(zone string, instanceNames []string) (refs []*compute.InstanceReference) { for _, ins := range instanceNames { diff --git a/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go b/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go index ceaaf053593..8cce4e2fe51 100644 --- a/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go +++ b/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go @@ -535,7 +535,7 @@ func (gce *GCECloud) createTargetPoolAndHealthCheck(svc *v1.Service, name, servi var instances []string for _, host := range hosts { - instances = append(instances, makeHostURL(gce.service.BasePath, gce.projectID, host.Zone, host.Name)) + instances = append(instances, host.makeComparableHostPath()) } glog.Infof("Creating targetpool %v with %d healthchecks", name, len(hcLinks)) pool := &compute.TargetPool{ @@ -732,11 +732,6 @@ func nodeNames(nodes []*v1.Node) []string { return ret } -func makeHostURL(projectsApiEndpoint, projectID, zone, host string) string { - host = canonicalizeInstanceName(host) - return projectsApiEndpoint + strings.Join([]string{projectID, "zones", zone, "instances", host}, "/") -} - func hostURLToComparablePath(hostURL string) string { idx := strings.Index(hostURL, "/zones/") if idx < 0 {