@@ -18,7 +18,6 @@ package devicemanager
18
18
19
19
import (
20
20
"context"
21
- "log"
22
21
"net"
23
22
"os"
24
23
"path"
@@ -27,6 +26,7 @@ import (
27
26
28
27
"google.golang.org/grpc"
29
28
29
+ "k8s.io/klog"
30
30
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
31
31
watcherapi "k8s.io/kubelet/pkg/apis/pluginregistration/v1"
32
32
)
@@ -108,7 +108,7 @@ func (m *Stub) Start() error {
108
108
return err
109
109
}
110
110
conn .Close ()
111
- log . Println ("Starting to serve on" , m .socket )
111
+ klog . Infof ("Starting to serve on %v " , m .socket )
112
112
113
113
return nil
114
114
}
@@ -130,7 +130,7 @@ func (m *Stub) Stop() error {
130
130
131
131
// GetInfo is the RPC which return pluginInfo
132
132
func (m * Stub ) GetInfo (ctx context.Context , req * watcherapi.InfoRequest ) (* watcherapi.PluginInfo , error ) {
133
- log . Println ("GetInfo" )
133
+ klog . Info ("GetInfo" )
134
134
return & watcherapi.PluginInfo {
135
135
Type : watcherapi .DevicePlugin ,
136
136
Name : m .resourceName ,
@@ -144,7 +144,7 @@ func (m *Stub) NotifyRegistrationStatus(ctx context.Context, status *watcherapi.
144
144
m .registrationStatus <- * status
145
145
}
146
146
if ! status .PluginRegistered {
147
- log . Println ("Registration failed: " , status .Error )
147
+ klog . Infof ("Registration failed: %v " , status .Error )
148
148
}
149
149
return & watcherapi.RegistrationStatusResponse {}, nil
150
150
}
@@ -153,11 +153,11 @@ func (m *Stub) NotifyRegistrationStatus(ctx context.Context, status *watcherapi.
153
153
func (m * Stub ) Register (kubeletEndpoint , resourceName string , pluginSockDir string ) error {
154
154
if pluginSockDir != "" {
155
155
if _ , err := os .Stat (pluginSockDir + "DEPRECATION" ); err == nil {
156
- log . Println ("Deprecation file found. Skip registration." )
156
+ klog . Info ("Deprecation file found. Skip registration." )
157
157
return nil
158
158
}
159
159
}
160
- log . Println ("Deprecation file not found. Invoke registration" )
160
+ klog . Info ("Deprecation file not found. Invoke registration" )
161
161
ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
162
162
defer cancel ()
163
163
@@ -191,13 +191,13 @@ func (m *Stub) GetDevicePluginOptions(ctx context.Context, e *pluginapi.Empty) (
191
191
192
192
// PreStartContainer resets the devices received
193
193
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 )
195
195
return & pluginapi.PreStartContainerResponse {}, nil
196
196
}
197
197
198
198
// ListAndWatch lists devices and update that list according to the Update call
199
199
func (m * Stub ) ListAndWatch (e * pluginapi.Empty , s pluginapi.DevicePlugin_ListAndWatchServer ) error {
200
- log . Println ("ListAndWatch" )
200
+ klog . Info ("ListAndWatch" )
201
201
202
202
s .Send (& pluginapi.ListAndWatchResponse {Devices : m .devs })
203
203
@@ -218,7 +218,7 @@ func (m *Stub) Update(devs []*pluginapi.Device) {
218
218
219
219
// Allocate does a mock allocation
220
220
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 )
222
222
223
223
devs := make (map [string ]pluginapi.Device )
224
224
0 commit comments