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
db7e5247
Commit
db7e5247
authored
Jan 29, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19850 from yujuhong/enable_cache
Auto commit by PR queue bot
parents
deef16d2
cfb5442b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
+26
-5
kubelet.go
pkg/kubelet/kubelet.go
+0
-0
pod_workers.go
pkg/kubelet/pod_workers.go
+24
-4
pod_workers_test.go
pkg/kubelet/pod_workers_test.go
+2
-1
No files found.
pkg/kubelet/kubelet.go
View file @
db7e5247
This diff is collapsed.
Click to expand it.
pkg/kubelet/pod_workers.go
View file @
db7e5247
...
@@ -71,6 +71,9 @@ type podWorkers struct {
...
@@ -71,6 +71,9 @@ type podWorkers struct {
// resyncInterval is the duration to wait until the next sync.
// resyncInterval is the duration to wait until the next sync.
resyncInterval
time
.
Duration
resyncInterval
time
.
Duration
// podCache stores kubecontainer.PodStatus for all pods.
podCache
kubecontainer
.
Cache
}
}
type
workUpdate
struct
{
type
workUpdate
struct
{
...
@@ -88,7 +91,7 @@ type workUpdate struct {
...
@@ -88,7 +91,7 @@ type workUpdate struct {
}
}
func
newPodWorkers
(
runtimeCache
kubecontainer
.
RuntimeCache
,
syncPodFn
syncPodFnType
,
func
newPodWorkers
(
runtimeCache
kubecontainer
.
RuntimeCache
,
syncPodFn
syncPodFnType
,
recorder
record
.
EventRecorder
,
workQueue
queue
.
WorkQueue
,
resyncInterval
,
backOffPeriod
time
.
Duration
)
*
podWorkers
{
recorder
record
.
EventRecorder
,
workQueue
queue
.
WorkQueue
,
resyncInterval
,
backOffPeriod
time
.
Duration
,
podCache
kubecontainer
.
Cache
)
*
podWorkers
{
return
&
podWorkers
{
return
&
podWorkers
{
podUpdates
:
map
[
types
.
UID
]
chan
workUpdate
{},
podUpdates
:
map
[
types
.
UID
]
chan
workUpdate
{},
isWorking
:
map
[
types
.
UID
]
bool
{},
isWorking
:
map
[
types
.
UID
]
bool
{},
...
@@ -99,13 +102,27 @@ func newPodWorkers(runtimeCache kubecontainer.RuntimeCache, syncPodFn syncPodFnT
...
@@ -99,13 +102,27 @@ func newPodWorkers(runtimeCache kubecontainer.RuntimeCache, syncPodFn syncPodFnT
workQueue
:
workQueue
,
workQueue
:
workQueue
,
resyncInterval
:
resyncInterval
,
resyncInterval
:
resyncInterval
,
backOffPeriod
:
backOffPeriod
,
backOffPeriod
:
backOffPeriod
,
podCache
:
podCache
,
}
}
}
}
func
(
p
*
podWorkers
)
managePodLoop
(
podUpdates
<-
chan
workUpdate
)
{
func
(
p
*
podWorkers
)
managePodLoop
(
podUpdates
<-
chan
workUpdate
)
{
var
minRuntimeCacheTime
time
.
Time
var
minRuntimeCacheTime
time
.
Time
for
newWork
:=
range
podUpdates
{
for
newWork
:=
range
podUpdates
{
err
:=
func
()
(
err
error
)
{
err
:=
func
()
(
err
error
)
{
podID
:=
newWork
.
pod
.
UID
if
p
.
podCache
!=
nil
{
// This is a blocking call that would return only if the cache
// has an entry for the pod that is newer than minRuntimeCache
// Time. This ensures the worker doesn't start syncing until
// after the cache is at least newer than the finished time of
// the previous sync.
// TODO: We don't consume the return PodStatus yet, but we
// should pass it to syncPod() eventually.
p
.
podCache
.
GetNewerThan
(
podID
,
minRuntimeCacheTime
)
}
// TODO: Deprecate the runtime cache.
// We would like to have the state of the containers from at least
// We would like to have the state of the containers from at least
// the moment when we finished the previous processing of that pod.
// the moment when we finished the previous processing of that pod.
if
err
:=
p
.
runtimeCache
.
ForceUpdateIfOlder
(
minRuntimeCacheTime
);
err
!=
nil
{
if
err
:=
p
.
runtimeCache
.
ForceUpdateIfOlder
(
minRuntimeCacheTime
);
err
!=
nil
{
...
@@ -206,10 +223,13 @@ func (p *podWorkers) ForgetNonExistingPodWorkers(desiredPods map[types.UID]empty
...
@@ -206,10 +223,13 @@ func (p *podWorkers) ForgetNonExistingPodWorkers(desiredPods map[types.UID]empty
func
(
p
*
podWorkers
)
wrapUp
(
uid
types
.
UID
,
syncErr
error
)
{
func
(
p
*
podWorkers
)
wrapUp
(
uid
types
.
UID
,
syncErr
error
)
{
// Requeue the last update if the last sync returned error.
// Requeue the last update if the last sync returned error.
if
syncErr
!=
nil
{
switch
{
p
.
workQueue
.
Enqueue
(
uid
,
p
.
backOffPeriod
)
case
syncErr
==
nil
:
}
else
{
// No error; requeue at the regular resync interval.
p
.
workQueue
.
Enqueue
(
uid
,
p
.
resyncInterval
)
p
.
workQueue
.
Enqueue
(
uid
,
p
.
resyncInterval
)
default
:
// Error occurred during the sync; back off and then retry.
p
.
workQueue
.
Enqueue
(
uid
,
p
.
backOffPeriod
)
}
}
p
.
checkForUpdates
(
uid
)
p
.
checkForUpdates
(
uid
)
}
}
...
...
pkg/kubelet/pod_workers_test.go
View file @
db7e5247
...
@@ -60,6 +60,7 @@ func createPodWorkers() (*podWorkers, map[types.UID][]string) {
...
@@ -60,6 +60,7 @@ func createPodWorkers() (*podWorkers, map[types.UID][]string) {
queue
.
NewBasicWorkQueue
(),
queue
.
NewBasicWorkQueue
(),
time
.
Second
,
time
.
Second
,
time
.
Second
,
time
.
Second
,
nil
,
)
)
return
podWorkers
,
processed
return
podWorkers
,
processed
}
}
...
@@ -190,7 +191,7 @@ func TestFakePodWorkers(t *testing.T) {
...
@@ -190,7 +191,7 @@ func TestFakePodWorkers(t *testing.T) {
kubeletForRealWorkers
:=
&
simpleFakeKubelet
{}
kubeletForRealWorkers
:=
&
simpleFakeKubelet
{}
kubeletForFakeWorkers
:=
&
simpleFakeKubelet
{}
kubeletForFakeWorkers
:=
&
simpleFakeKubelet
{}
realPodWorkers
:=
newPodWorkers
(
fakeRuntimeCache
,
kubeletForRealWorkers
.
syncPodWithWaitGroup
,
fakeRecorder
,
queue
.
NewBasicWorkQueue
(),
time
.
Second
,
time
.
Second
)
realPodWorkers
:=
newPodWorkers
(
fakeRuntimeCache
,
kubeletForRealWorkers
.
syncPodWithWaitGroup
,
fakeRecorder
,
queue
.
NewBasicWorkQueue
(),
time
.
Second
,
time
.
Second
,
nil
)
fakePodWorkers
:=
&
fakePodWorkers
{
kubeletForFakeWorkers
.
syncPod
,
fakeRuntimeCache
,
t
}
fakePodWorkers
:=
&
fakePodWorkers
{
kubeletForFakeWorkers
.
syncPod
,
fakeRuntimeCache
,
t
}
tests
:=
[]
struct
{
tests
:=
[]
struct
{
...
...
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