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
ca9e209c
Commit
ca9e209c
authored
Apr 14, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6795 from yifan-gu/cache
kubelet/container: Replace DockerCache with RuntimeCache.
parents
190e6df4
e1feed9a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
177 deletions
+43
-177
fake_runtime.go
pkg/kubelet/container/fake_runtime.go
+4
-4
runtime_cache.go
pkg/kubelet/container/runtime_cache.go
+12
-12
docker_cache.go
pkg/kubelet/dockertools/docker_cache.go
+0
-115
fake_docker_client.go
pkg/kubelet/dockertools/fake_docker_client.go
+0
-18
kubelet.go
pkg/kubelet/kubelet.go
+6
-6
kubelet_test.go
pkg/kubelet/kubelet_test.go
+2
-2
metrics.go
pkg/kubelet/metrics/metrics.go
+4
-4
pod_workers.go
pkg/kubelet/pod_workers.go
+11
-12
pod_workers_test.go
pkg/kubelet/pod_workers_test.go
+4
-4
No files found.
pkg/kubelet/container/fake_runtime.go
View file @
ca9e209c
...
@@ -42,15 +42,15 @@ type FakeRuntime struct {
...
@@ -42,15 +42,15 @@ type FakeRuntime struct {
}
}
type
FakeRuntimeCache
struct
{
type
FakeRuntimeCache
struct
{
runtime
Runtime
getter
podsGetter
}
}
func
NewFakeRuntimeCache
(
runtime
Runtime
)
RuntimeCache
{
func
NewFakeRuntimeCache
(
getter
podsGetter
)
RuntimeCache
{
return
&
FakeRuntimeCache
{
runtime
}
return
&
FakeRuntimeCache
{
getter
}
}
}
func
(
f
*
FakeRuntimeCache
)
GetPods
()
([]
*
Pod
,
error
)
{
func
(
f
*
FakeRuntimeCache
)
GetPods
()
([]
*
Pod
,
error
)
{
return
f
.
runtime
.
GetPods
(
false
)
return
f
.
getter
.
GetPods
(
false
)
}
}
func
(
f
*
FakeRuntimeCache
)
ForceUpdateIfOlder
(
time
.
Time
)
error
{
func
(
f
*
FakeRuntimeCache
)
ForceUpdateIfOlder
(
time
.
Time
)
error
{
...
...
pkg/kubelet/container/runtime_cache.go
View file @
ca9e209c
...
@@ -32,24 +32,24 @@ type RuntimeCache interface {
...
@@ -32,24 +32,24 @@ type RuntimeCache interface {
ForceUpdateIfOlder
(
time
.
Time
)
error
ForceUpdateIfOlder
(
time
.
Time
)
error
}
}
// TODO(yifan): This interface can be removed once docker manager has implemented
// all the runtime interfaces, (thus we can pass the runtime directly).
type
podsGetter
interface
{
GetPods
(
bool
)
([]
*
Pod
,
error
)
}
// NewRuntimeCache creates a container runtime cache.
// NewRuntimeCache creates a container runtime cache.
func
NewRuntimeCache
(
runtime
Runtime
)
(
RuntimeCache
,
error
)
{
func
NewRuntimeCache
(
getter
podsGetter
)
(
RuntimeCache
,
error
)
{
pods
,
err
:=
runtime
.
GetPods
(
false
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
runtimeCache
{
return
&
runtimeCache
{
runtime
:
runtime
,
getter
:
getter
,
cacheTime
:
time
.
Now
(),
updating
:
false
,
pods
:
pods
,
updating
:
false
,
},
nil
},
nil
}
}
type
runtimeCache
struct
{
type
runtimeCache
struct
{
sync
.
Mutex
sync
.
Mutex
// The underlying container runtime used to update the cache.
// The underlying container runtime used to update the cache.
runtime
Runtime
getter
podsGetter
// Last time when cache was updated.
// Last time when cache was updated.
cacheTime
time
.
Time
cacheTime
time
.
Time
// The content of the cache.
// The content of the cache.
...
@@ -90,7 +90,7 @@ func (r *runtimeCache) ForceUpdateIfOlder(minExpectedCacheTime time.Time) error
...
@@ -90,7 +90,7 @@ func (r *runtimeCache) ForceUpdateIfOlder(minExpectedCacheTime time.Time) error
}
}
func
(
r
*
runtimeCache
)
updateCache
()
error
{
func
(
r
*
runtimeCache
)
updateCache
()
error
{
pods
,
err
:=
r
.
runtime
.
GetPods
(
false
)
pods
,
err
:=
r
.
getter
.
GetPods
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -105,7 +105,7 @@ func (r *runtimeCache) startUpdatingCache() {
...
@@ -105,7 +105,7 @@ func (r *runtimeCache) startUpdatingCache() {
run
:=
true
run
:=
true
for
run
{
for
run
{
time
.
Sleep
(
defaultUpdateInterval
)
time
.
Sleep
(
defaultUpdateInterval
)
pods
,
err
:=
r
.
runtime
.
GetPods
(
false
)
pods
,
err
:=
r
.
getter
.
GetPods
(
false
)
cacheTime
:=
time
.
Now
()
cacheTime
:=
time
.
Now
()
if
err
!=
nil
{
if
err
!=
nil
{
continue
continue
...
...
pkg/kubelet/dockertools/docker_cache.go
deleted
100644 → 0
View file @
190e6df4
/*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
dockertools
import
(
"sync"
"time"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
)
type
DockerCache
interface
{
GetPods
()
([]
*
kubecontainer
.
Pod
,
error
)
ForceUpdateIfOlder
(
time
.
Time
)
error
}
type
podsGetter
interface
{
GetPods
(
bool
)
([]
*
kubecontainer
.
Pod
,
error
)
}
func
NewDockerCache
(
getter
podsGetter
)
(
DockerCache
,
error
)
{
return
&
dockerCache
{
getter
:
getter
,
updatingCache
:
false
,
},
nil
}
// dockerCache is a default implementation of DockerCache interface
// TODO(yifan): Use runtime cache to replace this.
type
dockerCache
struct
{
// The narrowed interface for updating the cache.
getter
podsGetter
// Mutex protecting all of the following fields.
lock
sync
.
Mutex
// Last time when cache was updated.
cacheTime
time
.
Time
// The content of the cache.
pods
[]
*
kubecontainer
.
Pod
// Whether the background thread updating the cache is running.
updatingCache
bool
// Time when the background thread should be stopped.
updatingThreadStopTime
time
.
Time
}
// Ensure that dockerCache abides by the DockerCache interface.
var
_
DockerCache
=
new
(
dockerCache
)
func
(
d
*
dockerCache
)
GetPods
()
([]
*
kubecontainer
.
Pod
,
error
)
{
d
.
lock
.
Lock
()
defer
d
.
lock
.
Unlock
()
if
time
.
Since
(
d
.
cacheTime
)
>
2
*
time
.
Second
{
pods
,
err
:=
d
.
getter
.
GetPods
(
false
)
if
err
!=
nil
{
return
pods
,
err
}
d
.
pods
=
pods
d
.
cacheTime
=
time
.
Now
()
}
// Stop refreshing thread if there were no requests within last 2 seconds.
d
.
updatingThreadStopTime
=
time
.
Now
()
.
Add
(
time
.
Duration
(
2
)
*
time
.
Second
)
if
!
d
.
updatingCache
{
d
.
updatingCache
=
true
go
d
.
startUpdatingCache
()
}
return
d
.
pods
,
nil
}
func
(
d
*
dockerCache
)
ForceUpdateIfOlder
(
minExpectedCacheTime
time
.
Time
)
error
{
d
.
lock
.
Lock
()
defer
d
.
lock
.
Unlock
()
if
d
.
cacheTime
.
Before
(
minExpectedCacheTime
)
{
pods
,
err
:=
d
.
getter
.
GetPods
(
false
)
if
err
!=
nil
{
return
err
}
d
.
pods
=
pods
d
.
cacheTime
=
time
.
Now
()
}
return
nil
}
func
(
d
*
dockerCache
)
startUpdatingCache
()
{
run
:=
true
for
run
{
time
.
Sleep
(
100
*
time
.
Millisecond
)
pods
,
err
:=
d
.
getter
.
GetPods
(
false
)
cacheTime
:=
time
.
Now
()
if
err
!=
nil
{
continue
}
d
.
lock
.
Lock
()
if
time
.
Now
()
.
After
(
d
.
updatingThreadStopTime
)
{
d
.
updatingCache
=
false
run
=
false
}
d
.
pods
=
pods
d
.
cacheTime
=
cacheTime
d
.
lock
.
Unlock
()
}
}
pkg/kubelet/dockertools/fake_docker_client.go
View file @
ca9e209c
...
@@ -22,9 +22,7 @@ import (
...
@@ -22,9 +22,7 @@ import (
"reflect"
"reflect"
"sort"
"sort"
"sync"
"sync"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/fsouza/go-dockerclient"
"github.com/fsouza/go-dockerclient"
)
)
...
@@ -333,19 +331,3 @@ func (f *FakeDockerPuller) IsImagePresent(name string) (bool, error) {
...
@@ -333,19 +331,3 @@ func (f *FakeDockerPuller) IsImagePresent(name string) (bool, error) {
}
}
return
false
,
nil
return
false
,
nil
}
}
type
FakeDockerCache
struct
{
getter
podsGetter
}
func
NewFakeDockerCache
(
getter
podsGetter
)
DockerCache
{
return
&
FakeDockerCache
{
getter
:
getter
}
}
func
(
f
*
FakeDockerCache
)
GetPods
()
([]
*
container
.
Pod
,
error
)
{
return
f
.
getter
.
GetPods
(
false
)
}
func
(
f
*
FakeDockerCache
)
ForceUpdateIfOlder
(
time
.
Time
)
error
{
return
nil
}
pkg/kubelet/kubelet.go
View file @
ca9e209c
...
@@ -232,14 +232,14 @@ func NewMainKubelet(
...
@@ -232,14 +232,14 @@ func NewMainKubelet(
klet
.
podManager
=
newBasicPodManager
(
klet
.
kubeClient
)
klet
.
podManager
=
newBasicPodManager
(
klet
.
kubeClient
)
dockerCache
,
err
:=
dockertools
.
NewDocker
Cache
(
containerManager
)
runtimeCache
,
err
:=
kubecontainer
.
NewRuntime
Cache
(
containerManager
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
klet
.
dockerCache
=
docker
Cache
klet
.
runtimeCache
=
runtime
Cache
klet
.
podWorkers
=
newPodWorkers
(
docker
Cache
,
klet
.
syncPod
,
recorder
)
klet
.
podWorkers
=
newPodWorkers
(
runtime
Cache
,
klet
.
syncPod
,
recorder
)
metrics
.
Register
(
docker
Cache
)
metrics
.
Register
(
runtime
Cache
)
if
err
=
klet
.
setupDataDirs
();
err
!=
nil
{
if
err
=
klet
.
setupDataDirs
();
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -274,7 +274,7 @@ type nodeLister interface {
...
@@ -274,7 +274,7 @@ type nodeLister interface {
type
Kubelet
struct
{
type
Kubelet
struct
{
hostname
string
hostname
string
dockerClient
dockertools
.
DockerInterface
dockerClient
dockertools
.
DockerInterface
dockerCache
dockertools
.
Docker
Cache
runtimeCache
kubecontainer
.
Runtime
Cache
kubeClient
client
.
Interface
kubeClient
client
.
Interface
rootDirectory
string
rootDirectory
string
podWorkers
*
podWorkers
podWorkers
*
podWorkers
...
@@ -1396,7 +1396,7 @@ func (kl *Kubelet) SyncPods(allPods []api.Pod, podSyncTypes map[types.UID]metric
...
@@ -1396,7 +1396,7 @@ func (kl *Kubelet) SyncPods(allPods []api.Pod, podSyncTypes map[types.UID]metric
var
err
error
var
err
error
desiredPods
:=
make
(
map
[
types
.
UID
]
empty
)
desiredPods
:=
make
(
map
[
types
.
UID
]
empty
)
runningPods
,
err
:=
kl
.
docker
Cache
.
GetPods
()
runningPods
,
err
:=
kl
.
runtime
Cache
.
GetPods
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error listing containers: %#v"
,
err
)
glog
.
Errorf
(
"Error listing containers: %#v"
,
err
)
return
err
return
err
...
...
pkg/kubelet/kubelet_test.go
View file @
ca9e209c
...
@@ -103,9 +103,9 @@ func newTestKubelet(t *testing.T) *TestKubelet {
...
@@ -103,9 +103,9 @@ func newTestKubelet(t *testing.T) *TestKubelet {
kubelet
.
podManager
=
podManager
kubelet
.
podManager
=
podManager
kubelet
.
containerRefManager
=
kubecontainer
.
NewRefManager
()
kubelet
.
containerRefManager
=
kubecontainer
.
NewRefManager
()
kubelet
.
containerManager
=
dockertools
.
NewDockerManager
(
fakeDocker
,
fakeRecorder
,
dockertools
.
PodInfraContainerImage
,
0
,
0
)
kubelet
.
containerManager
=
dockertools
.
NewDockerManager
(
fakeDocker
,
fakeRecorder
,
dockertools
.
PodInfraContainerImage
,
0
,
0
)
kubelet
.
dockerCache
=
dockertools
.
NewFakeDocker
Cache
(
kubelet
.
containerManager
)
kubelet
.
runtimeCache
=
kubecontainer
.
NewFakeRuntime
Cache
(
kubelet
.
containerManager
)
kubelet
.
podWorkers
=
newPodWorkers
(
kubelet
.
podWorkers
=
newPodWorkers
(
kubelet
.
docker
Cache
,
kubelet
.
runtime
Cache
,
func
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
container
.
Pod
)
error
{
func
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
container
.
Pod
)
error
{
err
:=
kubelet
.
syncPod
(
pod
,
mirrorPod
,
runningPod
)
err
:=
kubelet
.
syncPod
(
pod
,
mirrorPod
,
runningPod
)
waitGroup
.
Done
()
waitGroup
.
Done
()
...
...
pkg/kubelet/metrics/metrics.go
View file @
ca9e209c
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"sync"
"sync"
"time"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools
"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container
"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus"
)
)
...
@@ -70,7 +70,7 @@ var (
...
@@ -70,7 +70,7 @@ var (
var
registerMetrics
sync
.
Once
var
registerMetrics
sync
.
Once
// Register all metrics.
// Register all metrics.
func
Register
(
containerCache
dockertools
.
Docker
Cache
)
{
func
Register
(
containerCache
kubecontainer
.
Runtime
Cache
)
{
// Register the metrics.
// Register the metrics.
registerMetrics
.
Do
(
func
()
{
registerMetrics
.
Do
(
func
()
{
prometheus
.
MustRegister
(
ImagePullLatency
)
prometheus
.
MustRegister
(
ImagePullLatency
)
...
@@ -108,7 +108,7 @@ func SinceInMicroseconds(start time.Time) float64 {
...
@@ -108,7 +108,7 @@ func SinceInMicroseconds(start time.Time) float64 {
return
float64
(
time
.
Since
(
start
)
.
Nanoseconds
()
/
time
.
Microsecond
.
Nanoseconds
())
return
float64
(
time
.
Since
(
start
)
.
Nanoseconds
()
/
time
.
Microsecond
.
Nanoseconds
())
}
}
func
newPodAndContainerCollector
(
containerCache
dockertools
.
Docker
Cache
)
*
podAndContainerCollector
{
func
newPodAndContainerCollector
(
containerCache
kubecontainer
.
Runtime
Cache
)
*
podAndContainerCollector
{
return
&
podAndContainerCollector
{
return
&
podAndContainerCollector
{
containerCache
:
containerCache
,
containerCache
:
containerCache
,
}
}
...
@@ -117,7 +117,7 @@ func newPodAndContainerCollector(containerCache dockertools.DockerCache) *podAnd
...
@@ -117,7 +117,7 @@ func newPodAndContainerCollector(containerCache dockertools.DockerCache) *podAnd
// Custom collector for current pod and container counts.
// Custom collector for current pod and container counts.
type
podAndContainerCollector
struct
{
type
podAndContainerCollector
struct
{
// Cache for accessing information about running containers.
// Cache for accessing information about running containers.
containerCache
dockertools
.
Docker
Cache
containerCache
kubecontainer
.
Runtime
Cache
}
}
// TODO(vmarmol): Split by source?
// TODO(vmarmol): Split by source?
...
...
pkg/kubelet/pod_workers.go
View file @
ca9e209c
...
@@ -22,14 +22,13 @@ import (
...
@@ -22,14 +22,13 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
type
syncPodFnType
func
(
*
api
.
Pod
,
*
api
.
Pod
,
container
.
Pod
)
error
type
syncPodFnType
func
(
*
api
.
Pod
,
*
api
.
Pod
,
kube
container
.
Pod
)
error
type
podWorkers
struct
{
type
podWorkers
struct
{
// Protects all per worker fields.
// Protects all per worker fields.
...
@@ -45,8 +44,8 @@ type podWorkers struct {
...
@@ -45,8 +44,8 @@ type podWorkers struct {
// Tracks the last undelivered work item for this pod - a work item is
// Tracks the last undelivered work item for this pod - a work item is
// undelivered if it comes in while the worker is working.
// undelivered if it comes in while the worker is working.
lastUndeliveredWorkUpdate
map
[
types
.
UID
]
workUpdate
lastUndeliveredWorkUpdate
map
[
types
.
UID
]
workUpdate
//
Docker
Cache is used for listing running containers.
//
runtime
Cache is used for listing running containers.
dockerCache
dockertools
.
Docker
Cache
runtimeCache
kubecontainer
.
Runtime
Cache
// This function is run to sync the desired stated of pod.
// This function is run to sync the desired stated of pod.
// NOTE: This function has to be thread-safe - it can be called for
// NOTE: This function has to be thread-safe - it can be called for
...
@@ -68,43 +67,43 @@ type workUpdate struct {
...
@@ -68,43 +67,43 @@ type workUpdate struct {
updateCompleteFn
func
()
updateCompleteFn
func
()
}
}
func
newPodWorkers
(
dockerCache
dockertools
.
Docker
Cache
,
syncPodFn
syncPodFnType
,
func
newPodWorkers
(
runtimeCache
kubecontainer
.
Runtime
Cache
,
syncPodFn
syncPodFnType
,
recorder
record
.
EventRecorder
)
*
podWorkers
{
recorder
record
.
EventRecorder
)
*
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
{},
lastUndeliveredWorkUpdate
:
map
[
types
.
UID
]
workUpdate
{},
lastUndeliveredWorkUpdate
:
map
[
types
.
UID
]
workUpdate
{},
dockerCache
:
docker
Cache
,
runtimeCache
:
runtime
Cache
,
syncPodFn
:
syncPodFn
,
syncPodFn
:
syncPodFn
,
recorder
:
recorder
,
recorder
:
recorder
,
}
}
}
}
func
(
p
*
podWorkers
)
managePodLoop
(
podUpdates
<-
chan
workUpdate
)
{
func
(
p
*
podWorkers
)
managePodLoop
(
podUpdates
<-
chan
workUpdate
)
{
var
min
Docker
CacheTime
time
.
Time
var
min
Runtime
CacheTime
time
.
Time
for
newWork
:=
range
podUpdates
{
for
newWork
:=
range
podUpdates
{
func
()
{
func
()
{
defer
p
.
checkForUpdates
(
newWork
.
pod
.
UID
,
newWork
.
updateCompleteFn
)
defer
p
.
checkForUpdates
(
newWork
.
pod
.
UID
,
newWork
.
updateCompleteFn
)
// We would like to have the state of Docker from at least the moment
// We would like to have the state of Docker from at least the moment
// when we finished the previous processing of that pod.
// when we finished the previous processing of that pod.
if
err
:=
p
.
dockerCache
.
ForceUpdateIfOlder
(
minDocker
CacheTime
);
err
!=
nil
{
if
err
:=
p
.
runtimeCache
.
ForceUpdateIfOlder
(
minRuntime
CacheTime
);
err
!=
nil
{
glog
.
Errorf
(
"Error updating docker cache: %v"
,
err
)
glog
.
Errorf
(
"Error updating docker cache: %v"
,
err
)
return
return
}
}
pods
,
err
:=
p
.
docker
Cache
.
GetPods
()
pods
,
err
:=
p
.
runtime
Cache
.
GetPods
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error getting pods while syncing pod: %v"
,
err
)
glog
.
Errorf
(
"Error getting pods while syncing pod: %v"
,
err
)
return
return
}
}
err
=
p
.
syncPodFn
(
newWork
.
pod
,
newWork
.
mirrorPod
,
err
=
p
.
syncPodFn
(
newWork
.
pod
,
newWork
.
mirrorPod
,
container
.
Pods
(
pods
)
.
FindPodByID
(
newWork
.
pod
.
UID
))
kube
container
.
Pods
(
pods
)
.
FindPodByID
(
newWork
.
pod
.
UID
))
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error syncing pod %s, skipping: %v"
,
newWork
.
pod
.
UID
,
err
)
glog
.
Errorf
(
"Error syncing pod %s, skipping: %v"
,
newWork
.
pod
.
UID
,
err
)
p
.
recorder
.
Eventf
(
newWork
.
pod
,
"failedSync"
,
"Error syncing pod, skipping: %v"
,
err
)
p
.
recorder
.
Eventf
(
newWork
.
pod
,
"failedSync"
,
"Error syncing pod, skipping: %v"
,
err
)
return
return
}
}
min
Docker
CacheTime
=
time
.
Now
()
min
Runtime
CacheTime
=
time
.
Now
()
newWork
.
updateCompleteFn
()
newWork
.
updateCompleteFn
()
}()
}()
...
...
pkg/kubelet/pod_workers_test.go
View file @
ca9e209c
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
)
)
...
@@ -40,14 +40,14 @@ func newPod(uid, name string) *api.Pod {
...
@@ -40,14 +40,14 @@ func newPod(uid, name string) *api.Pod {
func
createPodWorkers
()
(
*
podWorkers
,
map
[
types
.
UID
][]
string
)
{
func
createPodWorkers
()
(
*
podWorkers
,
map
[
types
.
UID
][]
string
)
{
fakeDocker
:=
&
dockertools
.
FakeDockerClient
{}
fakeDocker
:=
&
dockertools
.
FakeDockerClient
{}
fakeRecorder
:=
&
record
.
FakeRecorder
{}
fakeRecorder
:=
&
record
.
FakeRecorder
{}
fake
DockerCache
:=
dockertools
.
NewFakeDocker
Cache
(
dockertools
.
NewDockerManager
(
fakeDocker
,
fakeRecorder
,
dockertools
.
PodInfraContainerImage
,
0
,
0
))
fake
RuntimeCache
:=
kubecontainer
.
NewFakeRuntime
Cache
(
dockertools
.
NewDockerManager
(
fakeDocker
,
fakeRecorder
,
dockertools
.
PodInfraContainerImage
,
0
,
0
))
lock
:=
sync
.
Mutex
{}
lock
:=
sync
.
Mutex
{}
processed
:=
make
(
map
[
types
.
UID
][]
string
)
processed
:=
make
(
map
[
types
.
UID
][]
string
)
podWorkers
:=
newPodWorkers
(
podWorkers
:=
newPodWorkers
(
fake
Docker
Cache
,
fake
Runtime
Cache
,
func
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
container
.
Pod
)
error
{
func
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kube
container
.
Pod
)
error
{
func
()
{
func
()
{
lock
.
Lock
()
lock
.
Lock
()
defer
lock
.
Unlock
()
defer
lock
.
Unlock
()
...
...
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