Skip to content

Commit

Permalink
Merge pull request #2060 from spencerhance/revert-2038-set-api-domain
Browse files Browse the repository at this point in the history
Revert "Set the k8s-cloud-provider API domain"
  • Loading branch information
k8s-ci-robot authored Apr 3, 2023
2 parents d007e55 + 76d861d commit f153932
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 59 deletions.
10 changes: 0 additions & 10 deletions cmd/glbc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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 <URL>/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,
Expand Down
9 changes: 0 additions & 9 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path>/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
}
40 changes: 0 additions & 40 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
}

0 comments on commit f153932

Please sign in to comment.