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
e93febfd
Commit
e93febfd
authored
Jan 12, 2016
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start returning PodSyncResult in SyncPod
parent
e953f4a0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
20 deletions
+28
-20
fake_runtime.go
pkg/kubelet/container/fake_runtime.go
+6
-2
runtime.go
pkg/kubelet/container/runtime.go
+2
-1
runtime_mock.go
pkg/kubelet/container/runtime_mock.go
+2
-2
manager.go
pkg/kubelet/dockertools/manager.go
+1
-7
manager_test.go
pkg/kubelet/dockertools/manager_test.go
+3
-1
kubelet.go
pkg/kubelet/kubelet.go
+2
-1
rkt.go
pkg/kubelet/rkt/rkt.go
+12
-6
No files found.
pkg/kubelet/container/fake_runtime.go
View file @
e93febfd
...
...
@@ -174,7 +174,7 @@ func (f *FakeRuntime) GetPods(all bool) ([]*Pod, error) {
return
f
.
PodList
,
f
.
Err
}
func
(
f
*
FakeRuntime
)
SyncPod
(
pod
*
api
.
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
)
(
result
PodSyncResult
)
{
f
.
Lock
()
defer
f
.
Unlock
()
...
...
@@ -183,7 +183,11 @@ func (f *FakeRuntime) SyncPod(pod *api.Pod, _ api.PodStatus, _ *PodStatus, _ []a
for
_
,
c
:=
range
pod
.
Spec
.
Containers
{
f
.
StartedContainers
=
append
(
f
.
StartedContainers
,
c
.
Name
)
}
return
f
.
Err
// TODO(random-liu): Add SyncResult for starting and killing containers
if
f
.
Err
!=
nil
{
result
.
Fail
(
f
.
Err
)
}
return
}
func
(
f
*
FakeRuntime
)
KillPod
(
pod
*
api
.
Pod
,
runningPod
Pod
)
error
{
...
...
pkg/kubelet/container/runtime.go
View file @
e93febfd
...
...
@@ -65,8 +65,9 @@ type Runtime interface {
// GarbageCollect removes dead containers using the specified container gc policy
GarbageCollect
(
gcPolicy
ContainerGCPolicy
)
error
// Syncs the running pod into the desired pod.
SyncPod
(
pod
*
api
.
Pod
,
apiPodStatus
api
.
PodStatus
,
podStatus
*
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
SyncPod
(
pod
*
api
.
Pod
,
apiPodStatus
api
.
PodStatus
,
podStatus
*
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
PodSyncResult
// KillPod kills all the containers of a pod. Pod may be nil, running pod must not be.
// TODO(random-liu): Return PodSyncResult in KillPod.
KillPod
(
pod
*
api
.
Pod
,
runningPod
Pod
)
error
// GetAPIPodStatus retrieves the api.PodStatus of the pod, including the information of
// all containers in the pod. Clients of this interface assume the
...
...
pkg/kubelet/container/runtime_mock.go
View file @
e93febfd
...
...
@@ -57,9 +57,9 @@ func (r *Mock) GetPods(all bool) ([]*Pod, error) {
return
args
.
Get
(
0
)
.
([]
*
Pod
),
args
.
Error
(
1
)
}
func
(
r
*
Mock
)
SyncPod
(
pod
*
api
.
Pod
,
apiStatus
api
.
PodStatus
,
status
*
PodStatus
,
secrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
func
(
r
*
Mock
)
SyncPod
(
pod
*
api
.
Pod
,
apiStatus
api
.
PodStatus
,
status
*
PodStatus
,
secrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
PodSyncResult
{
args
:=
r
.
Called
(
pod
,
apiStatus
,
status
,
secrets
,
backOff
)
return
args
.
Error
(
0
)
return
args
.
Get
(
0
)
.
(
PodSyncResult
)
}
func
(
r
*
Mock
)
KillPod
(
pod
*
api
.
Pod
,
runningPod
Pod
)
error
{
...
...
pkg/kubelet/dockertools/manager.go
View file @
e93febfd
...
...
@@ -1814,13 +1814,7 @@ func (dm *DockerManager) clearReasonCache(pod *api.Pod, container *api.Container
}
// Sync the running pod to match the specified desired pod.
func
(
dm
*
DockerManager
)
SyncPod
(
pod
*
api
.
Pod
,
apiPodStatus
api
.
PodStatus
,
podStatus
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
result
:=
dm
.
syncPodWithSyncResult
(
pod
,
apiPodStatus
,
podStatus
,
pullSecrets
,
backOff
)
return
result
.
Error
()
}
// (random-liu) This is just a temporary function, will be removed when we acturally add PodSyncEvent
func
(
dm
*
DockerManager
)
syncPodWithSyncResult
(
pod
*
api
.
Pod
,
_
api
.
PodStatus
,
podStatus
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
(
result
kubecontainer
.
PodSyncResult
)
{
func
(
dm
*
DockerManager
)
SyncPod
(
pod
*
api
.
Pod
,
_
api
.
PodStatus
,
podStatus
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
(
result
kubecontainer
.
PodSyncResult
)
{
start
:=
time
.
Now
()
defer
func
()
{
metrics
.
ContainerManagerLatency
.
WithLabelValues
(
"SyncPod"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
...
...
pkg/kubelet/dockertools/manager_test.go
View file @
e93febfd
...
...
@@ -551,7 +551,9 @@ func runSyncPod(t *testing.T, dm *DockerManager, fakeDocker *FakeDockerClient, p
if
backOff
==
nil
{
backOff
=
util
.
NewBackOff
(
time
.
Second
,
time
.
Minute
)
}
err
=
dm
.
SyncPod
(
pod
,
*
apiPodStatus
,
podStatus
,
[]
api
.
Secret
{},
backOff
)
//TODO(random-liu): Add test for PodSyncResult
result
:=
dm
.
SyncPod
(
pod
,
*
apiPodStatus
,
podStatus
,
[]
api
.
Secret
{},
backOff
)
err
=
result
.
Error
()
if
err
!=
nil
&&
!
expectErr
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
else
if
err
==
nil
&&
expectErr
{
...
...
pkg/kubelet/kubelet.go
View file @
e93febfd
...
...
@@ -1675,7 +1675,8 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
return
err
}
err
=
kl
.
containerRuntime
.
SyncPod
(
pod
,
apiPodStatus
,
podStatus
,
pullSecrets
,
kl
.
backOff
)
result
:=
kl
.
containerRuntime
.
SyncPod
(
pod
,
apiPodStatus
,
podStatus
,
pullSecrets
,
kl
.
backOff
)
err
=
result
.
Error
()
if
err
!=
nil
{
return
err
}
...
...
pkg/kubelet/rkt/rkt.go
View file @
e93febfd
...
...
@@ -976,7 +976,13 @@ func (r *Runtime) APIVersion() (kubecontainer.Version, error) {
}
// SyncPod syncs the running pod to match the specified desired pod.
func
(
r
*
Runtime
)
SyncPod
(
pod
*
api
.
Pod
,
podStatus
api
.
PodStatus
,
internalPodStatus
*
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
)
(
result
kubecontainer
.
PodSyncResult
)
{
var
err
error
defer
func
()
{
if
err
!=
nil
{
result
.
Fail
(
err
)
}
}()
// 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.
...
...
@@ -1031,15 +1037,15 @@ func (r *Runtime) SyncPod(pod *api.Pod, podStatus api.PodStatus, internalPodStat
if
restartPod
{
// Kill the pod only if the pod is actually running.
if
len
(
runningPod
.
Containers
)
>
0
{
if
err
:
=
r
.
KillPod
(
pod
,
runningPod
);
err
!=
nil
{
return
err
if
err
=
r
.
KillPod
(
pod
,
runningPod
);
err
!=
nil
{
return
}
}
if
err
:
=
r
.
RunPod
(
pod
,
pullSecrets
);
err
!=
nil
{
return
err
if
err
=
r
.
RunPod
(
pod
,
pullSecrets
);
err
!=
nil
{
return
}
}
return
nil
return
}
// GarbageCollect collects the pods/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