From 2d5d301669a96d9c43b1a7cb68544c6917cd55c5 Mon Sep 17 00:00:00 2001 From: Ashley Gau Date: Tue, 6 Feb 2018 10:48:09 -0800 Subject: [PATCH 1/2] use comparable host path instead of full url when creating a targetpool --- pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go b/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go index ceaaf053593..e3570dccc61 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{ From 41318d7596885fa1e6b7921d2ae55cb73b07f1c5 Mon Sep 17 00:00:00 2001 From: Ashley Gau Date: Tue, 6 Feb 2018 10:49:08 -0800 Subject: [PATCH 2/2] move makeHostUrl to gce_instances (only used there) --- pkg/cloudprovider/providers/gce/gce_instances.go | 5 +++++ pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) 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 e3570dccc61..8cce4e2fe51 100644 --- a/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go +++ b/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go @@ -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 {