diff --git a/pkg/util/cachepersister.go b/pkg/util/cachepersister.go index 63a5c0f42..e72c28f16 100644 --- a/pkg/util/cachepersister.go +++ b/pkg/util/cachepersister.go @@ -19,7 +19,7 @@ package util import ( "errors" - "github.com/golang/glog" + "k8s.io/klog" ) const ( @@ -41,13 +41,13 @@ type CachePersister interface { // NewCachePersister returns CachePersister based on store func NewCachePersister(metadataStore, driverName string) (CachePersister, error) { if metadataStore == "k8s_configmap" { - glog.Infof("cache-perister: using kubernetes configmap as metadata cache persister") + klog.Infof("cache-perister: using kubernetes configmap as metadata cache persister") k8scm := &K8sCMCache{} k8scm.Client = NewK8sClient() k8scm.Namespace = GetK8sNamespace() return k8scm, nil } else if metadataStore == "node" { - glog.Infof("cache-persister: using node as metadata cache persister") + klog.Infof("cache-persister: using node as metadata cache persister") nc := &NodeCache{} nc.BasePath = PluginFolder + "/" + driverName return nc, nil diff --git a/pkg/util/k8scmcache.go b/pkg/util/k8scmcache.go index bdcb75d9d..570857f89 100644 --- a/pkg/util/k8scmcache.go +++ b/pkg/util/k8scmcache.go @@ -22,8 +22,8 @@ import ( "os" "regexp" - "github.com/golang/glog" "github.com/pkg/errors" + "k8s.io/klog" "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" @@ -66,19 +66,19 @@ func NewK8sClient() *k8s.Clientset { if cPath != "" { cfg, err = clientcmd.BuildConfigFromFlags("", cPath) if err != nil { - glog.Errorf("Failed to get cluster config with error: %v\n", err) + klog.Errorf("Failed to get cluster config with error: %v\n", err) os.Exit(1) } } else { cfg, err = rest.InClusterConfig() if err != nil { - glog.Errorf("Failed to get cluster config with error: %v\n", err) + klog.Errorf("Failed to get cluster config with error: %v\n", err) os.Exit(1) } } client, err := k8s.NewForConfig(cfg) if err != nil { - glog.Errorf("Failed to create client with error: %v\n", err) + klog.Errorf("Failed to create client with error: %v\n", err) os.Exit(1) } return client @@ -123,7 +123,7 @@ func (k8scm *K8sCMCache) ForAll(pattern string, destObj interface{}, f ForAllFun func (k8scm *K8sCMCache) Create(identifier string, data interface{}) error { cm, err := k8scm.getMetadataCM(identifier) if cm != nil && err == nil { - glog.V(4).Infof("k8s-cm-cache: configmap already exists, skipping configmap creation") + klog.V(4).Infof("k8s-cm-cache: configmap already exists, skipping configmap creation") return nil } dataJSON, err := json.Marshal(data) @@ -145,13 +145,13 @@ func (k8scm *K8sCMCache) Create(identifier string, data interface{}) error { _, err = k8scm.Client.CoreV1().ConfigMaps(k8scm.Namespace).Create(cm) if err != nil { if apierrs.IsAlreadyExists(err) { - glog.V(4).Infof("k8s-cm-cache: configmap already exists") + klog.V(4).Infof("k8s-cm-cache: configmap already exists") return nil } return errors.Wrapf(err, "k8s-cm-cache: couldn't persist %s metadata as configmap", identifier) } - glog.V(4).Infof("k8s-cm-cache: configmap %s successfully created\n", identifier) + klog.V(4).Infof("k8s-cm-cache: configmap %s successfully created\n", identifier) return nil } @@ -174,6 +174,6 @@ func (k8scm *K8sCMCache) Delete(identifier string) error { if err != nil { return errors.Wrapf(err, "k8s-cm-cache: couldn't delete metadata configmap %s", identifier) } - glog.V(4).Infof("k8s-cm-cache: successfully deleted metadata configmap %s", identifier) + klog.V(4).Infof("k8s-cm-cache: successfully deleted metadata configmap %s", identifier) return nil } diff --git a/pkg/util/nodecache.go b/pkg/util/nodecache.go index 50a72c040..947375b00 100644 --- a/pkg/util/nodecache.go +++ b/pkg/util/nodecache.go @@ -25,8 +25,8 @@ import ( "regexp" "strings" - "github.com/golang/glog" "github.com/pkg/errors" + "k8s.io/klog" ) // NodeCache to store metadata @@ -87,7 +87,7 @@ func decodeObj(filepath, pattern string, file os.FileInfo, destObj interface{}) // #nosec fp, err := os.Open(path.Join(filepath, file.Name())) if err != nil { - glog.Infof("node-cache: open file: %s err %v", file.Name(), err) + klog.Infof("node-cache: open file: %s err %v", file.Name(), err) return errDec } decoder := json.NewDecoder(fp) @@ -112,7 +112,7 @@ func (nc *NodeCache) Create(identifier string, data interface{}) error { defer func() { if err = fp.Close(); err != nil { - glog.Warningf("failed to close file:%s %v", fp.Name(), err) + klog.Warningf("failed to close file:%s %v", fp.Name(), err) } }() @@ -120,7 +120,7 @@ func (nc *NodeCache) Create(identifier string, data interface{}) error { if err = encoder.Encode(data); err != nil { return errors.Wrapf(err, "node-cache: failed to encode metadata for file: %s\n", file) } - glog.V(4).Infof("node-cache: successfully saved metadata into file: %s\n", file) + klog.V(4).Infof("node-cache: successfully saved metadata into file: %s\n", file) return nil } @@ -135,7 +135,7 @@ func (nc *NodeCache) Get(identifier string, data interface{}) error { defer func() { if err = fp.Close(); err != nil { - glog.Warningf("failed to close file:%s %v", fp.Name(), err) + klog.Warningf("failed to close file:%s %v", fp.Name(), err) } }() @@ -156,6 +156,6 @@ func (nc *NodeCache) Delete(identifier string) error { return errors.Wrapf(err, "node-cache: error removing file %s", file) } } - glog.V(4).Infof("node-cache: successfully deleted metadata storage file at: %+v\n", file) + klog.V(4).Infof("node-cache: successfully deleted metadata storage file at: %+v\n", file) return nil }