Skip to content

Commit e310755

Browse files
authored
Merge pull request #2091 from dims/move-from-glog-to-klog
Move from glog to klog
2 parents 13e3e83 + 4da6d80 commit e310755

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+496
-327
lines changed

Godeps/Godeps.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

accelerators/nvidia.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import (
2626

2727
info "github.com/google/cadvisor/info/v1"
2828

29-
"github.com/golang/glog"
3029
"github.com/mindprince/gonvml"
30+
"k8s.io/klog"
3131
)
3232

3333
type NvidiaManager struct {
@@ -50,7 +50,7 @@ const nvidiaVendorId = "0x10de"
5050
// Setup initializes NVML if nvidia devices are present on the node.
5151
func (nm *NvidiaManager) Setup() {
5252
if !detectDevices(nvidiaVendorId) {
53-
glog.V(4).Info("No NVIDIA devices found.")
53+
klog.V(4).Info("No NVIDIA devices found.")
5454
return
5555
}
5656

@@ -63,19 +63,19 @@ func (nm *NvidiaManager) Setup() {
6363
func detectDevices(vendorId string) bool {
6464
devices, err := ioutil.ReadDir(sysFsPCIDevicesPath)
6565
if err != nil {
66-
glog.Warningf("Error reading %q: %v", sysFsPCIDevicesPath, err)
66+
klog.Warningf("Error reading %q: %v", sysFsPCIDevicesPath, err)
6767
return false
6868
}
6969

7070
for _, device := range devices {
7171
vendorPath := filepath.Join(sysFsPCIDevicesPath, device.Name(), "vendor")
7272
content, err := ioutil.ReadFile(vendorPath)
7373
if err != nil {
74-
glog.V(4).Infof("Error while reading %q: %v", vendorPath, err)
74+
klog.V(4).Infof("Error while reading %q: %v", vendorPath, err)
7575
continue
7676
}
7777
if strings.EqualFold(strings.TrimSpace(string(content)), vendorId) {
78-
glog.V(3).Infof("Found device with vendorId %q", vendorId)
78+
klog.V(3).Infof("Found device with vendorId %q", vendorId)
7979
return true
8080
}
8181
}
@@ -88,26 +88,26 @@ var initializeNVML = func(nm *NvidiaManager) {
8888
if err := gonvml.Initialize(); err != nil {
8989
// This is under a logging level because otherwise we may cause
9090
// log spam if the drivers/nvml is not installed on the system.
91-
glog.V(4).Infof("Could not initialize NVML: %v", err)
91+
klog.V(4).Infof("Could not initialize NVML: %v", err)
9292
return
9393
}
9494
nm.nvmlInitialized = true
9595
numDevices, err := gonvml.DeviceCount()
9696
if err != nil {
97-
glog.Warningf("GPU metrics would not be available. Failed to get the number of nvidia devices: %v", err)
97+
klog.Warningf("GPU metrics would not be available. Failed to get the number of nvidia devices: %v", err)
9898
return
9999
}
100-
glog.V(1).Infof("NVML initialized. Number of nvidia devices: %v", numDevices)
100+
klog.V(1).Infof("NVML initialized. Number of nvidia devices: %v", numDevices)
101101
nm.nvidiaDevices = make(map[int]gonvml.Device, numDevices)
102102
for i := 0; i < int(numDevices); i++ {
103103
device, err := gonvml.DeviceHandleByIndex(uint(i))
104104
if err != nil {
105-
glog.Warningf("Failed to get nvidia device handle %d: %v", i, err)
105+
klog.Warningf("Failed to get nvidia device handle %d: %v", i, err)
106106
continue
107107
}
108108
minorNumber, err := device.MinorNumber()
109109
if err != nil {
110-
glog.Warningf("Failed to get nvidia device minor number: %v", err)
110+
klog.Warningf("Failed to get nvidia device minor number: %v", err)
111111
continue
112112
}
113113
nm.nvidiaDevices[int(minorNumber)] = device

api/handler.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
info "github.com/google/cadvisor/info/v1"
3434
"github.com/google/cadvisor/manager"
3535

36-
"github.com/golang/glog"
36+
"k8s.io/klog"
3737
)
3838

3939
const (
@@ -68,7 +68,7 @@ const (
6868
func handleRequest(supportedApiVersions map[string]ApiVersion, m manager.Manager, w http.ResponseWriter, r *http.Request) error {
6969
start := time.Now()
7070
defer func() {
71-
glog.V(4).Infof("Request took %s", time.Since(start))
71+
klog.V(4).Infof("Request took %s", time.Since(start))
7272
}()
7373

7474
request := r.URL.Path
@@ -157,7 +157,7 @@ func streamResults(eventChannel *events.EventChannel, w http.ResponseWriter, r *
157157
case ev := <-eventChannel.GetChannel():
158158
err := enc.Encode(ev)
159159
if err != nil {
160-
glog.Errorf("error encoding message %+v for result stream: %v", ev, err)
160+
klog.Errorf("error encoding message %+v for result stream: %v", ev, err)
161161
}
162162
flusher.Flush()
163163
}

api/versions.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/google/cadvisor/info/v2"
2525
"github.com/google/cadvisor/manager"
2626

27-
"github.com/golang/glog"
27+
"k8s.io/klog"
2828
)
2929

3030
const (
@@ -85,7 +85,7 @@ func (self *version1_0) SupportedRequestTypes() []string {
8585
func (self *version1_0) HandleRequest(requestType string, request []string, m manager.Manager, w http.ResponseWriter, r *http.Request) error {
8686
switch requestType {
8787
case machineApi:
88-
glog.V(4).Infof("Api - Machine")
88+
klog.V(4).Infof("Api - Machine")
8989

9090
// Get the MachineInfo
9191
machineInfo, err := m.GetMachineInfo()
@@ -99,7 +99,7 @@ func (self *version1_0) HandleRequest(requestType string, request []string, m ma
9999
}
100100
case containersApi:
101101
containerName := getContainerName(request)
102-
glog.V(4).Infof("Api - Container(%s)", containerName)
102+
klog.V(4).Infof("Api - Container(%s)", containerName)
103103

104104
// Get the query request.
105105
query, err := getContainerInfoRequest(r.Body)
@@ -149,7 +149,7 @@ func (self *version1_1) HandleRequest(requestType string, request []string, m ma
149149
switch requestType {
150150
case subcontainersApi:
151151
containerName := getContainerName(request)
152-
glog.V(4).Infof("Api - Subcontainers(%s)", containerName)
152+
klog.V(4).Infof("Api - Subcontainers(%s)", containerName)
153153

154154
// Get the query request.
155155
query, err := getContainerInfoRequest(r.Body)
@@ -198,7 +198,7 @@ func (self *version1_2) SupportedRequestTypes() []string {
198198
func (self *version1_2) HandleRequest(requestType string, request []string, m manager.Manager, w http.ResponseWriter, r *http.Request) error {
199199
switch requestType {
200200
case dockerApi:
201-
glog.V(4).Infof("Api - Docker(%v)", request)
201+
klog.V(4).Infof("Api - Docker(%v)", request)
202202

203203
// Get the query request.
204204
query, err := getContainerInfoRequest(r.Body)
@@ -279,7 +279,7 @@ func handleEventRequest(request []string, m manager.Manager, w http.ResponseWrit
279279
return err
280280
}
281281
query.ContainerName = path.Join("/", getContainerName(request))
282-
glog.V(4).Infof("Api - Events(%v)", query)
282+
klog.V(4).Infof("Api - Events(%v)", query)
283283
if !stream {
284284
pastEvents, err := m.GetPastEvents(query)
285285
if err != nil {
@@ -319,14 +319,14 @@ func (self *version2_0) HandleRequest(requestType string, request []string, m ma
319319
}
320320
switch requestType {
321321
case versionApi:
322-
glog.V(4).Infof("Api - Version")
322+
klog.V(4).Infof("Api - Version")
323323
versionInfo, err := m.GetVersionInfo()
324324
if err != nil {
325325
return err
326326
}
327327
return writeResult(versionInfo.CadvisorVersion, w)
328328
case attributesApi:
329-
glog.V(4).Info("Api - Attributes")
329+
klog.V(4).Info("Api - Attributes")
330330

331331
machineInfo, err := m.GetMachineInfo()
332332
if err != nil {
@@ -339,7 +339,7 @@ func (self *version2_0) HandleRequest(requestType string, request []string, m ma
339339
info := v2.GetAttributes(machineInfo, versionInfo)
340340
return writeResult(info, w)
341341
case machineApi:
342-
glog.V(4).Info("Api - Machine")
342+
klog.V(4).Info("Api - Machine")
343343

344344
// TODO(rjnagal): Move machineInfo from v1.
345345
machineInfo, err := m.GetMachineInfo()
@@ -349,7 +349,7 @@ func (self *version2_0) HandleRequest(requestType string, request []string, m ma
349349
return writeResult(machineInfo, w)
350350
case summaryApi:
351351
containerName := getContainerName(request)
352-
glog.V(4).Infof("Api - Summary for container %q, options %+v", containerName, opt)
352+
klog.V(4).Infof("Api - Summary for container %q, options %+v", containerName, opt)
353353

354354
stats, err := m.GetDerivedStats(containerName, opt)
355355
if err != nil {
@@ -358,13 +358,13 @@ func (self *version2_0) HandleRequest(requestType string, request []string, m ma
358358
return writeResult(stats, w)
359359
case statsApi:
360360
name := getContainerName(request)
361-
glog.V(4).Infof("Api - Stats: Looking for stats for container %q, options %+v", name, opt)
361+
klog.V(4).Infof("Api - Stats: Looking for stats for container %q, options %+v", name, opt)
362362
infos, err := m.GetRequestedContainersInfo(name, opt)
363363
if err != nil {
364364
if len(infos) == 0 {
365365
return err
366366
}
367-
glog.Errorf("Error calling GetRequestedContainersInfo: %v", err)
367+
klog.Errorf("Error calling GetRequestedContainersInfo: %v", err)
368368
}
369369
contStats := make(map[string][]v2.DeprecatedContainerStats, 0)
370370
for name, cinfo := range infos {
@@ -373,7 +373,7 @@ func (self *version2_0) HandleRequest(requestType string, request []string, m ma
373373
return writeResult(contStats, w)
374374
case customMetricsApi:
375375
containerName := getContainerName(request)
376-
glog.V(4).Infof("Api - Custom Metrics: Looking for metrics for container %q, options %+v", containerName, opt)
376+
klog.V(4).Infof("Api - Custom Metrics: Looking for metrics for container %q, options %+v", containerName, opt)
377377
infos, err := m.GetContainerInfoV2(containerName, opt)
378378
if err != nil {
379379
return err
@@ -413,7 +413,7 @@ func (self *version2_0) HandleRequest(requestType string, request []string, m ma
413413
return writeResult(contMetrics, w)
414414
case specApi:
415415
containerName := getContainerName(request)
416-
glog.V(4).Infof("Api - Spec for container %q, options %+v", containerName, opt)
416+
klog.V(4).Infof("Api - Spec for container %q, options %+v", containerName, opt)
417417
specs, err := m.GetContainerSpec(containerName, opt)
418418
if err != nil {
419419
return err
@@ -451,7 +451,7 @@ func (self *version2_0) HandleRequest(requestType string, request []string, m ma
451451
// ignore recursive.
452452
// TODO(rjnagal): consider count to limit ps output.
453453
name := getContainerName(request)
454-
glog.V(4).Infof("Api - Spec for container %q, options %+v", name, opt)
454+
klog.V(4).Infof("Api - Spec for container %q, options %+v", name, opt)
455455
ps, err := m.GetProcessList(name, opt)
456456
if err != nil {
457457
return fmt.Errorf("process listing failed: %v", err)
@@ -489,24 +489,24 @@ func (self *version2_1) HandleRequest(requestType string, request []string, m ma
489489

490490
switch requestType {
491491
case machineStatsApi:
492-
glog.V(4).Infof("Api - MachineStats(%v)", request)
492+
klog.V(4).Infof("Api - MachineStats(%v)", request)
493493
cont, err := m.GetRequestedContainersInfo("/", opt)
494494
if err != nil {
495495
if len(cont) == 0 {
496496
return err
497497
}
498-
glog.Errorf("Error calling GetRequestedContainersInfo: %v", err)
498+
klog.Errorf("Error calling GetRequestedContainersInfo: %v", err)
499499
}
500500
return writeResult(v2.MachineStatsFromV1(cont["/"]), w)
501501
case statsApi:
502502
name := getContainerName(request)
503-
glog.V(4).Infof("Api - Stats: Looking for stats for container %q, options %+v", name, opt)
503+
klog.V(4).Infof("Api - Stats: Looking for stats for container %q, options %+v", name, opt)
504504
conts, err := m.GetRequestedContainersInfo(name, opt)
505505
if err != nil {
506506
if len(conts) == 0 {
507507
return err
508508
}
509-
glog.Errorf("Error calling GetRequestedContainersInfo: %v", err)
509+
klog.Errorf("Error calling GetRequestedContainersInfo: %v", err)
510510
}
511511
contStats := make(map[string]v2.ContainerInfo, len(conts))
512512
for name, cont := range conts {

cache/memory/memory.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/google/cadvisor/storage"
2424
"github.com/google/cadvisor/utils"
2525

26-
"github.com/golang/glog"
26+
"k8s.io/klog"
2727
)
2828

2929
// ErrDataNotFound is the error resulting if failed to find a container in memory cache.
@@ -91,7 +91,7 @@ func (self *InMemoryCache) AddStats(cInfo *info.ContainerInfo, stats *info.Conta
9191
// may want to start a pool of goroutines to do write
9292
// operations.
9393
if err := self.backend.AddStats(cInfo, stats); err != nil {
94-
glog.Error(err)
94+
klog.Error(err)
9595
}
9696
}
9797
return cstore.AddStats(stats)

0 commit comments

Comments
 (0)