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
2ea11690
Commit
2ea11690
authored
Dec 22, 2015
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove running pod from SyncPod() of container runtime
parent
cd097e3f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
13 deletions
+10
-13
fake_runtime.go
pkg/kubelet/container/fake_runtime.go
+1
-1
runtime.go
pkg/kubelet/container/runtime.go
+1
-2
manager.go
pkg/kubelet/dockertools/manager.go
+1
-1
manager_test.go
pkg/kubelet/dockertools/manager_test.go
+1
-7
kubelet.go
pkg/kubelet/kubelet.go
+1
-1
rkt.go
pkg/kubelet/rkt/rkt.go
+5
-1
No files found.
pkg/kubelet/container/fake_runtime.go
View file @
2ea11690
...
@@ -165,7 +165,7 @@ func (f *FakeRuntime) GetPods(all bool) ([]*Pod, error) {
...
@@ -165,7 +165,7 @@ func (f *FakeRuntime) GetPods(all bool) ([]*Pod, error) {
return
f
.
PodList
,
f
.
Err
return
f
.
PodList
,
f
.
Err
}
}
func
(
f
*
FakeRuntime
)
SyncPod
(
pod
*
api
.
Pod
,
_
Pod
,
_
api
.
PodStatus
,
_
*
PodStatus
,
_
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
func
(
f
*
FakeRuntime
)
SyncPod
(
pod
*
api
.
Pod
,
_
api
.
PodStatus
,
_
*
PodStatus
,
_
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
...
...
pkg/kubelet/container/runtime.go
View file @
2ea11690
...
@@ -89,8 +89,7 @@ type Runtime interface {
...
@@ -89,8 +89,7 @@ type Runtime interface {
// GarbageCollect removes dead containers using the specified container gc policy
// GarbageCollect removes dead containers using the specified container gc policy
GarbageCollect
(
gcPolicy
ContainerGCPolicy
)
error
GarbageCollect
(
gcPolicy
ContainerGCPolicy
)
error
// Syncs the running pod into the desired pod.
// Syncs the running pod into the desired pod.
// TODO(random-liu): The runningPod will be removed after #17420 is done.
SyncPod
(
pod
*
api
.
Pod
,
apiPodStatus
api
.
PodStatus
,
podStatus
*
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
SyncPod
(
pod
*
api
.
Pod
,
runningPod
Pod
,
apiPodStatus
api
.
PodStatus
,
podStatus
*
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
// KillPod kills all the containers of a pod. Pod may be nil, running pod must not be.
// KillPod kills all the containers of a pod. Pod may be nil, running pod must not be.
KillPod
(
pod
*
api
.
Pod
,
runningPod
Pod
)
error
KillPod
(
pod
*
api
.
Pod
,
runningPod
Pod
)
error
// GetAPIPodStatus retrieves the api.PodStatus of the pod, including the information of
// GetAPIPodStatus retrieves the api.PodStatus of the pod, including the information of
...
...
pkg/kubelet/dockertools/manager.go
View file @
2ea11690
...
@@ -1749,7 +1749,7 @@ func (dm *DockerManager) clearReasonCache(pod *api.Pod, container *api.Container
...
@@ -1749,7 +1749,7 @@ func (dm *DockerManager) clearReasonCache(pod *api.Pod, container *api.Container
}
}
// Sync the running pod to match the specified desired pod.
// Sync the running pod to match the specified desired pod.
func
(
dm
*
DockerManager
)
SyncPod
(
pod
*
api
.
Pod
,
_
kubecontainer
.
Pod
,
_
api
.
PodStatus
,
podStatus
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
func
(
dm
*
DockerManager
)
SyncPod
(
pod
*
api
.
Pod
,
_
api
.
PodStatus
,
podStatus
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
metrics
.
ContainerManagerLatency
.
WithLabelValues
(
"SyncPod"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
metrics
.
ContainerManagerLatency
.
WithLabelValues
(
"SyncPod"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
...
...
pkg/kubelet/dockertools/manager_test.go
View file @
2ea11690
...
@@ -542,12 +542,6 @@ func generatePodInfraContainerHash(pod *api.Pod) uint64 {
...
@@ -542,12 +542,6 @@ func generatePodInfraContainerHash(pod *api.Pod) uint64 {
// runSyncPod is a helper function to retrieve the running pods from the fake
// runSyncPod is a helper function to retrieve the running pods from the fake
// docker client and runs SyncPod for the given pod.
// docker client and runs SyncPod for the given pod.
func
runSyncPod
(
t
*
testing
.
T
,
dm
*
DockerManager
,
fakeDocker
*
FakeDockerClient
,
pod
*
api
.
Pod
,
backOff
*
util
.
Backoff
,
expectErr
bool
)
{
func
runSyncPod
(
t
*
testing
.
T
,
dm
*
DockerManager
,
fakeDocker
*
FakeDockerClient
,
pod
*
api
.
Pod
,
backOff
*
util
.
Backoff
,
expectErr
bool
)
{
runningPods
,
err
:=
dm
.
GetPods
(
false
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
runningPod
:=
kubecontainer
.
Pods
(
runningPods
)
.
FindPodByID
(
pod
.
UID
)
podStatus
,
apiPodStatus
,
err
:=
dm
.
GetPodStatusAndAPIPodStatus
(
pod
)
podStatus
,
apiPodStatus
,
err
:=
dm
.
GetPodStatusAndAPIPodStatus
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
@@ -556,7 +550,7 @@ func runSyncPod(t *testing.T, dm *DockerManager, fakeDocker *FakeDockerClient, p
...
@@ -556,7 +550,7 @@ func runSyncPod(t *testing.T, dm *DockerManager, fakeDocker *FakeDockerClient, p
if
backOff
==
nil
{
if
backOff
==
nil
{
backOff
=
util
.
NewBackOff
(
time
.
Second
,
time
.
Minute
)
backOff
=
util
.
NewBackOff
(
time
.
Second
,
time
.
Minute
)
}
}
err
=
dm
.
SyncPod
(
pod
,
runningPod
,
*
apiPodStatus
,
podStatus
,
[]
api
.
Secret
{},
backOff
)
err
=
dm
.
SyncPod
(
pod
,
*
apiPodStatus
,
podStatus
,
[]
api
.
Secret
{},
backOff
)
if
err
!=
nil
&&
!
expectErr
{
if
err
!=
nil
&&
!
expectErr
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
else
if
err
==
nil
&&
expectErr
{
}
else
if
err
==
nil
&&
expectErr
{
...
...
pkg/kubelet/kubelet.go
View file @
2ea11690
...
@@ -1741,7 +1741,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
...
@@ -1741,7 +1741,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
return
err
return
err
}
}
err
=
kl
.
containerRuntime
.
SyncPod
(
pod
,
runningPod
,
apiPodStatus
,
podStatus
,
pullSecrets
,
kl
.
backOff
)
err
=
kl
.
containerRuntime
.
SyncPod
(
pod
,
apiPodStatus
,
podStatus
,
pullSecrets
,
kl
.
backOff
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubelet/rkt/rkt.go
View file @
2ea11690
...
@@ -938,7 +938,11 @@ func (r *Runtime) Version() (kubecontainer.Version, error) {
...
@@ -938,7 +938,11 @@ func (r *Runtime) Version() (kubecontainer.Version, error) {
}
}
// SyncPod syncs the running pod to match the specified desired pod.
// SyncPod syncs the running pod to match the specified desired pod.
func
(
r
*
Runtime
)
SyncPod
(
pod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
podStatus
api
.
PodStatus
,
_
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
func
(
r
*
Runtime
)
SyncPod
(
pod
*
api
.
Pod
,
podStatus
api
.
PodStatus
,
internalPodStatus
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
// TODO: (random-liu) Stop using running pod in SyncPod()
// TODO: (random-liu) Rename podStatus to apiPodStatus, rename internalPodStatus to podStatus, and use new pod status as much as possible,
// we may stop using apiPodStatus someday.
runningPod
:=
kubecontainer
.
ConvertPodStatusToRunningPod
(
internalPodStatus
)
// Add references to all containers.
// Add references to all containers.
unidentifiedContainers
:=
make
(
map
[
kubecontainer
.
ContainerID
]
*
kubecontainer
.
Container
)
unidentifiedContainers
:=
make
(
map
[
kubecontainer
.
ContainerID
]
*
kubecontainer
.
Container
)
for
_
,
c
:=
range
runningPod
.
Containers
{
for
_
,
c
:=
range
runningPod
.
Containers
{
...
...
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