mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
Move from glog to klog
- 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
This commit is contained in:
@@ -45,16 +45,16 @@ go_library(
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:darwin": [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/golang.org/x/sys/unix:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:freebsd": [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/golang.org/x/sys/unix:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/golang.org/x/sys/unix:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:windows": [
|
||||
"//vendor/github.com/Microsoft/go-winio:go_default_library",
|
||||
|
||||
@@ -16,10 +16,10 @@ go_library(
|
||||
"//pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta2:go_default_library",
|
||||
"//pkg/util/filesystem:go_default_library",
|
||||
"//vendor/github.com/fsnotify/fsnotify:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/pkg/errors:go_default_library",
|
||||
"//vendor/golang.org/x/net/context:go_default_library",
|
||||
"//vendor/google.golang.org/grpc:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -30,6 +30,7 @@ go_test(
|
||||
deps = [
|
||||
"//pkg/kubelet/apis/pluginregistration/v1alpha1:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/require:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/klog"
|
||||
|
||||
v1beta1 "k8s.io/kubernetes/pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta1"
|
||||
v1beta2 "k8s.io/kubernetes/pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta2"
|
||||
@@ -117,7 +117,7 @@ func (p *exampleHandler) EventChan(pluginName string) chan examplePluginEvent {
|
||||
}
|
||||
|
||||
func (p *exampleHandler) SendEvent(pluginName string, event examplePluginEvent) {
|
||||
glog.V(2).Infof("Sending %v for plugin %s over chan %v", event, pluginName, p.eventChans[pluginName])
|
||||
klog.V(2).Infof("Sending %v for plugin %s over chan %v", event, pluginName, p.eventChans[pluginName])
|
||||
p.eventChans[pluginName] <- event
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"k8s.io/klog"
|
||||
|
||||
registerapi "k8s.io/kubernetes/pkg/kubelet/apis/pluginregistration/v1alpha1"
|
||||
v1beta1 "k8s.io/kubernetes/pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta1"
|
||||
@@ -49,7 +49,7 @@ type pluginServiceV1Beta1 struct {
|
||||
}
|
||||
|
||||
func (s *pluginServiceV1Beta1) GetExampleInfo(ctx context.Context, rqt *v1beta1.ExampleRequest) (*v1beta1.ExampleResponse, error) {
|
||||
glog.Infof("GetExampleInfo v1beta1field: %s", rqt.V1Beta1Field)
|
||||
klog.Infof("GetExampleInfo v1beta1field: %s", rqt.V1Beta1Field)
|
||||
return &v1beta1.ExampleResponse{}, nil
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ type pluginServiceV1Beta2 struct {
|
||||
}
|
||||
|
||||
func (s *pluginServiceV1Beta2) GetExampleInfo(ctx context.Context, rqt *v1beta2.ExampleRequest) (*v1beta2.ExampleResponse, error) {
|
||||
glog.Infof("GetExampleInfo v1beta2_field: %s", rqt.V1Beta2Field)
|
||||
klog.Infof("GetExampleInfo v1beta2_field: %s", rqt.V1Beta2Field)
|
||||
return &v1beta2.ExampleResponse{}, nil
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func (e *examplePlugin) GetInfo(ctx context.Context, req *registerapi.InfoReques
|
||||
}
|
||||
|
||||
func (e *examplePlugin) NotifyRegistrationStatus(ctx context.Context, status *registerapi.RegistrationStatus) (*registerapi.RegistrationStatusResponse, error) {
|
||||
glog.Errorf("Registration is: %v\n", status)
|
||||
klog.Errorf("Registration is: %v\n", status)
|
||||
|
||||
if e.registrationStatus != nil {
|
||||
e.registrationStatus <- *status
|
||||
@@ -108,13 +108,13 @@ func (e *examplePlugin) NotifyRegistrationStatus(ctx context.Context, status *re
|
||||
|
||||
// Serve starts a pluginwatcher server and one or more of the plugin services
|
||||
func (e *examplePlugin) Serve(services ...string) error {
|
||||
glog.Infof("starting example server at: %s\n", e.endpoint)
|
||||
klog.Infof("starting example server at: %s\n", e.endpoint)
|
||||
lis, err := net.Listen("unix", e.endpoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
glog.Infof("example server started at: %s\n", e.endpoint)
|
||||
klog.Infof("example server started at: %s\n", e.endpoint)
|
||||
e.grpcServer = grpc.NewServer()
|
||||
|
||||
// Registers kubelet plugin watcher api.
|
||||
@@ -141,7 +141,7 @@ func (e *examplePlugin) Serve(services ...string) error {
|
||||
defer e.wg.Done()
|
||||
// Blocking call to accept incoming connections.
|
||||
if err := e.grpcServer.Serve(lis); err != nil {
|
||||
glog.Errorf("example server stopped serving: %v", err)
|
||||
klog.Errorf("example server stopped serving: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -149,7 +149,7 @@ func (e *examplePlugin) Serve(services ...string) error {
|
||||
}
|
||||
|
||||
func (e *examplePlugin) Stop() error {
|
||||
glog.Infof("Stopping example server at: %s\n", e.endpoint)
|
||||
klog.Infof("Stopping example server at: %s\n", e.endpoint)
|
||||
|
||||
e.grpcServer.Stop()
|
||||
c := make(chan struct{})
|
||||
|
||||
@@ -25,10 +25,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"k8s.io/klog"
|
||||
|
||||
registerapi "k8s.io/kubernetes/pkg/kubelet/apis/pluginregistration/v1alpha1"
|
||||
utilfs "k8s.io/kubernetes/pkg/util/filesystem"
|
||||
@@ -82,7 +82,7 @@ func (w *Watcher) getHandler(pluginType string) (PluginHandler, bool) {
|
||||
|
||||
// Start watches for the creation of plugin sockets at the path
|
||||
func (w *Watcher) Start() error {
|
||||
glog.V(2).Infof("Plugin Watcher Start at %s", w.path)
|
||||
klog.V(2).Infof("Plugin Watcher Start at %s", w.path)
|
||||
w.stopCh = make(chan interface{})
|
||||
|
||||
// Creating the directory to be watched if it doesn't exist yet,
|
||||
@@ -112,12 +112,12 @@ func (w *Watcher) Start() error {
|
||||
if event.Op&fsnotify.Create == fsnotify.Create {
|
||||
err := w.handleCreateEvent(event)
|
||||
if err != nil {
|
||||
glog.Errorf("error %v when handling create event: %s", err, event)
|
||||
klog.Errorf("error %v when handling create event: %s", err, event)
|
||||
}
|
||||
} else if event.Op&fsnotify.Remove == fsnotify.Remove {
|
||||
err := w.handleDeleteEvent(event)
|
||||
if err != nil {
|
||||
glog.Errorf("error %v when handling delete event: %s", err, event)
|
||||
klog.Errorf("error %v when handling delete event: %s", err, event)
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -125,7 +125,7 @@ func (w *Watcher) Start() error {
|
||||
continue
|
||||
case err := <-fsWatcher.Errors:
|
||||
if err != nil {
|
||||
glog.Errorf("fsWatcher received error: %v", err)
|
||||
klog.Errorf("fsWatcher received error: %v", err)
|
||||
}
|
||||
continue
|
||||
case <-w.stopCh:
|
||||
@@ -165,7 +165,7 @@ func (w *Watcher) Stop() error {
|
||||
}
|
||||
|
||||
func (w *Watcher) init() error {
|
||||
glog.V(4).Infof("Ensuring Plugin directory at %s ", w.path)
|
||||
klog.V(4).Infof("Ensuring Plugin directory at %s ", w.path)
|
||||
|
||||
if err := w.fs.MkdirAll(w.path, 0755); err != nil {
|
||||
return fmt.Errorf("error (re-)creating root %s: %v", w.path, err)
|
||||
@@ -203,7 +203,7 @@ func (w *Watcher) traversePluginDir(dir string) error {
|
||||
}
|
||||
}()
|
||||
default:
|
||||
glog.V(5).Infof("Ignoring file %s with mode %v", path, mode)
|
||||
klog.V(5).Infof("Ignoring file %s with mode %v", path, mode)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -212,7 +212,7 @@ func (w *Watcher) traversePluginDir(dir string) error {
|
||||
|
||||
// Handle filesystem notify event.
|
||||
func (w *Watcher) handleCreateEvent(event fsnotify.Event) error {
|
||||
glog.V(6).Infof("Handling create event: %v", event)
|
||||
klog.V(6).Infof("Handling create event: %v", event)
|
||||
|
||||
fi, err := os.Stat(event.Name)
|
||||
if err != nil {
|
||||
@@ -220,7 +220,7 @@ func (w *Watcher) handleCreateEvent(event fsnotify.Event) error {
|
||||
}
|
||||
|
||||
if strings.HasPrefix(fi.Name(), ".") {
|
||||
glog.Errorf("Ignoring file: %s", fi.Name())
|
||||
klog.Errorf("Ignoring file: %s", fi.Name())
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ func (w *Watcher) handlePluginRegistration(socketPath string) error {
|
||||
}
|
||||
|
||||
func (w *Watcher) handleDeleteEvent(event fsnotify.Event) error {
|
||||
glog.V(6).Infof("Handling delete event: %v", event)
|
||||
klog.V(6).Infof("Handling delete event: %v", event)
|
||||
|
||||
plugin, ok := w.getPlugin(event.Name)
|
||||
if !ok {
|
||||
@@ -304,7 +304,7 @@ func (w *Watcher) handleDeleteEvent(event fsnotify.Event) error {
|
||||
// When ReRegistering, the new plugin will have removed the current mapping (map[socketPath] = plugin) and replaced
|
||||
// it with it's own socketPath.
|
||||
if _, ok = w.getPlugin(event.Name); !ok {
|
||||
glog.V(2).Infof("A newer plugin watcher has been registered for plugin %v, dropping DeRegister call", plugin)
|
||||
klog.V(2).Infof("A newer plugin watcher has been registered for plugin %v, dropping DeRegister call", plugin)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ func (w *Watcher) handleDeleteEvent(event fsnotify.Event) error {
|
||||
return fmt.Errorf("could not find handler %s for plugin %s at path %s", plugin.pluginType, plugin.pluginName, event.Name)
|
||||
}
|
||||
|
||||
glog.V(2).Infof("DeRegistering plugin %v at path %s", plugin, event.Name)
|
||||
klog.V(2).Infof("DeRegistering plugin %v at path %s", plugin, event.Name)
|
||||
w.deRegisterPlugin(event.Name, plugin.pluginType, plugin.pluginName)
|
||||
h.DeRegisterPlugin(plugin.pluginName)
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"k8s.io/klog"
|
||||
registerapi "k8s.io/kubernetes/pkg/kubelet/apis/pluginregistration/v1alpha1"
|
||||
)
|
||||
|
||||
@@ -39,6 +40,7 @@ var (
|
||||
func init() {
|
||||
var logLevel string
|
||||
|
||||
klog.InitFlags(flag.CommandLine)
|
||||
flag.Set("alsologtostderr", fmt.Sprintf("%t", true))
|
||||
flag.StringVar(&logLevel, "logLevel", "6", "test")
|
||||
flag.Lookup("v").Value.Set(logLevel)
|
||||
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"golang.org/x/sys/unix"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -73,7 +73,7 @@ func parseEndpointWithFallbackProtocol(endpoint string, fallbackProtocol string)
|
||||
fallbackEndpoint := fallbackProtocol + "://" + endpoint
|
||||
protocol, addr, err = parseEndpoint(fallbackEndpoint)
|
||||
if err == nil {
|
||||
glog.Warningf("Using %q as endpoint is deprecated, please consider using full url format %q.", endpoint, fallbackEndpoint)
|
||||
klog.Warningf("Using %q as endpoint is deprecated, please consider using full url format %q.", endpoint, fallbackEndpoint)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user