Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7ce5e7bc
Commit
7ce5e7bc
authored
Apr 09, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6661 from vishh/sys_oom
Updating cadvisor deps and adding events cadvisor interface to kubelet
parents
284d2a30
de792099
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
176 additions
and
129 deletions
+176
-129
Godeps.json
Godeps/Godeps.json
+32
-32
handler.go
...orkspace/src/github.com/google/cadvisor/events/handler.go
+66
-76
handler_test.go
...ace/src/github.com/google/cadvisor/events/handler_test.go
+2
-2
handlers.go
...workspace/src/github.com/google/cadvisor/http/handlers.go
+1
-1
container.go
...space/src/github.com/google/cadvisor/info/v1/container.go
+29
-7
manager.go
...rkspace/src/github.com/google/cadvisor/manager/manager.go
+15
-6
stats_buffer.go
...github.com/google/cadvisor/storage/memory/stats_buffer.go
+6
-5
cadvisor_fake.go
pkg/kubelet/cadvisor/cadvisor_fake.go
+5
-0
cadvisor_linux.go
pkg/kubelet/cadvisor/cadvisor_linux.go
+5
-0
cadvisor_mock.go
pkg/kubelet/cadvisor/cadvisor_mock.go
+6
-0
cadvisor_unsupported.go
pkg/kubelet/cadvisor/cadvisor_unsupported.go
+5
-0
types.go
pkg/kubelet/cadvisor/types.go
+4
-0
No files found.
Godeps/Godeps.json
View file @
7ce5e7bc
...
...
@@ -212,83 +212,83 @@
},
{
"ImportPath"
:
"github.com/google/cadvisor/api"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/container"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/events"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/fs"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/healthz"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/http"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/info/v1"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/info/v2"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/manager"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/metrics"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/pages"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/storage"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/summary"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/utils"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/validate"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/cadvisor/version"
,
"Comment"
:
"0.11.0"
,
"Rev"
:
"
318252a107983f9d9fc109cc97f8140c37ec8233
"
"Comment"
:
"0.11.0
-14-ga1c6887
"
,
"Rev"
:
"
a1c688751c991f5002d4d36e8e0682186bc78566
"
},
{
"ImportPath"
:
"github.com/google/gofuzz"
,
...
...
Godeps/_workspace/src/github.com/google/cadvisor/events/handler.go
View file @
7ce5e7bc
...
...
@@ -25,63 +25,27 @@ import (
info
"github.com/google/cadvisor/info/v1"
)
// EventManager is implemented by Events. It provides two ways to monitor
// events and one way to add events
type
EventManager
interface
{
// Watch checks if events fed to it by the caller of AddEvent satisfy the
// request and if so sends the event back to the caller on outChannel
WatchEvents
(
request
*
Request
)
(
*
EventChannel
,
error
)
// GetEvents() returns a slice of all events detected that have passed
// the *Request object parameters to the caller
GetEvents
(
request
*
Request
)
(
EventSlice
,
error
)
// AddEvent allows the caller to add an event to an EventManager
// object
AddEvent
(
e
*
info
.
Event
)
error
// Removes a watch instance from the EventManager's watchers map
StopWatch
(
watch_id
int
)
type
EventSlice
[]
*
info
.
Event
// functions necessary to implement the sort interface on the Events struct
func
(
e
EventSlice
)
Len
()
int
{
return
len
(
e
)
}
// Events holds a slice of *Event objects with a potential field
// that caps the number of events held. It is an implementation of the
// EventManager interface
type
events
struct
{
// eventlist holds the complete set of events found over an
// EventManager events instantiation.
eventlist
EventSlice
// the slice of watch pointers allows the EventManager access to channels
// linked to different calls of WatchEvents. When new events are found that
// satisfy the request of a given watch object in watchers, the event
// is sent over the channel to that caller of WatchEvents
watchers
map
[
int
]
*
watch
// lock that blocks eventlist from being accessed until a writer releases it
eventsLock
sync
.
RWMutex
// lock that blocks watchers from being accessed until a writer releases it
watcherLock
sync
.
RWMutex
// receives notices when a watch event ends and needs to be removed from
// the watchers list
lastId
int
func
(
e
EventSlice
)
Swap
(
i
,
j
int
)
{
e
[
i
],
e
[
j
]
=
e
[
j
],
e
[
i
]
}
// initialized by a call to WatchEvents(), a watch struct will then be added
// to the events slice of *watch objects. When AddEvent() finds an event that
// satisfies the request parameter of a watch object in events.watchers,
// it will send that event out over the watch object's channel. The caller that
// called WatchEvents will receive the event over the channel provided to
// WatchEvents
type
watch
struct
{
// request specifies all the parameters that events sent through the
// channel must satisfy. Specified by the creator of the watch object
request
*
Request
// a channel created by the caller through which events satisfying the
// request are sent to the caller
eventChannel
*
EventChannel
// unique identifier of a watch that is used as a key in events' watchers
// map
id
int
func
(
e
EventSlice
)
Less
(
i
,
j
int
)
bool
{
return
e
[
i
]
.
Timestamp
.
Before
(
e
[
j
]
.
Timestamp
)
}
// typedef of a slice of Event pointers
type
EventSlice
[]
*
info
.
Event
type
EventChannel
struct
{
// Watch ID. Can be used by the caller to request cancellation of watch events.
watchId
int
// Channel on which the caller can receive watch events.
channel
chan
*
info
.
Event
}
// Request holds a set of parameters by which Event objects may be screened.
// The caller may want events that occurred within a specific timeframe
...
...
@@ -97,7 +61,7 @@ type Request struct {
// EventType is a map that specifies the type(s) of events wanted
EventType
map
[
info
.
EventType
]
bool
// allows the caller to put a limit on how many
// events t
hey
receive. If there are more events than MaxEventsReturned
// events t
o
receive. If there are more events than MaxEventsReturned
// then the most chronologically recent events in the time period
// specified are returned. Must be >= 1
MaxEventsReturned
int
...
...
@@ -108,9 +72,50 @@ type Request struct {
IncludeSubcontainers
bool
}
type
EventChannel
struct
{
watchId
int
channel
chan
*
info
.
Event
// EventManager is implemented by Events. It provides two ways to monitor
// events and one way to add events
type
EventManager
interface
{
// WatchEvents() allows a caller to register for receiving events based on the specified request.
// On successful registration, an EventChannel object is returned.
WatchEvents
(
request
*
Request
)
(
*
EventChannel
,
error
)
// GetEvents() returns all detected events based on the filters specified in request.
GetEvents
(
request
*
Request
)
(
EventSlice
,
error
)
// AddEvent allows the caller to add an event to an EventManager
// object
AddEvent
(
e
*
info
.
Event
)
error
// Cancels a previously requested watch event.
StopWatch
(
watch_id
int
)
}
// events provides an implementation for the EventManager interface.
type
events
struct
{
// eventList holds the complete set of events found over an
// EventManager events instantiation.
eventList
EventSlice
// map of registered watchers keyed by watch id.
watchers
map
[
int
]
*
watch
// lock guarding the eventList.
eventsLock
sync
.
RWMutex
// lock guarding watchers.
watcherLock
sync
.
RWMutex
// last allocated watch id.
lastId
int
}
// initialized by a call to WatchEvents(), a watch struct will then be added
// to the events slice of *watch objects. When AddEvent() finds an event that
// satisfies the request parameter of a watch object in events.watchers,
// it will send that event out over the watch object's channel. The caller that
// called WatchEvents will receive the event over the channel provided to
// WatchEvents
type
watch
struct
{
// request parameters passed in by the caller of WatchEvents()
request
*
Request
// a channel used to send event back to the caller.
eventChannel
*
EventChannel
// unique identifier of a watch that is used as a key in events' watchers
// map
id
int
}
func
NewEventChannel
(
watchId
int
)
*
EventChannel
{
...
...
@@ -123,7 +128,7 @@ func NewEventChannel(watchId int) *EventChannel {
// returns a pointer to an initialized Events object
func
NewEventManager
()
*
events
{
return
&
events
{
event
l
ist
:
make
(
EventSlice
,
0
),
event
L
ist
:
make
(
EventSlice
,
0
),
watchers
:
make
(
map
[
int
]
*
watch
),
}
}
...
...
@@ -153,21 +158,6 @@ func (self *EventChannel) GetWatchId() int {
return
self
.
watchId
}
// function necessary to implement the sort interface on the Events struct
func
(
e
EventSlice
)
Len
()
int
{
return
len
(
e
)
}
// function necessary to implement the sort interface on the Events struct
func
(
e
EventSlice
)
Swap
(
i
,
j
int
)
{
e
[
i
],
e
[
j
]
=
e
[
j
],
e
[
i
]
}
// function necessary to implement the sort interface on the Events struct
func
(
e
EventSlice
)
Less
(
i
,
j
int
)
bool
{
return
e
[
i
]
.
Timestamp
.
Before
(
e
[
j
]
.
Timestamp
)
}
// sorts and returns up to the last MaxEventsReturned chronological elements
func
getMaxEventsReturned
(
request
*
Request
,
eSlice
EventSlice
)
EventSlice
{
sort
.
Sort
(
eSlice
)
...
...
@@ -213,7 +203,7 @@ func checkIfEventSatisfiesRequest(request *Request, event *info.Event) bool {
return
true
}
// method of Events object that screens Event objects found in the event
l
ist
// method of Events object that screens Event objects found in the event
L
ist
// attribute and if they fit the parameters passed by the Request object,
// adds it to a slice of *Event objects that is returned. If both MaxEventsReturned
// and StartTime/EndTime are specified in the request object, then only
...
...
@@ -222,7 +212,7 @@ func (self *events) GetEvents(request *Request) (EventSlice, error) {
returnEventList
:=
EventSlice
{}
self
.
eventsLock
.
RLock
()
defer
self
.
eventsLock
.
RUnlock
()
for
_
,
e
:=
range
self
.
event
l
ist
{
for
_
,
e
:=
range
self
.
event
L
ist
{
if
checkIfEventSatisfiesRequest
(
request
,
e
)
{
returnEventList
=
append
(
returnEventList
,
e
)
}
...
...
@@ -251,11 +241,11 @@ func (self *events) WatchEvents(request *Request) (*EventChannel, error) {
return
returnEventChannel
,
nil
}
// helper function to update the event manager's event
l
ist
// helper function to update the event manager's event
L
ist
func
(
self
*
events
)
updateEventList
(
e
*
info
.
Event
)
{
self
.
eventsLock
.
Lock
()
defer
self
.
eventsLock
.
Unlock
()
self
.
event
list
=
append
(
self
.
eventl
ist
,
e
)
self
.
event
List
=
append
(
self
.
eventL
ist
,
e
)
}
func
(
self
*
events
)
findValidWatchers
(
e
*
info
.
Event
)
[]
*
watch
{
...
...
@@ -270,7 +260,7 @@ func (self *events) findValidWatchers(e *info.Event) []*watch {
}
// method of Events object that adds the argument Event object to the
// event
l
ist. It also feeds the event to a set of watch channels
// event
L
ist. It also feeds the event to a set of watch channels
// held by the manager if it satisfies the request keys of the channels
func
(
self
*
events
)
AddEvent
(
e
*
info
.
Event
)
error
{
self
.
updateEventList
(
e
)
...
...
Godeps/_workspace/src/github.com/google/cadvisor/events/handler_test.go
View file @
7ce5e7bc
...
...
@@ -139,8 +139,8 @@ func TestAddEventAddsEventsToEventManager(t *testing.T) {
myEventHolder
.
AddEvent
(
fakeEvent
)
checkNumberOfEvents
(
t
,
1
,
myEventHolder
.
event
l
ist
.
Len
())
ensureProperEventReturned
(
t
,
fakeEvent
,
myEventHolder
.
event
l
ist
[
0
])
checkNumberOfEvents
(
t
,
1
,
myEventHolder
.
event
L
ist
.
Len
())
ensureProperEventReturned
(
t
,
fakeEvent
,
myEventHolder
.
event
L
ist
[
0
])
}
func
TestGetEventsForOneEvent
(
t
*
testing
.
T
)
{
...
...
Godeps/_workspace/src/github.com/google/cadvisor/http/handlers.go
View file @
7ce5e7bc
...
...
@@ -72,7 +72,7 @@ func RegisterHandlers(mux httpMux.Mux, containerManager manager.Manager, httpAut
authenticator
:=
auth
.
NewDigestAuthenticator
(
httpDigestRealm
,
secrets
)
mux
.
HandleFunc
(
static
.
StaticResource
,
authenticator
.
Wrap
(
staticHandler
))
if
err
:=
pages
.
RegisterHandlersDigest
(
mux
,
containerManager
,
authenticator
);
err
!=
nil
{
fmt
.
Errorf
(
"failed to register pages digest handlers: %s"
,
err
)
return
fmt
.
Errorf
(
"failed to register pages digest handlers: %s"
,
err
)
}
authenticated
=
true
}
...
...
Godeps/_workspace/src/github.com/google/cadvisor/info/v1/container.go
View file @
7ce5e7bc
...
...
@@ -479,14 +479,17 @@ func calculateCpuUsage(prev, cur uint64) uint64 {
// differentiated by the EventType field of Event.
type
Event
struct
{
// the absolute container name for which the event occurred
ContainerName
string
ContainerName
string
`json:"container_name"`
// the time at which the event occurred
Timestamp
time
.
Time
Timestamp
time
.
Time
`json:"timestamp"`
// the type of event. EventType is an enumerated type
EventType
EventType
EventType
EventType
`json:"event_type"`
// the original event object and all of its extraneous data, ex. an
// OomInstance
EventData
EventData
Interface
EventData
EventData
`json:"event_data,omitempty"`
}
// EventType is an enumerated type which lists the categories under which
...
...
@@ -499,7 +502,26 @@ const (
EventContainerDeletion
)
// a general interface which populates the Event field EventData. The actual
// object, such as an OomInstance, is set as an Event's EventData
type
EventDataInterface
interface
{
// Extra information about an event. Only one type will be set.
type
EventData
struct
{
// Information about a container creation event.
Created
*
CreatedEventData
`json:"created,omitempty"`
// Information about an OOM event.
Oom
*
OomEventData
`json:"oom,omitempty"`
}
// Information related to a container creation event.
type
CreatedEventData
struct
{
// Spec of the container at creation.
Spec
ContainerSpec
`json:"spec"`
}
// Information related to an OOM kill instance
type
OomEventData
struct
{
// process id of the killed process
Pid
int
`json:"pid"`
// The name of the killed process
ProcessName
string
`json:"process_name"`
}
Godeps/_workspace/src/github.com/google/cadvisor/manager/manager.go
View file @
7ce5e7bc
...
...
@@ -660,12 +660,12 @@ func (m *manager) createContainer(containerName string) error {
}
glog
.
V
(
2
)
.
Infof
(
"Added container: %q (aliases: %v, namespace: %q)"
,
containerName
,
cont
.
info
.
Aliases
,
cont
.
info
.
Namespace
)
contSpec
s
,
err
:=
cont
.
handler
.
GetSpec
()
contSpec
,
err
:=
cont
.
handler
.
GetSpec
()
if
err
!=
nil
{
return
err
}
if
contSpec
s
.
CreationTime
.
After
(
m
.
startupTime
)
{
if
contSpec
.
CreationTime
.
After
(
m
.
startupTime
)
{
contRef
,
err
:=
cont
.
handler
.
ContainerReference
()
if
err
!=
nil
{
return
err
...
...
@@ -673,9 +673,13 @@ func (m *manager) createContainer(containerName string) error {
newEvent
:=
&
info
.
Event
{
ContainerName
:
contRef
.
Name
,
EventData
:
contSpecs
,
Timestamp
:
contSpecs
.
CreationTime
,
Timestamp
:
contSpec
.
CreationTime
,
EventType
:
info
.
EventContainerCreation
,
EventData
:
info
.
EventData
{
Created
:
&
info
.
CreatedEventData
{
Spec
:
contSpec
,
},
},
}
err
=
m
.
eventHandler
.
AddEvent
(
newEvent
)
if
err
!=
nil
{
...
...
@@ -847,7 +851,7 @@ func (self *manager) watchForNewContainers(quit chan error) error {
err
=
self
.
destroyContainer
(
event
.
Name
)
}
if
err
!=
nil
{
glog
.
Warning
(
"Failed to process watch event: %v"
,
err
)
glog
.
Warning
f
(
"Failed to process watch event: %v"
,
err
)
}
case
<-
quit
:
// Stop processing events if asked to quit.
...
...
@@ -878,7 +882,12 @@ func (self *manager) watchForNewOoms() error {
ContainerName
:
oomInstance
.
ContainerName
,
Timestamp
:
oomInstance
.
TimeOfDeath
,
EventType
:
info
.
EventOom
,
EventData
:
oomInstance
,
EventData
:
info
.
EventData
{
Oom
:
&
info
.
OomEventData
{
Pid
:
oomInstance
.
Pid
,
ProcessName
:
oomInstance
.
ProcessName
,
},
},
}
glog
.
V
(
1
)
.
Infof
(
"Created an oom event: %v"
,
newEvent
)
err
:=
self
.
eventHandler
.
AddEvent
(
newEvent
)
...
...
Godeps/_workspace/src/github.com/google/cadvisor/storage/memory/stats_buffer.go
View file @
7ce5e7bc
...
...
@@ -23,7 +23,7 @@ import (
// A circular buffer for ContainerStats.
type
StatsBuffer
struct
{
buffer
[]
info
.
ContainerStats
buffer
[]
*
info
.
ContainerStats
size
int
index
int
}
...
...
@@ -31,7 +31,7 @@ type StatsBuffer struct {
// Returns a new thread-compatible StatsBuffer.
func
NewStatsBuffer
(
size
int
)
*
StatsBuffer
{
return
&
StatsBuffer
{
buffer
:
make
([]
info
.
ContainerStats
,
size
),
buffer
:
make
([]
*
info
.
ContainerStats
,
size
),
size
:
0
,
index
:
size
-
1
,
}
...
...
@@ -43,7 +43,8 @@ func (self *StatsBuffer) Add(item *info.ContainerStats) {
self
.
size
++
}
self
.
index
=
(
self
.
index
+
1
)
%
len
(
self
.
buffer
)
self
.
buffer
[
self
.
index
]
=
*
item
copied
:=
*
item
self
.
buffer
[
self
.
index
]
=
&
copied
}
// Returns up to maxResult elements in the specified time period (inclusive).
...
...
@@ -131,7 +132,7 @@ func (self *StatsBuffer) FirstN(n int) []*info.ContainerStats {
res
:=
make
([]
*
info
.
ContainerStats
,
n
)
for
i
:=
0
;
i
<
n
;
i
++
{
index
:=
(
start
+
i
)
%
len
(
self
.
buffer
)
res
[
i
]
=
&
self
.
buffer
[
index
]
res
[
i
]
=
self
.
buffer
[
index
]
}
return
res
}
...
...
@@ -142,7 +143,7 @@ func (self *StatsBuffer) Get(index int) *info.ContainerStats {
if
calculatedIndex
<
0
{
calculatedIndex
+=
len
(
self
.
buffer
)
}
return
&
self
.
buffer
[
calculatedIndex
]
return
self
.
buffer
[
calculatedIndex
]
}
func
(
self
*
StatsBuffer
)
Size
()
int
{
...
...
pkg/kubelet/cadvisor/cadvisor_fake.go
View file @
7ce5e7bc
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
cadvisor
import
(
"github.com/google/cadvisor/events"
cadvisorApi
"github.com/google/cadvisor/info/v1"
cadvisorApiV2
"github.com/google/cadvisor/info/v2"
)
...
...
@@ -46,3 +47,7 @@ func (c *Fake) VersionInfo() (*cadvisorApi.VersionInfo, error) {
func
(
c
*
Fake
)
DockerImagesFsInfo
()
(
cadvisorApiV2
.
FsInfo
,
error
)
{
return
cadvisorApiV2
.
FsInfo
{},
nil
}
func
(
c
*
Fake
)
GetPastEvents
(
request
*
events
.
Request
)
([]
*
cadvisorApi
.
Event
,
error
)
{
return
[]
*
cadvisorApi
.
Event
{},
nil
}
pkg/kubelet/cadvisor/cadvisor_linux.go
View file @
7ce5e7bc
...
...
@@ -25,6 +25,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
"github.com/google/cadvisor/events"
cadvisorFs
"github.com/google/cadvisor/fs"
cadvisorHttp
"github.com/google/cadvisor/http"
cadvisorApi
"github.com/google/cadvisor/info/v1"
...
...
@@ -132,3 +133,7 @@ func (self *cadvisorClient) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
return
res
[
0
],
nil
}
func
(
self
*
cadvisorClient
)
GetPastEvents
(
request
*
events
.
Request
)
([]
*
cadvisorApi
.
Event
,
error
)
{
return
self
.
GetPastEvents
(
request
)
}
pkg/kubelet/cadvisor/cadvisor_mock.go
View file @
7ce5e7bc
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
cadvisor
import
(
"github.com/google/cadvisor/events"
cadvisorApi
"github.com/google/cadvisor/info/v1"
cadvisorApiV2
"github.com/google/cadvisor/info/v2"
"github.com/stretchr/testify/mock"
...
...
@@ -55,3 +56,8 @@ func (c *Mock) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
args
:=
c
.
Called
()
return
args
.
Get
(
0
)
.
(
cadvisorApiV2
.
FsInfo
),
args
.
Error
(
1
)
}
func
(
c
*
Mock
)
GetPastEvents
(
request
*
events
.
Request
)
([]
*
cadvisorApi
.
Event
,
error
)
{
args
:=
c
.
Called
()
return
args
.
Get
(
0
)
.
([]
*
cadvisorApi
.
Event
),
args
.
Error
(
1
)
}
pkg/kubelet/cadvisor/cadvisor_unsupported.go
View file @
7ce5e7bc
...
...
@@ -21,6 +21,7 @@ package cadvisor
import
(
"errors"
"github.com/google/cadvisor/events"
cadvisorApi
"github.com/google/cadvisor/info/v1"
cadvisorApiV2
"github.com/google/cadvisor/info/v2"
)
...
...
@@ -55,3 +56,7 @@ func (self *cadvisorUnsupported) VersionInfo() (*cadvisorApi.VersionInfo, error)
func
(
self
*
cadvisorUnsupported
)
DockerImagesFsInfo
()
(
cadvisorApiV2
.
FsInfo
,
error
)
{
return
cadvisorApiV2
.
FsInfo
{},
unsupportedErr
}
func
(
self
*
cadvisorUnsupported
)
GetPastEvents
(
request
*
events
.
Request
)
([]
*
cadvisorApi
.
Event
,
error
)
{
return
cadvisorApi
.
Event
{},
unsupportedErr
}
pkg/kubelet/cadvisor/types.go
View file @
7ce5e7bc
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
cadvisor
import
(
"github.com/google/cadvisor/events"
cadvisorApi
"github.com/google/cadvisor/info/v1"
cadvisorApiV2
"github.com/google/cadvisor/info/v2"
)
...
...
@@ -31,4 +32,7 @@ type Interface interface {
// Returns usage information about the filesystem holding Docker images.
DockerImagesFsInfo
()
(
cadvisorApiV2
.
FsInfo
,
error
)
// Get past events that have been detected and that fit the request.
GetPastEvents
(
request
*
events
.
Request
)
([]
*
cadvisorApi
.
Event
,
error
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment