From 76d861d4edce3ad792069e34df29f45208db80f9 Mon Sep 17 00:00:00 2001 From: Spencer Hance Date: Mon, 3 Apr 2023 13:11:06 -0500 Subject: [PATCH] Revert "Set the k8s-cloud-provider API domain" --- cmd/glbc/main.go | 10 ---------- pkg/utils/utils.go | 9 --------- pkg/utils/utils_test.go | 40 ---------------------------------------- 3 files changed, 59 deletions(-) diff --git a/cmd/glbc/main.go b/cmd/glbc/main.go index d21475c5a5..98b6011ca4 100644 --- a/cmd/glbc/main.go +++ b/cmd/glbc/main.go @@ -24,7 +24,6 @@ import ( "os" "time" - k8scp "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" flag "github.com/spf13/pflag" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-gce/pkg/frontendconfig" @@ -35,7 +34,6 @@ import ( "k8s.io/ingress-gce/pkg/serviceattachment" "k8s.io/ingress-gce/pkg/servicemetrics" "k8s.io/ingress-gce/pkg/svcneg" - "k8s.io/ingress-gce/pkg/utils" "k8s.io/klog/v2" crdclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" @@ -191,14 +189,6 @@ func main() { kubeSystemUID := kubeSystemNS.GetUID() cloud := app.NewGCEClient() - - // Globally set the domain for all urls generated by GoogleCloudPlatform/k8s-cloud-provider. - // The cloud object is configured by the gce.conf file and parsed in app.NewGCEClient(). - // basePath will be of the form /v1 - domain := utils.GetDomainFromGABasePath(cloud.ComputeServices().GA.BasePath) - klog.Infof("Setting k8s-cloud-provider API Domain to %q", domain) - k8scp.SetAPIDomain(domain) - defaultBackendServicePort := app.DefaultBackendServicePort(kubeClient) ctxConfig := ingctx.ControllerContextConfig{ Namespace: flags.F.WatchNamespace, diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index f05477f50c..b03cd1769a 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -868,12 +868,3 @@ func AddIPToLBStatus(status *api_v1.LoadBalancerStatus, ips ...string) *api_v1.L } return status } - -// GetDomainFromGABasePath takes a GA base path of the form /compute/v1 and returns the path. -func GetDomainFromGABasePath(basePath string) string { - // Trim URL to remove the "/v1" part since we are using the GA path. - // Start by trimming any trailing "/" - domain := strings.TrimSuffix(basePath, "/") - domain = strings.TrimSuffix(domain, "/compute/v1") - return domain -} diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go index ad97224ea8..61e07c000b 100644 --- a/pkg/utils/utils_test.go +++ b/pkg/utils/utils_test.go @@ -1535,43 +1535,3 @@ func TestAddIPToLBStatus(t *testing.T) { }) } } - -func TestGetDomainFromGABasePath(t *testing.T) { - testCases := []struct { - desc string - basePath string - want string - }{ - { - desc: "empty string", - }, - { - desc: "compute.googleapis.com path", - basePath: "https://www.compute.googleapis.com/compute/v1", - want: "https://www.compute.googleapis.com", - }, - { - desc: "arbitary path", - basePath: "mycompute.mydomain.com/mypath/compute/v1", - want: "mycompute.mydomain.com/mypath", - }, - { - desc: "arbitary path with trailing /", - basePath: "mycompute.mydomain.com/mypath/compute/v1/", - want: "mycompute.mydomain.com/mypath", - }, - { - desc: "arbitary path without /v1 -- should return same string", - basePath: "mycompute.mydomain.com/mypath/compute", - want: "mycompute.mydomain.com/mypath/compute", - }, - } - - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - if got := GetDomainFromGABasePath(tc.basePath); got != tc.want { - t.Errorf("GetDomainFromGABasePath(%s) = %s, want %s", tc.basePath, got, tc.want) - } - }) - } -}