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
accd6a49
Commit
accd6a49
authored
Mar 11, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #22767 from yifan-gu/rkt_getpods
Auto commit by PR queue bot
parents
4ee7424a
56be600c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
5 deletions
+46
-5
rkt.go
pkg/kubelet/rkt/rkt.go
+18
-3
rkt_test.go
pkg/kubelet/rkt/rkt_test.go
+28
-2
No files found.
pkg/kubelet/rkt/rkt.go
View file @
accd6a49
...
@@ -997,16 +997,31 @@ func (r *Runtime) GetPods(all bool) ([]*kubecontainer.Pod, error) {
...
@@ -997,16 +997,31 @@ func (r *Runtime) GetPods(all bool) ([]*kubecontainer.Pod, error) {
return
nil
,
fmt
.
Errorf
(
"couldn't list pods: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"couldn't list pods: %v"
,
err
)
}
}
var
pods
[]
*
kubecontainer
.
Pod
pods
:=
make
(
map
[
types
.
UID
]
*
kubecontainer
.
Pod
)
for
_
,
pod
:=
range
listResp
.
Pods
{
for
_
,
pod
:=
range
listResp
.
Pods
{
pod
,
err
:=
r
.
convertRktPod
(
pod
)
pod
,
err
:=
r
.
convertRktPod
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Warningf
(
"rkt: Cannot construct pod from unit file: %v."
,
err
)
glog
.
Warningf
(
"rkt: Cannot construct pod from unit file: %v."
,
err
)
continue
continue
}
}
pods
=
append
(
pods
,
pod
)
// Group pods together.
oldPod
,
found
:=
pods
[
pod
.
ID
]
if
!
found
{
pods
[
pod
.
ID
]
=
pod
continue
}
oldPod
.
Containers
=
append
(
oldPod
.
Containers
,
pod
.
Containers
...
)
}
// Convert map to list.
var
result
[]
*
kubecontainer
.
Pod
for
_
,
p
:=
range
pods
{
result
=
append
(
result
,
p
)
}
}
return
pods
,
nil
return
result
,
nil
}
}
// KillPod invokes 'systemctl kill' to kill the unit that runs the pod.
// KillPod invokes 'systemctl kill' to kill the unit that runs the pod.
...
...
pkg/kubelet/rkt/rkt_test.go
View file @
accd6a49
...
@@ -409,7 +409,17 @@ func TestGetPods(t *testing.T) {
...
@@ -409,7 +409,17 @@ func TestGetPods(t *testing.T) {
[]
string
{
"img-id-11"
,
"img-id-22"
},
[]
string
{
"img-id-11"
,
"img-id-22"
},
[]
string
{
"img-name-11"
,
"img-name-22"
},
[]
string
{
"img-name-11"
,
"img-name-22"
},
[]
string
{
"10011"
,
"10022"
},
[]
string
{
"10011"
,
"10022"
},
[]
rktapi
.
AppState
{
rktapi
.
AppState_APP_STATE_RUNNING
,
rktapi
.
AppState_APP_STATE_EXITED
},
[]
rktapi
.
AppState
{
rktapi
.
AppState_APP_STATE_EXITED
,
rktapi
.
AppState_APP_STATE_EXITED
},
[]
int32
{
0
,
0
},
),
makeRktPod
(
rktapi
.
PodState_POD_STATE_EXITED
,
"uuid-4004"
,
"43"
,
"guestbook"
,
"default"
,
"10.10.10.44"
,
"100000"
,
"8"
,
[]
string
{
"app-11"
,
"app-22"
},
[]
string
{
"img-id-11"
,
"img-id-22"
},
[]
string
{
"img-name-11"
,
"img-name-22"
},
[]
string
{
"10011"
,
"10022"
},
[]
rktapi
.
AppState
{
rktapi
.
AppState_APP_STATE_RUNNING
,
rktapi
.
AppState_APP_STATE_RUNNING
},
[]
int32
{
0
,
0
},
[]
int32
{
0
,
0
},
),
),
},
},
...
@@ -448,7 +458,7 @@ func TestGetPods(t *testing.T) {
...
@@ -448,7 +458,7 @@ func TestGetPods(t *testing.T) {
Image
:
"img-name-11"
,
Image
:
"img-name-11"
,
Hash
:
10011
,
Hash
:
10011
,
Created
:
90000
,
Created
:
90000
,
State
:
"
running
"
,
State
:
"
exited
"
,
},
},
{
{
ID
:
kubecontainer
.
BuildContainerID
(
"rkt"
,
"uuid-4003:app-22"
),
ID
:
kubecontainer
.
BuildContainerID
(
"rkt"
,
"uuid-4003:app-22"
),
...
@@ -458,6 +468,22 @@ func TestGetPods(t *testing.T) {
...
@@ -458,6 +468,22 @@ func TestGetPods(t *testing.T) {
Created
:
90000
,
Created
:
90000
,
State
:
"exited"
,
State
:
"exited"
,
},
},
{
ID
:
kubecontainer
.
BuildContainerID
(
"rkt"
,
"uuid-4004:app-11"
),
Name
:
"app-11"
,
Image
:
"img-name-11"
,
Hash
:
10011
,
Created
:
100000
,
State
:
"running"
,
},
{
ID
:
kubecontainer
.
BuildContainerID
(
"rkt"
,
"uuid-4004:app-22"
),
Name
:
"app-22"
,
Image
:
"img-name-22"
,
Hash
:
10022
,
Created
:
100000
,
State
:
"running"
,
},
},
},
},
},
},
},
...
...
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