Skip to content

Commit

Permalink
Move from glog to klog
Browse files Browse the repository at this point in the history
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
  • Loading branch information
dims authored and k8s-publishing-bot committed Nov 9, 2018
1 parent b1c1d2e commit 74cd8bb
Show file tree
Hide file tree
Showing 38 changed files with 262 additions and 262 deletions.
174 changes: 85 additions & 89 deletions Godeps/Godeps.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions discovery/cached_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"sync"
"time"

"github.com/golang/glog"
"github.com/googleapis/gnostic/OpenAPIv2"
"k8s.io/klog"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -67,23 +67,23 @@ func (d *CachedDiscoveryClient) ServerResourcesForGroupVersion(groupVersion stri
if err == nil {
cachedResources := &metav1.APIResourceList{}
if err := runtime.DecodeInto(scheme.Codecs.UniversalDecoder(), cachedBytes, cachedResources); err == nil {
glog.V(10).Infof("returning cached discovery info from %v", filename)
klog.V(10).Infof("returning cached discovery info from %v", filename)
return cachedResources, nil
}
}

liveResources, err := d.delegate.ServerResourcesForGroupVersion(groupVersion)
if err != nil {
glog.V(3).Infof("skipped caching discovery info due to %v", err)
klog.V(3).Infof("skipped caching discovery info due to %v", err)
return liveResources, err
}
if liveResources == nil || len(liveResources.APIResources) == 0 {
glog.V(3).Infof("skipped caching discovery info, no resources found")
klog.V(3).Infof("skipped caching discovery info, no resources found")
return liveResources, err
}

if err := d.writeCachedFile(filename, liveResources); err != nil {
glog.V(1).Infof("failed to write cache to %v due to %v", filename, err)
klog.V(1).Infof("failed to write cache to %v due to %v", filename, err)
}

return liveResources, nil
Expand All @@ -103,23 +103,23 @@ func (d *CachedDiscoveryClient) ServerGroups() (*metav1.APIGroupList, error) {
if err == nil {
cachedGroups := &metav1.APIGroupList{}
if err := runtime.DecodeInto(scheme.Codecs.UniversalDecoder(), cachedBytes, cachedGroups); err == nil {
glog.V(10).Infof("returning cached discovery info from %v", filename)
klog.V(10).Infof("returning cached discovery info from %v", filename)
return cachedGroups, nil
}
}

liveGroups, err := d.delegate.ServerGroups()
if err != nil {
glog.V(3).Infof("skipped caching discovery info due to %v", err)
klog.V(3).Infof("skipped caching discovery info due to %v", err)
return liveGroups, err
}
if liveGroups == nil || len(liveGroups.Groups) == 0 {
glog.V(3).Infof("skipped caching discovery info, no groups found")
klog.V(3).Infof("skipped caching discovery info, no groups found")
return liveGroups, err
}

if err := d.writeCachedFile(filename, liveGroups); err != nil {
glog.V(1).Infof("failed to write cache to %v due to %v", filename, err)
klog.V(1).Infof("failed to write cache to %v due to %v", filename, err)
}

return liveGroups, nil
Expand Down
4 changes: 2 additions & 2 deletions discovery/round_tripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"net/http"
"path/filepath"

"github.com/golang/glog"
"github.com/gregjones/httpcache"
"github.com/gregjones/httpcache/diskcache"
"github.com/peterbourgon/diskv"
"k8s.io/klog"
)

type cacheRoundTripper struct {
Expand Down Expand Up @@ -55,7 +55,7 @@ func (rt *cacheRoundTripper) CancelRequest(req *http.Request) {
if cr, ok := rt.rt.Transport.(canceler); ok {
cr.CancelRequest(req)
} else {
glog.Errorf("CancelRequest not implemented by %T", rt.rt.Transport)
klog.Errorf("CancelRequest not implemented by %T", rt.rt.Transport)
}
}

Expand Down
16 changes: 8 additions & 8 deletions examples/workqueue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"time"

"github.com/golang/glog"
"k8s.io/klog"

"k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -72,7 +72,7 @@ func (c *Controller) processNextItem() bool {
func (c *Controller) syncToStdout(key string) error {
obj, exists, err := c.indexer.GetByKey(key)
if err != nil {
glog.Errorf("Fetching object with key %s from store failed with %v", key, err)
klog.Errorf("Fetching object with key %s from store failed with %v", key, err)
return err
}

Expand All @@ -99,7 +99,7 @@ func (c *Controller) handleErr(err error, key interface{}) {

// This controller retries 5 times if something goes wrong. After that, it stops trying.
if c.queue.NumRequeues(key) < 5 {
glog.Infof("Error syncing pod %v: %v", key, err)
klog.Infof("Error syncing pod %v: %v", key, err)

// Re-enqueue the key rate limited. Based on the rate limiter on the
// queue and the re-enqueue history, the key will be processed later again.
Expand All @@ -110,15 +110,15 @@ func (c *Controller) handleErr(err error, key interface{}) {
c.queue.Forget(key)
// Report to an external entity that, even after several retries, we could not successfully process this key
runtime.HandleError(err)
glog.Infof("Dropping pod %q out of the queue: %v", key, err)
klog.Infof("Dropping pod %q out of the queue: %v", key, err)
}

func (c *Controller) Run(threadiness int, stopCh chan struct{}) {
defer runtime.HandleCrash()

// Let the workers stop when we are done
defer c.queue.ShutDown()
glog.Info("Starting Pod controller")
klog.Info("Starting Pod controller")

go c.informer.Run(stopCh)

Expand All @@ -133,7 +133,7 @@ func (c *Controller) Run(threadiness int, stopCh chan struct{}) {
}

<-stopCh
glog.Info("Stopping Pod controller")
klog.Info("Stopping Pod controller")
}

func (c *Controller) runWorker() {
Expand All @@ -152,13 +152,13 @@ func main() {
// creates the connection
config, err := clientcmd.BuildConfigFromFlags(master, kubeconfig)
if err != nil {
glog.Fatal(err)
klog.Fatal(err)
}

// creates the clientset
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
glog.Fatal(err)
klog.Fatal(err)
}

// create the pod watcher
Expand Down
4 changes: 2 additions & 2 deletions listers/policy/v1beta1/poddisruptionbudget_expansion.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package v1beta1
import (
"fmt"

"github.com/golang/glog"
"k8s.io/api/core/v1"
policy "k8s.io/api/policy/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/klog"
)

// PodDisruptionBudgetListerExpansion allows custom methods to be added to
Expand Down Expand Up @@ -54,7 +54,7 @@ func (s *podDisruptionBudgetLister) GetPodPodDisruptionBudgets(pod *v1.Pod) ([]*
pdb := list[i]
selector, err = metav1.LabelSelectorAsSelector(pdb.Spec.Selector)
if err != nil {
glog.Warningf("invalid selector: %v", err)
klog.Warningf("invalid selector: %v", err)
// TODO(mml): add an event to the PDB
continue
}
Expand Down
6 changes: 3 additions & 3 deletions plugin/pkg/client/auth/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/golang/glog"
"k8s.io/klog"

"k8s.io/apimachinery/pkg/util/net"
restclient "k8s.io/client-go/rest"
Expand All @@ -50,7 +50,7 @@ const (

func init() {
if err := restclient.RegisterAuthProviderPlugin("azure", newAzureAuthProvider); err != nil {
glog.Fatalf("Failed to register azure auth plugin: %v", err)
klog.Fatalf("Failed to register azure auth plugin: %v", err)
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ func (r *azureRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

token, err := r.tokenSource.Token()
if err != nil {
glog.Errorf("Failed to acquire a token: %v", err)
klog.Errorf("Failed to acquire a token: %v", err)
return nil, fmt.Errorf("acquiring a token for authorization header: %v", err)
}

Expand Down
4 changes: 2 additions & 2 deletions plugin/pkg/client/auth/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"sync"
"time"

"github.com/golang/glog"
"golang.org/x/crypto/ssh/terminal"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -44,6 +43,7 @@ import (
"k8s.io/client-go/tools/clientcmd/api"
"k8s.io/client-go/transport"
"k8s.io/client-go/util/connrotation"
"k8s.io/klog"
)

const execInfoEnv = "KUBERNETES_EXEC_INFO"
Expand Down Expand Up @@ -228,7 +228,7 @@ func (r *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
Code: int32(res.StatusCode),
}
if err := r.a.maybeRefreshCreds(creds, resp); err != nil {
glog.Errorf("refreshing credentials: %v", err)
klog.Errorf("refreshing credentials: %v", err)
}
}
return res, nil
Expand Down
10 changes: 5 additions & 5 deletions plugin/pkg/client/auth/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ import (
"sync"
"time"

"github.com/golang/glog"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/yaml"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/util/jsonpath"
"k8s.io/klog"
)

func init() {
if err := restclient.RegisterAuthProviderPlugin("gcp", newGCPAuthProvider); err != nil {
glog.Fatalf("Failed to register gcp auth plugin: %v", err)
klog.Fatalf("Failed to register gcp auth plugin: %v", err)
}
}

Expand Down Expand Up @@ -223,7 +223,7 @@ func (t *cachedTokenSource) Token() (*oauth2.Token, error) {
cache := t.update(tok)
if t.persister != nil {
if err := t.persister.Persist(cache); err != nil {
glog.V(4).Infof("Failed to persist token: %v", err)
klog.V(4).Infof("Failed to persist token: %v", err)
}
}
return tok, nil
Expand Down Expand Up @@ -329,7 +329,7 @@ func (c *commandTokenSource) parseTokenCmdOutput(output []byte) (*oauth2.Token,
}
var expiry time.Time
if t, err := time.Parse(c.timeFmt, expiryStr); err != nil {
glog.V(4).Infof("Failed to parse token expiry from %s (fmt=%s): %v", expiryStr, c.timeFmt, err)
klog.V(4).Infof("Failed to parse token expiry from %s (fmt=%s): %v", expiryStr, c.timeFmt, err)
} else {
expiry = t
}
Expand Down Expand Up @@ -373,7 +373,7 @@ func (t *conditionalTransport) RoundTrip(req *http.Request) (*http.Response, err
}

if res.StatusCode == 401 {
glog.V(4).Infof("The credentials that were supplied are invalid for the target cluster")
klog.V(4).Infof("The credentials that were supplied are invalid for the target cluster")
t.persister.Persist(t.resetCache)
}

Expand Down
6 changes: 3 additions & 3 deletions plugin/pkg/client/auth/oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
"sync"
"time"

"github.com/golang/glog"
"golang.org/x/oauth2"
"k8s.io/apimachinery/pkg/util/net"
restclient "k8s.io/client-go/rest"
"k8s.io/klog"
)

const (
Expand All @@ -49,7 +49,7 @@ const (

func init() {
if err := restclient.RegisterAuthProviderPlugin("oidc", newOIDCAuthProvider); err != nil {
glog.Fatalf("Failed to register oidc auth plugin: %v", err)
klog.Fatalf("Failed to register oidc auth plugin: %v", err)
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ func newOIDCAuthProvider(_ string, cfg map[string]string, persister restclient.A
}

if len(cfg[cfgExtraScopes]) > 0 {
glog.V(2).Infof("%s auth provider field depricated, refresh request don't send scopes",
klog.V(2).Infof("%s auth provider field depricated, refresh request don't send scopes",
cfgExtraScopes)
}

Expand Down
10 changes: 5 additions & 5 deletions plugin/pkg/client/auth/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import (
"sync"
"time"

"github.com/golang/glog"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack"
"k8s.io/klog"

"k8s.io/apimachinery/pkg/util/net"
restclient "k8s.io/client-go/rest"
)

func init() {
if err := restclient.RegisterAuthProviderPlugin("openstack", newOpenstackAuthProvider); err != nil {
glog.Fatalf("Failed to register openstack auth plugin: %s", err)
klog.Fatalf("Failed to register openstack auth plugin: %s", err)
}
}

Expand Down Expand Up @@ -62,7 +62,7 @@ func (t *tokenGetter) Token() (string, error) {
var err error
if t.authOpt == nil {
// reads the config from the environment
glog.V(4).Info("reading openstack config from the environment variables")
klog.V(4).Info("reading openstack config from the environment variables")
options, err = openstack.AuthOptionsFromEnv()
if err != nil {
return "", fmt.Errorf("failed to read openstack env vars: %s", err)
Expand Down Expand Up @@ -126,7 +126,7 @@ func (t *tokenRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
if err == nil {
req.Header.Set("Authorization", "Bearer "+token)
} else {
glog.V(4).Infof("failed to get token: %s", err)
klog.V(4).Infof("failed to get token: %s", err)
}

return t.RoundTripper.RoundTrip(req)
Expand All @@ -140,7 +140,7 @@ func newOpenstackAuthProvider(_ string, config map[string]string, persister rest
var ttlDuration time.Duration
var err error

glog.Warningf("WARNING: in-tree openstack auth plugin is now deprecated. please use the \"client-keystone-auth\" kubectl/client-go credential plugin instead")
klog.Warningf("WARNING: in-tree openstack auth plugin is now deprecated. please use the \"client-keystone-auth\" kubectl/client-go credential plugin instead")
ttl, found := config["ttl"]
if !found {
ttlDuration = DefaultTTLDuration
Expand Down
4 changes: 2 additions & 2 deletions rest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import (
"strings"
"time"

"github.com/golang/glog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/pkg/version"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
certutil "k8s.io/client-go/util/cert"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/klog"
)

const (
Expand Down Expand Up @@ -331,7 +331,7 @@ func InClusterConfig() (*Config, error) {
tlsClientConfig := TLSClientConfig{}

if _, err := certutil.NewPool(rootCAFile); err != nil {
glog.Errorf("Expected to load root CA config from %s, but got err: %v", rootCAFile, err)
klog.Errorf("Expected to load root CA config from %s, but got err: %v", rootCAFile, err)
} else {
tlsClientConfig.CAFile = rootCAFile
}
Expand Down
4 changes: 2 additions & 2 deletions rest/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"net/http"
"sync"

"github.com/golang/glog"
"k8s.io/klog"

clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)
Expand Down Expand Up @@ -57,7 +57,7 @@ func RegisterAuthProviderPlugin(name string, plugin Factory) error {
if _, found := plugins[name]; found {
return fmt.Errorf("Auth Provider Plugin %q was registered twice", name)
}
glog.V(4).Infof("Registered Auth Provider Plugin %q", name)
klog.V(4).Infof("Registered Auth Provider Plugin %q", name)
plugins[name] = plugin
return nil
}
Expand Down
Loading

0 comments on commit 74cd8bb

Please sign in to comment.