Skip to content

Commit

Permalink
Merge pull request #751 from panslava/remove-client
Browse files Browse the repository at this point in the history
Remove unused client argument
  • Loading branch information
k8s-ci-robot authored Aug 7, 2024
2 parents 8b385de + 08d1998 commit 6dce34d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
42 changes: 1 addition & 41 deletions providers/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"context"
"fmt"
"io"
"net/http"
"runtime"
"strconv"
"strings"
Expand All @@ -45,7 +44,6 @@ import (

"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/informers"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -488,11 +486,7 @@ func CreateGCECloud(config *CloudConfig) (*Cloud, error) {
containerService.BasePath = config.ContainerAPIEndpoint
}

client, err := newOauthClient(config.TokenSource)
if err != nil {
return nil, err
}
tpuService, err := newTPUService(client)
tpuService, err := newTPUService()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -960,40 +954,6 @@ func findSubnetForRegion(subnetURLs []string, region string) string {
return ""
}

func newOauthClient(tokenSource oauth2.TokenSource) (*http.Client, error) {
if tokenSource == nil {
var err error
tokenSource, err = google.DefaultTokenSource(
context.Background(),
compute.CloudPlatformScope,
compute.ComputeScope)
klog.Infof("Using DefaultTokenSource %#v", tokenSource)
if err != nil {
return nil, err
}
} else {
klog.Infof("Using existing Token Source %#v", tokenSource)
}

backoff := wait.Backoff{
// These values will add up to about a minute. See #56293 for background.
Duration: time.Second,
Factor: 1.4,
Steps: 10,
}
if err := wait.ExponentialBackoff(backoff, func() (bool, error) {
if _, err := tokenSource.Token(); err != nil {
klog.Errorf("error fetching initial token: %v", err)
return false, nil
}
return true, nil
}); err != nil {
return nil, err
}

return oauth2.NewClient(context.Background(), tokenSource), nil
}

func (manager *gceServiceManager) getProjectsAPIEndpoint() string {
projectsAPIEndpoint := gceComputeAPIEndpoint + "projects/"
if manager.gce.service != nil {
Expand Down
3 changes: 1 addition & 2 deletions providers/gce/gce_tpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/http"
"time"

"google.golang.org/api/googleapi"
Expand All @@ -35,7 +34,7 @@ import (

// newTPUService returns a new tpuService using the client to communicate with
// the Cloud TPU APIs.
func newTPUService(client *http.Client) (*tpuService, error) {
func newTPUService() (*tpuService, error) {
s, err := tpuapi.NewService(context.Background())
if err != nil {
return nil, err
Expand Down

0 comments on commit 6dce34d

Please sign in to comment.