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
a77450ec
Commit
a77450ec
authored
Feb 07, 2018
by
Lantao Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mountpoint as CRI image filesystem storage identifier.
parent
c37b5d75
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
54 additions
and
54 deletions
+54
-54
api.pb.go
pkg/kubelet/apis/cri/runtime/v1alpha2/api.pb.go
+0
-0
api.proto
pkg/kubelet/apis/cri/runtime/v1alpha2/api.proto
+6
-6
cadvisor_unsupported.go
pkg/kubelet/cadvisor/cadvisor_unsupported.go
+1
-1
cadvisor_windows.go
pkg/kubelet/cadvisor/cadvisor_windows.go
+1
-1
cadvisor_fake.go
pkg/kubelet/cadvisor/testing/cadvisor_fake.go
+1
-1
cadvisor_mock.go
pkg/kubelet/cadvisor/testing/cadvisor_mock.go
+2
-2
types.go
pkg/kubelet/cadvisor/types.go
+2
-3
cri_stats_provider.go
pkg/kubelet/stats/cri_stats_provider.go
+25
-24
cri_stats_provider_test.go
pkg/kubelet/stats/cri_stats_provider_test.go
+16
-16
No files found.
pkg/kubelet/apis/cri/runtime/v1alpha2/api.pb.go
View file @
a77450ec
This diff is collapsed.
Click to expand it.
pkg/kubelet/apis/cri/runtime/v1alpha2/api.proto
View file @
a77450ec
...
@@ -1103,18 +1103,18 @@ message UInt64Value {
...
@@ -1103,18 +1103,18 @@ message UInt64Value {
uint64
value
=
1
;
uint64
value
=
1
;
}
}
//
StorageIdentifier uniquely identify the storage.
.
//
FilesystemIdentifier uniquely identify the filesystem
.
message
Storage
Identifier
{
message
Filesystem
Identifier
{
//
UUID of the device
.
//
Mountpoint of a filesystem
.
string
uuid
=
1
;
string
mountpoint
=
1
;
}
}
// FilesystemUsage provides the filesystem usage information.
// FilesystemUsage provides the filesystem usage information.
message
FilesystemUsage
{
message
FilesystemUsage
{
// Timestamp in nanoseconds at which the information were collected. Must be > 0.
// Timestamp in nanoseconds at which the information were collected. Must be > 0.
int64
timestamp
=
1
;
int64
timestamp
=
1
;
// The un
derlying storage
of the filesystem.
// The un
ique identifier
of the filesystem.
StorageIdentifier
storage
_id
=
2
;
FilesystemIdentifier
fs
_id
=
2
;
// UsedBytes represents the bytes used for images on the filesystem.
// UsedBytes represents the bytes used for images on the filesystem.
// This may differ from the total bytes used on the filesystem and may not
// This may differ from the total bytes used on the filesystem and may not
// equal CapacityBytes - AvailableBytes.
// equal CapacityBytes - AvailableBytes.
...
...
pkg/kubelet/cadvisor/cadvisor_unsupported.go
View file @
a77450ec
...
@@ -77,6 +77,6 @@ func (cu *cadvisorUnsupported) WatchEvents(request *events.Request) (*events.Eve
...
@@ -77,6 +77,6 @@ func (cu *cadvisorUnsupported) WatchEvents(request *events.Request) (*events.Eve
return
nil
,
unsupportedErr
return
nil
,
unsupportedErr
}
}
func
(
c
*
cadvisorUnsupported
)
GetFsInfoByFsUUID
(
uuid
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
{
func
(
c
u
*
cadvisorUnsupported
)
GetDirFsInfo
(
path
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
{
return
cadvisorapiv2
.
FsInfo
{},
nil
return
cadvisorapiv2
.
FsInfo
{},
nil
}
}
pkg/kubelet/cadvisor/cadvisor_windows.go
View file @
a77450ec
...
@@ -77,6 +77,6 @@ func (cu *cadvisorClient) WatchEvents(request *events.Request) (*events.EventCha
...
@@ -77,6 +77,6 @@ func (cu *cadvisorClient) WatchEvents(request *events.Request) (*events.EventCha
return
&
events
.
EventChannel
{},
nil
return
&
events
.
EventChannel
{},
nil
}
}
func
(
c
*
cadvisorClient
)
GetFsInfoByFsUUID
(
uuid
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
{
func
(
c
u
*
cadvisorClient
)
GetDirFsInfo
(
path
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
{
return
cadvisorapiv2
.
FsInfo
{},
nil
return
cadvisorapiv2
.
FsInfo
{},
nil
}
}
pkg/kubelet/cadvisor/testing/cadvisor_fake.go
View file @
a77450ec
...
@@ -76,6 +76,6 @@ func (c *Fake) WatchEvents(request *events.Request) (*events.EventChannel, error
...
@@ -76,6 +76,6 @@ func (c *Fake) WatchEvents(request *events.Request) (*events.EventChannel, error
return
new
(
events
.
EventChannel
),
nil
return
new
(
events
.
EventChannel
),
nil
}
}
func
(
c
*
Fake
)
Get
FsInfoByFsUUID
(
uuid
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
{
func
(
c
*
Fake
)
Get
DirFsInfo
(
path
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
{
return
cadvisorapiv2
.
FsInfo
{},
nil
return
cadvisorapiv2
.
FsInfo
{},
nil
}
}
pkg/kubelet/cadvisor/testing/cadvisor_mock.go
View file @
a77450ec
...
@@ -84,7 +84,7 @@ func (c *Mock) WatchEvents(request *events.Request) (*events.EventChannel, error
...
@@ -84,7 +84,7 @@ func (c *Mock) WatchEvents(request *events.Request) (*events.EventChannel, error
return
args
.
Get
(
0
)
.
(
*
events
.
EventChannel
),
args
.
Error
(
1
)
return
args
.
Get
(
0
)
.
(
*
events
.
EventChannel
),
args
.
Error
(
1
)
}
}
func
(
c
*
Mock
)
Get
FsInfoByFsUUID
(
uuid
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
{
func
(
c
*
Mock
)
Get
DirFsInfo
(
path
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
{
args
:=
c
.
Called
(
uuid
)
args
:=
c
.
Called
(
path
)
return
args
.
Get
(
0
)
.
(
cadvisorapiv2
.
FsInfo
),
args
.
Error
(
1
)
return
args
.
Get
(
0
)
.
(
cadvisorapiv2
.
FsInfo
),
args
.
Error
(
1
)
}
}
pkg/kubelet/cadvisor/types.go
View file @
a77450ec
...
@@ -42,9 +42,8 @@ type Interface interface {
...
@@ -42,9 +42,8 @@ type Interface interface {
// Get events streamed through passedChannel that fit the request.
// Get events streamed through passedChannel that fit the request.
WatchEvents
(
request
*
events
.
Request
)
(
*
events
.
EventChannel
,
error
)
WatchEvents
(
request
*
events
.
Request
)
(
*
events
.
EventChannel
,
error
)
// GetFsInfoByFsUUID returns the stats of the filesystem with the specified
// Get filesystem information for the filesystem that contains the given file.
// uuid.
GetDirFsInfo
(
path
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
GetFsInfoByFsUUID
(
uuid
string
)
(
cadvisorapiv2
.
FsInfo
,
error
)
}
}
// ImageFsInfoProvider informs cAdvisor how to find imagefs for container images.
// ImageFsInfoProvider informs cAdvisor how to find imagefs for container images.
...
...
pkg/kubelet/stats/cri_stats_provider.go
View file @
a77450ec
...
@@ -95,10 +95,10 @@ func (p *criStatsProvider) ListPodStats() ([]statsapi.PodStats, error) {
...
@@ -95,10 +95,10 @@ func (p *criStatsProvider) ListPodStats() ([]statsapi.PodStats, error) {
podSandboxMap
[
s
.
Id
]
=
s
podSandboxMap
[
s
.
Id
]
=
s
}
}
//
uuidToFsInfo is a map from filesystem UUID to its stats. This will be
//
fsIDtoInfo is a map from filesystem id to its stats. This will be used
//
used as a cache to avoid querying cAdvisor for the filesystem stats with
//
as a cache to avoid querying cAdvisor for the filesystem stats with the
//
the same UUID
many times.
//
same filesystem id
many times.
uuidToFsInfo
:=
make
(
map
[
runtimeapi
.
Storage
Identifier
]
*
cadvisorapiv2
.
FsInfo
)
fsIDtoInfo
:=
make
(
map
[
runtimeapi
.
Filesystem
Identifier
]
*
cadvisorapiv2
.
FsInfo
)
// sandboxIDToPodStats is a temporary map from sandbox ID to its pod stats.
// sandboxIDToPodStats is a temporary map from sandbox ID to its pod stats.
sandboxIDToPodStats
:=
make
(
map
[
string
]
*
statsapi
.
PodStats
)
sandboxIDToPodStats
:=
make
(
map
[
string
]
*
statsapi
.
PodStats
)
...
@@ -149,7 +149,7 @@ func (p *criStatsProvider) ListPodStats() ([]statsapi.PodStats, error) {
...
@@ -149,7 +149,7 @@ func (p *criStatsProvider) ListPodStats() ([]statsapi.PodStats, error) {
}
}
sandboxIDToPodStats
[
podSandboxID
]
=
ps
sandboxIDToPodStats
[
podSandboxID
]
=
ps
}
}
cs
:=
p
.
makeContainerStats
(
stats
,
container
,
&
rootFsInfo
,
uuidToFs
Info
)
cs
:=
p
.
makeContainerStats
(
stats
,
container
,
&
rootFsInfo
,
fsIDto
Info
)
// If cadvisor stats is available for the container, use it to populate
// If cadvisor stats is available for the container, use it to populate
// container stats
// container stats
caStats
,
caFound
:=
caInfos
[
containerID
]
caStats
,
caFound
:=
caInfos
[
containerID
]
...
@@ -186,11 +186,11 @@ func (p *criStatsProvider) ImageFsStats() (*statsapi.FsStats, error) {
...
@@ -186,11 +186,11 @@ func (p *criStatsProvider) ImageFsStats() (*statsapi.FsStats, error) {
UsedBytes
:
&
fs
.
UsedBytes
.
Value
,
UsedBytes
:
&
fs
.
UsedBytes
.
Value
,
InodesUsed
:
&
fs
.
InodesUsed
.
Value
,
InodesUsed
:
&
fs
.
InodesUsed
.
Value
,
}
}
imageFsInfo
:=
p
.
getFsInfo
(
fs
.
StorageId
)
imageFsInfo
:=
p
.
getFsInfo
(
fs
.
GetFsId
()
)
if
imageFsInfo
!=
nil
{
if
imageFsInfo
!=
nil
{
// The image filesystem
UUID is unknown to the local node or
// The image filesystem
id is unknown to the local node or there's
//
there's an error on retrieving the stats. In these cases, w
e
//
an error on retrieving the stats. In these cases, we omit thos
e
//
omit those
stats and return the best-effort partial result. See
// stats and return the best-effort partial result. See
// https://github.com/kubernetes/heapster/issues/1793.
// https://github.com/kubernetes/heapster/issues/1793.
s
.
AvailableBytes
=
&
imageFsInfo
.
Available
s
.
AvailableBytes
=
&
imageFsInfo
.
Available
s
.
CapacityBytes
=
&
imageFsInfo
.
Capacity
s
.
CapacityBytes
=
&
imageFsInfo
.
Capacity
...
@@ -211,7 +211,7 @@ func (p *criStatsProvider) ImageFsDevice() (string, error) {
...
@@ -211,7 +211,7 @@ func (p *criStatsProvider) ImageFsDevice() (string, error) {
return
""
,
err
return
""
,
err
}
}
for
_
,
fs
:=
range
resp
{
for
_
,
fs
:=
range
resp
{
fsInfo
:=
p
.
getFsInfo
(
fs
.
Get
Storage
Id
())
fsInfo
:=
p
.
getFsInfo
(
fs
.
Get
Fs
Id
())
if
fsInfo
!=
nil
{
if
fsInfo
!=
nil
{
return
fsInfo
.
Device
,
nil
return
fsInfo
.
Device
,
nil
}
}
...
@@ -220,16 +220,17 @@ func (p *criStatsProvider) ImageFsDevice() (string, error) {
...
@@ -220,16 +220,17 @@ func (p *criStatsProvider) ImageFsDevice() (string, error) {
}
}
// getFsInfo returns the information of the filesystem with the specified
// getFsInfo returns the information of the filesystem with the specified
//
storage
ID. If any error occurs, this function logs the error and returns
//
fs
ID. If any error occurs, this function logs the error and returns
// nil.
// nil.
func
(
p
*
criStatsProvider
)
getFsInfo
(
storageID
*
runtimeapi
.
Storage
Identifier
)
*
cadvisorapiv2
.
FsInfo
{
func
(
p
*
criStatsProvider
)
getFsInfo
(
fsID
*
runtimeapi
.
Filesystem
Identifier
)
*
cadvisorapiv2
.
FsInfo
{
if
storage
ID
==
nil
{
if
fs
ID
==
nil
{
glog
.
V
(
2
)
.
Infof
(
"Failed to get filesystem info:
storage
ID is nil."
)
glog
.
V
(
2
)
.
Infof
(
"Failed to get filesystem info:
fs
ID is nil."
)
return
nil
return
nil
}
}
fsInfo
,
err
:=
p
.
cadvisor
.
GetFsInfoByFsUUID
(
storageID
.
Uuid
)
mountpoint
:=
fsID
.
GetMountpoint
()
fsInfo
,
err
:=
p
.
cadvisor
.
GetDirFsInfo
(
mountpoint
)
if
err
!=
nil
{
if
err
!=
nil
{
msg
:=
fmt
.
Sprintf
(
"Failed to get the info of the filesystem with
id %q: %v."
,
storageID
.
Uuid
,
err
)
msg
:=
fmt
.
Sprintf
(
"Failed to get the info of the filesystem with
mountpoint %q: %v."
,
mountpoint
,
err
)
if
err
==
cadvisorfs
.
ErrNoSuchDevice
{
if
err
==
cadvisorfs
.
ErrNoSuchDevice
{
glog
.
V
(
2
)
.
Info
(
msg
)
glog
.
V
(
2
)
.
Info
(
msg
)
}
else
{
}
else
{
...
@@ -275,7 +276,7 @@ func (p *criStatsProvider) makeContainerStats(
...
@@ -275,7 +276,7 @@ func (p *criStatsProvider) makeContainerStats(
stats
*
runtimeapi
.
ContainerStats
,
stats
*
runtimeapi
.
ContainerStats
,
container
*
runtimeapi
.
Container
,
container
*
runtimeapi
.
Container
,
rootFsInfo
*
cadvisorapiv2
.
FsInfo
,
rootFsInfo
*
cadvisorapiv2
.
FsInfo
,
uuidToFsInfo
map
[
runtimeapi
.
Storage
Identifier
]
*
cadvisorapiv2
.
FsInfo
,
fsIDtoInfo
map
[
runtimeapi
.
Filesystem
Identifier
]
*
cadvisorapiv2
.
FsInfo
,
)
*
statsapi
.
ContainerStats
{
)
*
statsapi
.
ContainerStats
{
result
:=
&
statsapi
.
ContainerStats
{
result
:=
&
statsapi
.
ContainerStats
{
Name
:
stats
.
Attributes
.
Metadata
.
Name
,
Name
:
stats
.
Attributes
.
Metadata
.
Name
,
...
@@ -324,16 +325,16 @@ func (p *criStatsProvider) makeContainerStats(
...
@@ -324,16 +325,16 @@ func (p *criStatsProvider) makeContainerStats(
result
.
Rootfs
.
InodesUsed
=
&
stats
.
WritableLayer
.
InodesUsed
.
Value
result
.
Rootfs
.
InodesUsed
=
&
stats
.
WritableLayer
.
InodesUsed
.
Value
}
}
}
}
storageID
:=
stats
.
GetWritableLayer
()
.
GetStorage
Id
()
fsID
:=
stats
.
GetWritableLayer
()
.
GetFs
Id
()
if
storage
ID
!=
nil
{
if
fs
ID
!=
nil
{
imageFsInfo
,
found
:=
uuidToFsInfo
[
*
storage
ID
]
imageFsInfo
,
found
:=
fsIDtoInfo
[
*
fs
ID
]
if
!
found
{
if
!
found
{
imageFsInfo
=
p
.
getFsInfo
(
storage
ID
)
imageFsInfo
=
p
.
getFsInfo
(
fs
ID
)
uuidToFsInfo
[
*
storage
ID
]
=
imageFsInfo
fsIDtoInfo
[
*
fs
ID
]
=
imageFsInfo
}
}
if
imageFsInfo
!=
nil
{
if
imageFsInfo
!=
nil
{
// The image filesystem
UUID is unknown to the local node or there's an
// The image filesystem
id is unknown to the local node or there's
// error on retrieving the stats. In these cases, we omit those stats
//
an
error on retrieving the stats. In these cases, we omit those stats
// and return the best-effort partial result. See
// and return the best-effort partial result. See
// https://github.com/kubernetes/heapster/issues/1793.
// https://github.com/kubernetes/heapster/issues/1793.
result
.
Rootfs
.
AvailableBytes
=
&
imageFsInfo
.
Available
result
.
Rootfs
.
AvailableBytes
=
&
imageFsInfo
.
Available
...
...
pkg/kubelet/stats/cri_stats_provider_test.go
View file @
a77450ec
...
@@ -63,26 +63,26 @@ func TestCRIListPodStats(t *testing.T) {
...
@@ -63,26 +63,26 @@ func TestCRIListPodStats(t *testing.T) {
)
)
var
(
var
(
imageFs
StorageUUID
=
"imagefs-storage-uuid
"
imageFs
Mountpoint
=
"/test/mount/point
"
unknown
StorageUUID
=
"unknown-storage-uuid
"
unknown
Mountpoint
=
"/unknown/mount/point
"
imageFsInfo
=
getTestFsInfo
(
2000
)
imageFsInfo
=
getTestFsInfo
(
2000
)
rootFsInfo
=
getTestFsInfo
(
1000
)
rootFsInfo
=
getTestFsInfo
(
1000
)
sandbox0
=
makeFakePodSandbox
(
"sandbox0-name"
,
"sandbox0-uid"
,
"sandbox0-ns"
)
sandbox0
=
makeFakePodSandbox
(
"sandbox0-name"
,
"sandbox0-uid"
,
"sandbox0-ns"
)
container0
=
makeFakeContainer
(
sandbox0
,
cName0
,
0
,
false
)
container0
=
makeFakeContainer
(
sandbox0
,
cName0
,
0
,
false
)
containerStats0
=
makeFakeContainerStats
(
container0
,
imageFs
StorageUUID
)
containerStats0
=
makeFakeContainerStats
(
container0
,
imageFs
Mountpoint
)
container1
=
makeFakeContainer
(
sandbox0
,
cName1
,
0
,
false
)
container1
=
makeFakeContainer
(
sandbox0
,
cName1
,
0
,
false
)
containerStats1
=
makeFakeContainerStats
(
container1
,
unknown
StorageUUID
)
containerStats1
=
makeFakeContainerStats
(
container1
,
unknown
Mountpoint
)
sandbox1
=
makeFakePodSandbox
(
"sandbox1-name"
,
"sandbox1-uid"
,
"sandbox1-ns"
)
sandbox1
=
makeFakePodSandbox
(
"sandbox1-name"
,
"sandbox1-uid"
,
"sandbox1-ns"
)
container2
=
makeFakeContainer
(
sandbox1
,
cName2
,
0
,
false
)
container2
=
makeFakeContainer
(
sandbox1
,
cName2
,
0
,
false
)
containerStats2
=
makeFakeContainerStats
(
container2
,
imageFs
StorageUUID
)
containerStats2
=
makeFakeContainerStats
(
container2
,
imageFs
Mountpoint
)
sandbox2
=
makeFakePodSandbox
(
"sandbox2-name"
,
"sandbox2-uid"
,
"sandbox2-ns"
)
sandbox2
=
makeFakePodSandbox
(
"sandbox2-name"
,
"sandbox2-uid"
,
"sandbox2-ns"
)
container3
=
makeFakeContainer
(
sandbox2
,
cName3
,
0
,
true
)
container3
=
makeFakeContainer
(
sandbox2
,
cName3
,
0
,
true
)
containerStats3
=
makeFakeContainerStats
(
container3
,
imageFs
StorageUUID
)
containerStats3
=
makeFakeContainerStats
(
container3
,
imageFs
Mountpoint
)
container4
=
makeFakeContainer
(
sandbox2
,
cName3
,
1
,
false
)
container4
=
makeFakeContainer
(
sandbox2
,
cName3
,
1
,
false
)
containerStats4
=
makeFakeContainerStats
(
container4
,
imageFs
StorageUUID
)
containerStats4
=
makeFakeContainerStats
(
container4
,
imageFs
Mountpoint
)
)
)
var
(
var
(
...
@@ -116,8 +116,8 @@ func TestCRIListPodStats(t *testing.T) {
...
@@ -116,8 +116,8 @@ func TestCRIListPodStats(t *testing.T) {
mockCadvisor
.
mockCadvisor
.
On
(
"ContainerInfoV2"
,
"/"
,
options
)
.
Return
(
infos
,
nil
)
.
On
(
"ContainerInfoV2"
,
"/"
,
options
)
.
Return
(
infos
,
nil
)
.
On
(
"RootFsInfo"
)
.
Return
(
rootFsInfo
,
nil
)
.
On
(
"RootFsInfo"
)
.
Return
(
rootFsInfo
,
nil
)
.
On
(
"Get
FsInfoByFsUUID"
,
imageFsStorageUUID
)
.
Return
(
imageFsInfo
,
nil
)
.
On
(
"Get
DirFsInfo"
,
imageFsMountpoint
)
.
Return
(
imageFsInfo
,
nil
)
.
On
(
"Get
FsInfoByFsUUID"
,
unknownStorageUUID
)
.
Return
(
cadvisorapiv2
.
FsInfo
{},
cadvisorfs
.
ErrNoSuchDevice
)
On
(
"Get
DirFsInfo"
,
unknownMountpoint
)
.
Return
(
cadvisorapiv2
.
FsInfo
{},
cadvisorfs
.
ErrNoSuchDevice
)
fakeRuntimeService
.
SetFakeSandboxes
([]
*
critest
.
FakePodSandbox
{
fakeRuntimeService
.
SetFakeSandboxes
([]
*
critest
.
FakePodSandbox
{
sandbox0
,
sandbox1
,
sandbox2
,
sandbox0
,
sandbox1
,
sandbox2
,
})
})
...
@@ -209,9 +209,9 @@ func TestCRIListPodStats(t *testing.T) {
...
@@ -209,9 +209,9 @@ func TestCRIListPodStats(t *testing.T) {
func
TestCRIImagesFsStats
(
t
*
testing
.
T
)
{
func
TestCRIImagesFsStats
(
t
*
testing
.
T
)
{
var
(
var
(
imageFs
StorageUUID
=
"imagefs-storage-uuid
"
imageFs
Mountpoint
=
"/test/mount/point
"
imageFsInfo
=
getTestFsInfo
(
2000
)
imageFsInfo
=
getTestFsInfo
(
2000
)
imageFsUsage
=
makeFakeImageFsUsage
(
imageFsStorageUUID
)
imageFsUsage
=
makeFakeImageFsUsage
(
imageFsMountpoint
)
)
)
var
(
var
(
mockCadvisor
=
new
(
cadvisortest
.
Mock
)
mockCadvisor
=
new
(
cadvisortest
.
Mock
)
...
@@ -222,7 +222,7 @@ func TestCRIImagesFsStats(t *testing.T) {
...
@@ -222,7 +222,7 @@ func TestCRIImagesFsStats(t *testing.T) {
fakeImageService
=
critest
.
NewFakeImageService
()
fakeImageService
=
critest
.
NewFakeImageService
()
)
)
mockCadvisor
.
On
(
"Get
FsInfoByFsUUID"
,
imageFsStorageUUID
)
.
Return
(
imageFsInfo
,
nil
)
mockCadvisor
.
On
(
"Get
DirFsInfo"
,
imageFsMountpoint
)
.
Return
(
imageFsInfo
,
nil
)
fakeImageService
.
SetFakeFilesystemUsage
([]
*
runtimeapi
.
FilesystemUsage
{
fakeImageService
.
SetFakeFilesystemUsage
([]
*
runtimeapi
.
FilesystemUsage
{
imageFsUsage
,
imageFsUsage
,
})
})
...
@@ -292,7 +292,7 @@ func makeFakeContainer(sandbox *critest.FakePodSandbox, name string, attempt uin
...
@@ -292,7 +292,7 @@ func makeFakeContainer(sandbox *critest.FakePodSandbox, name string, attempt uin
return
c
return
c
}
}
func
makeFakeContainerStats
(
container
*
critest
.
FakeContainer
,
imageFs
UUID
string
)
*
runtimeapi
.
ContainerStats
{
func
makeFakeContainerStats
(
container
*
critest
.
FakeContainer
,
imageFs
Mountpoint
string
)
*
runtimeapi
.
ContainerStats
{
containerStats
:=
&
runtimeapi
.
ContainerStats
{
containerStats
:=
&
runtimeapi
.
ContainerStats
{
Attributes
:
&
runtimeapi
.
ContainerAttributes
{
Attributes
:
&
runtimeapi
.
ContainerAttributes
{
Id
:
container
.
ContainerStatus
.
Id
,
Id
:
container
.
ContainerStatus
.
Id
,
...
@@ -300,7 +300,7 @@ func makeFakeContainerStats(container *critest.FakeContainer, imageFsUUID string
...
@@ -300,7 +300,7 @@ func makeFakeContainerStats(container *critest.FakeContainer, imageFsUUID string
},
},
WritableLayer
:
&
runtimeapi
.
FilesystemUsage
{
WritableLayer
:
&
runtimeapi
.
FilesystemUsage
{
Timestamp
:
time
.
Now
()
.
UnixNano
(),
Timestamp
:
time
.
Now
()
.
UnixNano
(),
StorageId
:
&
runtimeapi
.
StorageIdentifier
{
Uuid
:
imageFsUUID
},
FsId
:
&
runtimeapi
.
FilesystemIdentifier
{
Mountpoint
:
imageFsMountpoint
},
UsedBytes
:
&
runtimeapi
.
UInt64Value
{
Value
:
rand
.
Uint64
()
/
100
},
UsedBytes
:
&
runtimeapi
.
UInt64Value
{
Value
:
rand
.
Uint64
()
/
100
},
InodesUsed
:
&
runtimeapi
.
UInt64Value
{
Value
:
rand
.
Uint64
()
/
100
},
InodesUsed
:
&
runtimeapi
.
UInt64Value
{
Value
:
rand
.
Uint64
()
/
100
},
},
},
...
@@ -321,10 +321,10 @@ func makeFakeContainerStats(container *critest.FakeContainer, imageFsUUID string
...
@@ -321,10 +321,10 @@ func makeFakeContainerStats(container *critest.FakeContainer, imageFsUUID string
return
containerStats
return
containerStats
}
}
func
makeFakeImageFsUsage
(
fs
UUID
string
)
*
runtimeapi
.
FilesystemUsage
{
func
makeFakeImageFsUsage
(
fs
Mountpoint
string
)
*
runtimeapi
.
FilesystemUsage
{
return
&
runtimeapi
.
FilesystemUsage
{
return
&
runtimeapi
.
FilesystemUsage
{
Timestamp
:
time
.
Now
()
.
UnixNano
(),
Timestamp
:
time
.
Now
()
.
UnixNano
(),
StorageId
:
&
runtimeapi
.
StorageIdentifier
{
Uuid
:
fsUUID
},
FsId
:
&
runtimeapi
.
FilesystemIdentifier
{
Mountpoint
:
fsMountpoint
},
UsedBytes
:
&
runtimeapi
.
UInt64Value
{
Value
:
rand
.
Uint64
()},
UsedBytes
:
&
runtimeapi
.
UInt64Value
{
Value
:
rand
.
Uint64
()},
InodesUsed
:
&
runtimeapi
.
UInt64Value
{
Value
:
rand
.
Uint64
()},
InodesUsed
:
&
runtimeapi
.
UInt64Value
{
Value
:
rand
.
Uint64
()},
}
}
...
...
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