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
5351602f
Commit
5351602f
authored
May 09, 2016
by
Yifan Gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rkt: Implement ImageStats() for rkt.
parent
e973b5d2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
image.go
pkg/kubelet/rkt/image.go
+14
-0
rkt.go
pkg/kubelet/rkt/rkt.go
+0
-5
rkt_test.go
pkg/kubelet/rkt/rkt_test.go
+15
-0
No files found.
pkg/kubelet/rkt/image.go
View file @
5351602f
...
@@ -227,3 +227,17 @@ func (r *Runtime) writeDockerAuthConfig(image string, credsSlice []credentialpro
...
@@ -227,3 +227,17 @@ func (r *Runtime) writeDockerAuthConfig(image string, credsSlice []credentialpro
}
}
return
nil
return
nil
}
}
// ImageStats returns the image stat (total storage bytes).
func
(
r
*
Runtime
)
ImageStats
()
(
*
kubecontainer
.
ImageStats
,
error
)
{
var
imageStat
kubecontainer
.
ImageStats
listResp
,
err
:=
r
.
apisvc
.
ListImages
(
context
.
Background
(),
&
rktapi
.
ListImagesRequest
{})
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"couldn't list images: %v"
,
err
)
}
for
_
,
image
:=
range
listResp
.
Images
{
imageStat
.
TotalStorageBytes
=
imageStat
.
TotalStorageBytes
+
uint64
(
image
.
Size
)
}
return
&
imageStat
,
nil
}
pkg/kubelet/rkt/rkt.go
View file @
5351602f
...
@@ -1771,8 +1771,3 @@ func (r *Runtime) GetPodStatus(uid types.UID, name, namespace string) (*kubecont
...
@@ -1771,8 +1771,3 @@ func (r *Runtime) GetPodStatus(uid types.UID, name, namespace string) (*kubecont
return
podStatus
,
nil
return
podStatus
,
nil
}
}
// FIXME: I need to be implemented.
func
(
r
*
Runtime
)
ImageStats
()
(
*
kubecontainer
.
ImageStats
,
error
)
{
return
&
kubecontainer
.
ImageStats
{},
nil
}
pkg/kubelet/rkt/rkt_test.go
View file @
5351602f
...
@@ -1382,3 +1382,18 @@ func TestLifeCycleHooks(t *testing.T) {
...
@@ -1382,3 +1382,18 @@ func TestLifeCycleHooks(t *testing.T) {
runner
.
Reset
()
runner
.
Reset
()
}
}
}
}
func
TestImageStats
(
t
*
testing
.
T
)
{
fr
:=
newFakeRktInterface
()
rkt
:=
&
Runtime
{
apisvc
:
fr
}
fr
.
images
=
[]
*
rktapi
.
Image
{
{
Size
:
100
},
{
Size
:
200
},
{
Size
:
300
},
}
result
,
err
:=
rkt
.
ImageStats
()
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
result
,
&
kubecontainer
.
ImageStats
{
TotalStorageBytes
:
600
})
}
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