Skip to content

Commit 0d0c400

Browse files
authored
Merge pull request kubernetes#91004 from cwdsuzhou/May/relplace_log
Use klog to replace log to keep them in consistence
2 parents 9188bbb + 5ed8fb6 commit 0d0c400

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pkg/kubelet/cm/devicemanager/device_plugin_stub.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package devicemanager
1818

1919
import (
2020
"context"
21-
"log"
2221
"net"
2322
"os"
2423
"path"
@@ -27,6 +26,7 @@ import (
2726

2827
"google.golang.org/grpc"
2928

29+
"k8s.io/klog"
3030
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
3131
watcherapi "k8s.io/kubelet/pkg/apis/pluginregistration/v1"
3232
)
@@ -108,7 +108,7 @@ func (m *Stub) Start() error {
108108
return err
109109
}
110110
conn.Close()
111-
log.Println("Starting to serve on", m.socket)
111+
klog.Infof("Starting to serve on %v", m.socket)
112112

113113
return nil
114114
}
@@ -130,7 +130,7 @@ func (m *Stub) Stop() error {
130130

131131
// GetInfo is the RPC which return pluginInfo
132132
func (m *Stub) GetInfo(ctx context.Context, req *watcherapi.InfoRequest) (*watcherapi.PluginInfo, error) {
133-
log.Println("GetInfo")
133+
klog.Info("GetInfo")
134134
return &watcherapi.PluginInfo{
135135
Type: watcherapi.DevicePlugin,
136136
Name: m.resourceName,
@@ -144,7 +144,7 @@ func (m *Stub) NotifyRegistrationStatus(ctx context.Context, status *watcherapi.
144144
m.registrationStatus <- *status
145145
}
146146
if !status.PluginRegistered {
147-
log.Println("Registration failed: ", status.Error)
147+
klog.Infof("Registration failed: %v", status.Error)
148148
}
149149
return &watcherapi.RegistrationStatusResponse{}, nil
150150
}
@@ -153,11 +153,11 @@ func (m *Stub) NotifyRegistrationStatus(ctx context.Context, status *watcherapi.
153153
func (m *Stub) Register(kubeletEndpoint, resourceName string, pluginSockDir string) error {
154154
if pluginSockDir != "" {
155155
if _, err := os.Stat(pluginSockDir + "DEPRECATION"); err == nil {
156-
log.Println("Deprecation file found. Skip registration.")
156+
klog.Info("Deprecation file found. Skip registration.")
157157
return nil
158158
}
159159
}
160-
log.Println("Deprecation file not found. Invoke registration")
160+
klog.Info("Deprecation file not found. Invoke registration")
161161
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
162162
defer cancel()
163163

@@ -191,13 +191,13 @@ func (m *Stub) GetDevicePluginOptions(ctx context.Context, e *pluginapi.Empty) (
191191

192192
// PreStartContainer resets the devices received
193193
func (m *Stub) PreStartContainer(ctx context.Context, r *pluginapi.PreStartContainerRequest) (*pluginapi.PreStartContainerResponse, error) {
194-
log.Printf("PreStartContainer, %+v", r)
194+
klog.Infof("PreStartContainer, %+v", r)
195195
return &pluginapi.PreStartContainerResponse{}, nil
196196
}
197197

198198
// ListAndWatch lists devices and update that list according to the Update call
199199
func (m *Stub) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePlugin_ListAndWatchServer) error {
200-
log.Println("ListAndWatch")
200+
klog.Info("ListAndWatch")
201201

202202
s.Send(&pluginapi.ListAndWatchResponse{Devices: m.devs})
203203

@@ -218,7 +218,7 @@ func (m *Stub) Update(devs []*pluginapi.Device) {
218218

219219
// Allocate does a mock allocation
220220
func (m *Stub) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error) {
221-
log.Printf("Allocate, %+v", r)
221+
klog.Infof("Allocate, %+v", r)
222222

223223
devs := make(map[string]pluginapi.Device)
224224

0 commit comments

Comments
 (0)