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
a3e60cc3
Commit
a3e60cc3
authored
Oct 09, 2015
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename imported package local name kubeletTypes to kubetypes
According to the naming guidelines, package name should not include mixedCaps.
parent
ac6122c5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
242 additions
and
242 deletions
+242
-242
integration.go
cmd/integration/integration.go
+2
-2
server.go
cmd/kubelet/app/server.go
+12
-12
executor.go
contrib/mesos/pkg/executor/executor.go
+9
-9
executor_test.go
contrib/mesos/pkg/executor/executor_test.go
+6
-6
service.go
contrib/mesos/pkg/executor/service/service.go
+8
-8
scheduler.go
contrib/mesos/pkg/scheduler/scheduler.go
+2
-2
apiserver.go
pkg/kubelet/config/apiserver.go
+2
-2
apiserver_test.go
pkg/kubelet/config/apiserver_test.go
+17
-17
common.go
pkg/kubelet/config/common.go
+2
-2
config.go
pkg/kubelet/config/config.go
+25
-25
config_test.go
pkg/kubelet/config/config_test.go
+0
-0
file.go
pkg/kubelet/config/file.go
+4
-4
file_test.go
pkg/kubelet/config/file_test.go
+8
-8
http.go
pkg/kubelet/config/http.go
+4
-4
http_test.go
pkg/kubelet/config/http_test.go
+10
-10
convert.go
pkg/kubelet/dockertools/convert.go
+2
-2
docker.go
pkg/kubelet/dockertools/docker.go
+3
-3
docker_test.go
pkg/kubelet/dockertools/docker_test.go
+10
-10
fake_manager.go
pkg/kubelet/dockertools/fake_manager.go
+2
-2
manager.go
pkg/kubelet/dockertools/manager.go
+16
-16
fake_pod_workers.go
pkg/kubelet/fake_pod_workers.go
+3
-3
kubelet.go
pkg/kubelet/kubelet.go
+19
-19
kubelet_test.go
pkg/kubelet/kubelet_test.go
+26
-26
handlers.go
pkg/kubelet/lifecycle/handlers.go
+3
-3
mirror_client.go
pkg/kubelet/mirror_client.go
+6
-6
cni.go
pkg/kubelet/network/cni/cni.go
+4
-4
exec.go
pkg/kubelet/network/exec/exec.go
+4
-4
plugins.go
pkg/kubelet/network/plugins.go
+7
-7
pod_manager_test.go
pkg/kubelet/pod_manager_test.go
+5
-5
pod_workers.go
pkg/kubelet/pod_workers.go
+5
-5
pod_workers_test.go
pkg/kubelet/pod_workers_test.go
+8
-8
runonce.go
pkg/kubelet/runonce.go
+3
-3
server_test.go
pkg/kubelet/server_test.go
+2
-2
manager.go
pkg/kubelet/status/manager.go
+3
-3
No files found.
cmd/integration/integration.go
View file @
a3e60cc3
...
...
@@ -51,7 +51,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/tools/etcdtest"
...
...
@@ -415,7 +415,7 @@ containers:
// Wait for the mirror pod to be created.
podName
:=
fmt
.
Sprintf
(
"%s-localhost"
,
desc
)
namespace
:=
kube
letT
ypes
.
NamespaceDefault
namespace
:=
kube
t
ypes
.
NamespaceDefault
if
err
:=
wait
.
Poll
(
time
.
Second
,
longTestTimeout
,
podRunning
(
c
,
namespace
,
podName
));
err
!=
nil
{
if
pods
,
err
:=
c
.
Pods
(
namespace
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
());
err
==
nil
{
...
...
cmd/kubelet/app/server.go
View file @
a3e60cc3
...
...
@@ -49,7 +49,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/kubelet/network"
"k8s.io/kubernetes/pkg/kubelet/qos"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/io"
...
...
@@ -149,8 +149,8 @@ type KubeletBootstrap interface {
StartGarbageCollection
()
ListenAndServe
(
address
net
.
IP
,
port
uint
,
tlsOptions
*
kubelet
.
TLSOptions
,
auth
kubelet
.
AuthInterface
,
enableDebuggingHandlers
bool
)
ListenAndServeReadOnly
(
address
net
.
IP
,
port
uint
)
Run
(
<-
chan
kube
letT
ypes
.
PodUpdate
)
RunOnce
(
<-
chan
kube
letT
ypes
.
PodUpdate
)
([]
kubelet
.
RunPodResult
,
error
)
Run
(
<-
chan
kube
t
ypes
.
PodUpdate
)
RunOnce
(
<-
chan
kube
t
ypes
.
PodUpdate
)
([]
kubelet
.
RunPodResult
,
error
)
}
// create and initialize a Kubelet instance
...
...
@@ -174,9 +174,9 @@ func NewKubeletServer() *KubeletServer {
FileCheckFrequency
:
20
*
time
.
Second
,
HealthzBindAddress
:
net
.
ParseIP
(
"127.0.0.1"
),
HealthzPort
:
10248
,
HostNetworkSources
:
kube
letT
ypes
.
AllSource
,
HostPIDSources
:
kube
letT
ypes
.
AllSource
,
HostIPCSources
:
kube
letT
ypes
.
AllSource
,
HostNetworkSources
:
kube
t
ypes
.
AllSource
,
HostPIDSources
:
kube
t
ypes
.
AllSource
,
HostIPCSources
:
kube
t
ypes
.
AllSource
,
HTTPCheckFrequency
:
20
*
time
.
Second
,
ImageGCHighThresholdPercent
:
90
,
ImageGCLowThresholdPercent
:
80
,
...
...
@@ -284,17 +284,17 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
// UnsecuredKubeletConfig returns a KubeletConfig suitable for being run, or an error if the server setup
// is not valid. It will not start any background processes, and does not include authentication/authorization
func
(
s
*
KubeletServer
)
UnsecuredKubeletConfig
()
(
*
KubeletConfig
,
error
)
{
hostNetworkSources
,
err
:=
kube
letT
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostNetworkSources
,
","
))
hostNetworkSources
,
err
:=
kube
t
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostNetworkSources
,
","
))
if
err
!=
nil
{
return
nil
,
err
}
hostPIDSources
,
err
:=
kube
letT
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostPIDSources
,
","
))
hostPIDSources
,
err
:=
kube
t
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostPIDSources
,
","
))
if
err
!=
nil
{
return
nil
,
err
}
hostIPCSources
,
err
:=
kube
letT
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostIPCSources
,
","
))
hostIPCSources
,
err
:=
kube
t
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostIPCSources
,
","
))
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -765,17 +765,17 @@ func makePodSourceConfig(kc *KubeletConfig) *config.PodConfig {
// define file config source
if
kc
.
ConfigFile
!=
""
{
glog
.
Infof
(
"Adding manifest file: %v"
,
kc
.
ConfigFile
)
config
.
NewSourceFile
(
kc
.
ConfigFile
,
kc
.
NodeName
,
kc
.
FileCheckFrequency
,
cfg
.
Channel
(
kube
letT
ypes
.
FileSource
))
config
.
NewSourceFile
(
kc
.
ConfigFile
,
kc
.
NodeName
,
kc
.
FileCheckFrequency
,
cfg
.
Channel
(
kube
t
ypes
.
FileSource
))
}
// define url config source
if
kc
.
ManifestURL
!=
""
{
glog
.
Infof
(
"Adding manifest url %q with HTTP header %v"
,
kc
.
ManifestURL
,
kc
.
ManifestURLHeader
)
config
.
NewSourceURL
(
kc
.
ManifestURL
,
kc
.
ManifestURLHeader
,
kc
.
NodeName
,
kc
.
HTTPCheckFrequency
,
cfg
.
Channel
(
kube
letT
ypes
.
HTTPSource
))
config
.
NewSourceURL
(
kc
.
ManifestURL
,
kc
.
ManifestURLHeader
,
kc
.
NodeName
,
kc
.
HTTPCheckFrequency
,
cfg
.
Channel
(
kube
t
ypes
.
HTTPSource
))
}
if
kc
.
KubeClient
!=
nil
{
glog
.
Infof
(
"Watching apiserver"
)
config
.
NewSourceApiserver
(
kc
.
KubeClient
,
kc
.
NodeName
,
cfg
.
Channel
(
kube
letT
ypes
.
ApiserverSource
))
config
.
NewSourceApiserver
(
kc
.
KubeClient
,
kc
.
NodeName
,
cfg
.
Channel
(
kube
t
ypes
.
ApiserverSource
))
}
return
cfg
}
...
...
contrib/mesos/pkg/executor/executor.go
View file @
a3e60cc3
...
...
@@ -43,7 +43,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet"
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util"
)
...
...
@@ -265,9 +265,9 @@ func (k *KubernetesExecutor) onInitialRegistration() {
defer
close
(
k
.
initialRegComplete
)
// emit an empty update to allow the mesos "source" to be marked as seen
k
.
updateChan
<-
kube
letT
ypes
.
PodUpdate
{
k
.
updateChan
<-
kube
t
ypes
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{},
Op
:
kube
letT
ypes
.
SET
,
Op
:
kube
t
ypes
.
SET
,
Source
:
k
.
sourcename
,
}
}
...
...
@@ -393,8 +393,8 @@ func (k *KubernetesExecutor) handleChangedApiserverPod(pod *api.Pod) {
oldPod
.
DeletionTimestamp
=
pod
.
DeletionTimestamp
oldPod
.
DeletionGracePeriodSeconds
=
pod
.
DeletionGracePeriodSeconds
update
:=
kube
letT
ypes
.
PodUpdate
{
Op
:
kube
letT
ypes
.
UPDATE
,
update
:=
kube
t
ypes
.
PodUpdate
{
Op
:
kube
t
ypes
.
UPDATE
,
Pods
:
[]
*
api
.
Pod
{
oldPod
},
}
k
.
updateChan
<-
update
...
...
@@ -566,8 +566,8 @@ func (k *KubernetesExecutor) launchTask(driver bindings.ExecutorDriver, taskId s
k
.
pods
[
podFullName
]
=
pod
// send the new pod to the kubelet which will spin it up
update
:=
kube
letT
ypes
.
PodUpdate
{
Op
:
kube
letT
ypes
.
ADD
,
update
:=
kube
t
ypes
.
PodUpdate
{
Op
:
kube
t
ypes
.
ADD
,
Pods
:
[]
*
api
.
Pod
{
pod
},
}
k
.
updateChan
<-
update
...
...
@@ -771,8 +771,8 @@ func (k *KubernetesExecutor) removePodTask(driver bindings.ExecutorDriver, tid,
delete
(
k
.
pods
,
pid
)
// tell the kubelet to remove the pod
update
:=
kube
letT
ypes
.
PodUpdate
{
Op
:
kube
letT
ypes
.
REMOVE
,
update
:=
kube
t
ypes
.
PodUpdate
{
Op
:
kube
t
ypes
.
REMOVE
,
Pods
:
[]
*
api
.
Pod
{
pod
},
}
k
.
updateChan
<-
update
...
...
contrib/mesos/pkg/executor/executor_test.go
View file @
a3e60cc3
...
...
@@ -43,7 +43,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet"
kconfig
"k8s.io/kubernetes/pkg/kubelet/config"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
...
...
@@ -67,15 +67,15 @@ func TestExecutorRegister(t *testing.T) {
executor
.
Init
(
mockDriver
)
executor
.
Registered
(
mockDriver
,
nil
,
nil
,
nil
)
initialPodUpdate
:=
kube
letT
ypes
.
PodUpdate
{
initialPodUpdate
:=
kube
t
ypes
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{},
Op
:
kube
letT
ypes
.
SET
,
Op
:
kube
t
ypes
.
SET
,
Source
:
executor
.
sourcename
,
}
receivedInitialPodUpdate
:=
false
select
{
case
m
:=
<-
updates
:
update
,
ok
:=
m
.
(
kube
letT
ypes
.
PodUpdate
)
update
,
ok
:=
m
.
(
kube
t
ypes
.
PodUpdate
)
if
ok
{
if
reflect
.
DeepEqual
(
initialPodUpdate
,
update
)
{
receivedInitialPodUpdate
=
true
...
...
@@ -213,7 +213,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) {
gotPodUpdate
:=
false
select
{
case
m
:=
<-
updates
:
update
,
ok
:=
m
.
(
kube
letT
ypes
.
PodUpdate
)
update
,
ok
:=
m
.
(
kube
t
ypes
.
PodUpdate
)
if
ok
&&
len
(
update
.
Pods
)
==
1
{
gotPodUpdate
=
true
}
...
...
@@ -361,7 +361,7 @@ func TestExecutorStaticPods(t *testing.T) {
if
!
ok
{
return
}
podUpdate
,
ok
:=
update
.
(
kube
letT
ypes
.
PodUpdate
)
podUpdate
,
ok
:=
update
.
(
kube
t
ypes
.
PodUpdate
)
if
!
ok
{
continue
}
...
...
contrib/mesos/pkg/executor/service/service.go
View file @
a3e60cc3
...
...
@@ -46,7 +46,7 @@ import (
kconfig
"k8s.io/kubernetes/pkg/kubelet/config"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util"
utilio
"k8s.io/kubernetes/pkg/util/io"
"k8s.io/kubernetes/pkg/util/mount"
...
...
@@ -56,7 +56,7 @@ import (
const
(
// if we don't use this source then the kubelet will do funny, mirror things.
// @see ConfigSourceAnnotationKey
MESOS_CFG_SOURCE
=
kube
letT
ypes
.
ApiserverSource
MESOS_CFG_SOURCE
=
kube
t
ypes
.
ApiserverSource
)
type
KubeletExecutorServer
struct
{
...
...
@@ -137,17 +137,17 @@ func (s *KubeletExecutorServer) Run(hks hyperkube.Interface, _ []string) error {
//cloud := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
//log.Infof("Successfully initialized cloud provider: %q from the config file: %q\n", s.CloudProvider, s.CloudConfigFile)
hostNetworkSources
,
err
:=
kube
letT
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostNetworkSources
,
","
))
hostNetworkSources
,
err
:=
kube
t
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostNetworkSources
,
","
))
if
err
!=
nil
{
return
err
}
hostPIDSources
,
err
:=
kube
letT
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostPIDSources
,
","
))
hostPIDSources
,
err
:=
kube
t
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostPIDSources
,
","
))
if
err
!=
nil
{
return
err
}
hostIPCSources
,
err
:=
kube
letT
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostIPCSources
,
","
))
hostIPCSources
,
err
:=
kube
t
ypes
.
GetValidatedSources
(
strings
.
Split
(
s
.
HostIPCSources
,
","
))
if
err
!=
nil
{
return
err
}
...
...
@@ -384,7 +384,7 @@ func (ks *KubeletExecutorServer) createAndInitKubelet(
go
exec
.
InitializeStaticPodsSource
(
func
()
{
// Create file source only when we are called back. Otherwise, it is never marked unseen.
fileSourceUpdates
:=
pc
.
Channel
(
kube
letT
ypes
.
FileSource
)
fileSourceUpdates
:=
pc
.
Channel
(
kube
t
ypes
.
FileSource
)
kconfig
.
NewSourceFile
(
staticPodsConfigPath
,
kc
.
Hostname
,
kc
.
FileCheckFrequency
,
fileSourceUpdates
)
})
...
...
@@ -450,7 +450,7 @@ func (kl *kubeletExecutor) ListenAndServe(address net.IP, port uint, tlsOptions
// runs the main kubelet loop, closing the kubeletFinished chan when the loop exits.
// never returns.
func
(
kl
*
kubeletExecutor
)
Run
(
updates
<-
chan
kube
letT
ypes
.
PodUpdate
)
{
func
(
kl
*
kubeletExecutor
)
Run
(
updates
<-
chan
kube
t
ypes
.
PodUpdate
)
{
defer
func
()
{
close
(
kl
.
kubeletFinished
)
util
.
HandleCrash
()
...
...
@@ -461,7 +461,7 @@ func (kl *kubeletExecutor) Run(updates <-chan kubeletTypes.PodUpdate) {
// push updates through a closable pipe. when the executor indicates shutdown
// via Done() we want to stop the Kubelet from processing updates.
pipe
:=
make
(
chan
kube
letT
ypes
.
PodUpdate
)
pipe
:=
make
(
chan
kube
t
ypes
.
PodUpdate
)
go
func
()
{
// closing pipe will cause our patched kubelet's syncLoop() to exit
defer
close
(
pipe
)
...
...
contrib/mesos/pkg/scheduler/scheduler.go
View file @
a3e60cc3
...
...
@@ -47,7 +47,7 @@ import (
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/kubelet/container"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/util/sets"
...
...
@@ -897,7 +897,7 @@ func (ks *KubernetesScheduler) recoverTasks() error {
ks
.
slaveHostNames
.
Register
(
slaveId
,
t
.
Offer
.
Host
())
}
for
_
,
pod
:=
range
podList
.
Items
{
if
_
,
isMirrorPod
:=
pod
.
Annotations
[
kube
letT
ypes
.
ConfigMirrorAnnotationKey
];
isMirrorPod
{
if
_
,
isMirrorPod
:=
pod
.
Annotations
[
kube
t
ypes
.
ConfigMirrorAnnotationKey
];
isMirrorPod
{
// mirrored pods are never reconciled because the scheduler isn't responsible for
// scheduling them; they're started by the executor/kubelet upon instantiation and
// reflected in the apiserver afterward. the scheduler has no knowledge of them.
...
...
pkg/kubelet/config/apiserver.go
View file @
a3e60cc3
...
...
@@ -22,7 +22,7 @@ import (
"k8s.io/kubernetes/pkg/client/cache"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
)
// NewSourceApiserver creates a config source that watches and pulls from the apiserver.
...
...
@@ -38,7 +38,7 @@ func newSourceApiserverFromLW(lw cache.ListerWatcher, updates chan<- interface{}
for
_
,
o
:=
range
objs
{
pods
=
append
(
pods
,
o
.
(
*
api
.
Pod
))
}
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
pods
,
Op
:
kubeletTypes
.
SET
,
Source
:
kubeletT
ypes
.
ApiserverSource
}
updates
<-
kube
types
.
PodUpdate
{
Pods
:
pods
,
Op
:
kubetypes
.
SET
,
Source
:
kubet
ypes
.
ApiserverSource
}
}
cache
.
NewReflector
(
lw
,
&
api
.
Pod
{},
cache
.
NewUndeltaStore
(
send
,
cache
.
MetaNamespaceKeyFunc
),
0
)
.
Run
()
}
pkg/kubelet/config/apiserver_test.go
View file @
a3e60cc3
...
...
@@ -21,7 +21,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/cache"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
)
...
...
@@ -67,8 +67,8 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
if
!
ok
{
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
:=
got
.
(
kube
letT
ypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
ApiserverSource
,
pod1v1
)
update
:=
got
.
(
kube
t
ypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
ApiserverSource
,
pod1v1
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
update
)
}
...
...
@@ -79,10 +79,10 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
if
!
ok
{
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
=
got
.
(
kube
letT
ypes
.
PodUpdate
)
update
=
got
.
(
kube
t
ypes
.
PodUpdate
)
// Could be sorted either of these two ways:
expectedA
:=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
ApiserverSource
,
pod1v1
,
pod2
)
expectedB
:=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
ApiserverSource
,
pod2
,
pod1v1
)
expectedA
:=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
ApiserverSource
,
pod1v1
,
pod2
)
expectedB
:=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
ApiserverSource
,
pod2
,
pod1v1
)
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
...
...
@@ -94,9 +94,9 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
if
!
ok
{
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
=
got
.
(
kube
letT
ypes
.
PodUpdate
)
expectedA
=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
ApiserverSource
,
pod1v2
,
pod2
)
expectedB
=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
ApiserverSource
,
pod2
,
pod1v2
)
update
=
got
.
(
kube
t
ypes
.
PodUpdate
)
expectedA
=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
ApiserverSource
,
pod1v2
,
pod2
)
expectedB
=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
ApiserverSource
,
pod2
,
pod1v2
)
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
...
...
@@ -108,8 +108,8 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
if
!
ok
{
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
=
got
.
(
kube
letT
ypes
.
PodUpdate
)
expected
=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
ApiserverSource
,
pod2
)
update
=
got
.
(
kube
t
ypes
.
PodUpdate
)
expected
=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
ApiserverSource
,
pod2
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
...
...
@@ -120,8 +120,8 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
if
!
ok
{
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
=
got
.
(
kube
letT
ypes
.
PodUpdate
)
expected
=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
ApiserverSource
)
update
=
got
.
(
kube
t
ypes
.
PodUpdate
)
expected
=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
ApiserverSource
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
...
...
@@ -150,7 +150,7 @@ func TestNewSourceApiserver_TwoNamespacesSameName(t *testing.T) {
if
!
ok
{
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
:=
got
.
(
kube
letT
ypes
.
PodUpdate
)
update
:=
got
.
(
kube
t
ypes
.
PodUpdate
)
// Make sure that we get both pods. Catches bug #2294.
if
!
(
len
(
update
.
Pods
)
==
2
)
{
t
.
Errorf
(
"Expected %d, Got %d"
,
2
,
len
(
update
.
Pods
))
...
...
@@ -162,7 +162,7 @@ func TestNewSourceApiserver_TwoNamespacesSameName(t *testing.T) {
if
!
ok
{
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
=
got
.
(
kube
letT
ypes
.
PodUpdate
)
update
=
got
.
(
kube
t
ypes
.
PodUpdate
)
if
!
(
len
(
update
.
Pods
)
==
1
)
{
t
.
Errorf
(
"Expected %d, Got %d"
,
1
,
len
(
update
.
Pods
))
}
...
...
@@ -184,8 +184,8 @@ func TestNewSourceApiserverInitialEmptySendsEmptyPodUpdate(t *testing.T) {
if
!
ok
{
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
:=
got
.
(
kube
letT
ypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
ApiserverSource
)
update
:=
got
.
(
kube
t
ypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
ApiserverSource
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
update
)
}
...
...
pkg/kubelet/config/common.go
View file @
a3e60cc3
...
...
@@ -25,7 +25,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/validation"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
utilyaml
"k8s.io/kubernetes/pkg/util/yaml"
...
...
@@ -56,7 +56,7 @@ func applyDefaults(pod *api.Pod, source string, isFile bool, nodeName string) er
glog
.
V
(
5
)
.
Infof
(
"Generated Name %q for UID %q from URL %s"
,
pod
.
Name
,
pod
.
UID
,
source
)
if
pod
.
Namespace
==
""
{
pod
.
Namespace
=
kube
letT
ypes
.
NamespaceDefault
pod
.
Namespace
=
kube
t
ypes
.
NamespaceDefault
}
glog
.
V
(
5
)
.
Infof
(
"Using namespace %q for pod %q from %s"
,
pod
.
Namespace
,
pod
.
Name
,
source
)
...
...
pkg/kubelet/config/config.go
View file @
a3e60cc3
...
...
@@ -26,7 +26,7 @@ import (
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/client/record"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubeletUtil
"k8s.io/kubernetes/pkg/kubelet/util"
"k8s.io/kubernetes/pkg/util/config"
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
...
...
@@ -59,7 +59,7 @@ type PodConfig struct {
mux
*
config
.
Mux
// the channel of denormalized changes passed to listeners
updates
chan
kube
letT
ypes
.
PodUpdate
updates
chan
kube
t
ypes
.
PodUpdate
// contains the list of all configured sources
sourcesLock
sync
.
Mutex
...
...
@@ -69,7 +69,7 @@ type PodConfig struct {
// NewPodConfig creates an object that can merge many configuration sources into a stream
// of normalized updates to a pod configuration.
func
NewPodConfig
(
mode
PodConfigNotificationMode
,
recorder
record
.
EventRecorder
)
*
PodConfig
{
updates
:=
make
(
chan
kube
letT
ypes
.
PodUpdate
,
50
)
updates
:=
make
(
chan
kube
t
ypes
.
PodUpdate
,
50
)
storage
:=
newPodStorage
(
updates
,
mode
,
recorder
)
podConfig
:=
&
PodConfig
{
pods
:
storage
,
...
...
@@ -100,7 +100,7 @@ func (c *PodConfig) SeenAllSources(seenSources sets.String) bool {
}
// Updates returns a channel of updates to the configuration, properly denormalized.
func
(
c
*
PodConfig
)
Updates
()
<-
chan
kube
letT
ypes
.
PodUpdate
{
func
(
c
*
PodConfig
)
Updates
()
<-
chan
kube
t
ypes
.
PodUpdate
{
return
c
.
updates
}
...
...
@@ -122,7 +122,7 @@ type podStorage struct {
// ensures that updates are delivered in strict order
// on the updates channel
updateLock
sync
.
Mutex
updates
chan
<-
kube
letT
ypes
.
PodUpdate
updates
chan
<-
kube
t
ypes
.
PodUpdate
// contains the set of all sources that have sent at least one SET
sourcesSeenLock
sync
.
Mutex
...
...
@@ -135,7 +135,7 @@ type podStorage struct {
// TODO: PodConfigNotificationMode could be handled by a listener to the updates channel
// in the future, especially with multiple listeners.
// TODO: allow initialization of the current state of the store with snapshotted version.
func
newPodStorage
(
updates
chan
<-
kube
letT
ypes
.
PodUpdate
,
mode
PodConfigNotificationMode
,
recorder
record
.
EventRecorder
)
*
podStorage
{
func
newPodStorage
(
updates
chan
<-
kube
t
ypes
.
PodUpdate
,
mode
PodConfigNotificationMode
,
recorder
record
.
EventRecorder
)
*
podStorage
{
return
&
podStorage
{
pods
:
make
(
map
[
string
]
map
[
string
]
*
api
.
Pod
),
mode
:
mode
,
...
...
@@ -172,12 +172,12 @@ func (s *podStorage) Merge(source string, change interface{}) error {
s
.
updates
<-
*
updates
}
if
len
(
deletes
.
Pods
)
>
0
||
len
(
adds
.
Pods
)
>
0
{
s
.
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
s
.
MergedState
()
.
([]
*
api
.
Pod
),
Op
:
kubeletT
ypes
.
SET
,
Source
:
source
}
s
.
updates
<-
kube
types
.
PodUpdate
{
Pods
:
s
.
MergedState
()
.
([]
*
api
.
Pod
),
Op
:
kubet
ypes
.
SET
,
Source
:
source
}
}
case
PodConfigNotificationSnapshot
:
if
len
(
updates
.
Pods
)
>
0
||
len
(
deletes
.
Pods
)
>
0
||
len
(
adds
.
Pods
)
>
0
{
s
.
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
s
.
MergedState
()
.
([]
*
api
.
Pod
),
Op
:
kubeletT
ypes
.
SET
,
Source
:
source
}
s
.
updates
<-
kube
types
.
PodUpdate
{
Pods
:
s
.
MergedState
()
.
([]
*
api
.
Pod
),
Op
:
kubet
ypes
.
SET
,
Source
:
source
}
}
case
PodConfigNotificationUnknown
:
...
...
@@ -189,23 +189,23 @@ func (s *podStorage) Merge(source string, change interface{}) error {
return
nil
}
func
(
s
*
podStorage
)
merge
(
source
string
,
change
interface
{})
(
adds
,
updates
,
deletes
*
kube
letT
ypes
.
PodUpdate
)
{
func
(
s
*
podStorage
)
merge
(
source
string
,
change
interface
{})
(
adds
,
updates
,
deletes
*
kube
t
ypes
.
PodUpdate
)
{
s
.
podLock
.
Lock
()
defer
s
.
podLock
.
Unlock
()
adds
=
&
kube
letTypes
.
PodUpdate
{
Op
:
kubeletT
ypes
.
ADD
,
Source
:
source
}
updates
=
&
kube
letTypes
.
PodUpdate
{
Op
:
kubeletT
ypes
.
UPDATE
,
Source
:
source
}
deletes
=
&
kube
letTypes
.
PodUpdate
{
Op
:
kubeletT
ypes
.
REMOVE
,
Source
:
source
}
adds
=
&
kube
types
.
PodUpdate
{
Op
:
kubet
ypes
.
ADD
,
Source
:
source
}
updates
=
&
kube
types
.
PodUpdate
{
Op
:
kubet
ypes
.
UPDATE
,
Source
:
source
}
deletes
=
&
kube
types
.
PodUpdate
{
Op
:
kubet
ypes
.
REMOVE
,
Source
:
source
}
pods
:=
s
.
pods
[
source
]
if
pods
==
nil
{
pods
=
make
(
map
[
string
]
*
api
.
Pod
)
}
update
:=
change
.
(
kube
letT
ypes
.
PodUpdate
)
update
:=
change
.
(
kube
t
ypes
.
PodUpdate
)
switch
update
.
Op
{
case
kube
letTypes
.
ADD
,
kubeletT
ypes
.
UPDATE
:
if
update
.
Op
==
kube
letT
ypes
.
ADD
{
case
kube
types
.
ADD
,
kubet
ypes
.
UPDATE
:
if
update
.
Op
==
kube
t
ypes
.
ADD
{
glog
.
V
(
4
)
.
Infof
(
"Adding new pods from source %s : %v"
,
source
,
update
.
Pods
)
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Updating pods from source %s : %v"
,
source
,
update
.
Pods
)
...
...
@@ -218,7 +218,7 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
if
ref
.
Annotations
==
nil
{
ref
.
Annotations
=
make
(
map
[
string
]
string
)
}
ref
.
Annotations
[
kube
letT
ypes
.
ConfigSourceAnnotationKey
]
=
source
ref
.
Annotations
[
kube
t
ypes
.
ConfigSourceAnnotationKey
]
=
source
if
existing
,
found
:=
pods
[
name
];
found
{
if
checkAndUpdatePod
(
existing
,
ref
)
{
// this is an update
...
...
@@ -234,7 +234,7 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
adds
.
Pods
=
append
(
adds
.
Pods
,
ref
)
}
case
kube
letT
ypes
.
REMOVE
:
case
kube
t
ypes
.
REMOVE
:
glog
.
V
(
4
)
.
Infof
(
"Removing a pod %v"
,
update
)
for
_
,
value
:=
range
update
.
Pods
{
name
:=
kubecontainer
.
GetPodFullName
(
value
)
...
...
@@ -247,7 +247,7 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
// this is a no-op
}
case
kube
letT
ypes
.
SET
:
case
kube
t
ypes
.
SET
:
glog
.
V
(
4
)
.
Infof
(
"Setting pods for source %s"
,
source
)
s
.
markSourceSet
(
source
)
// Clear the old map entries by just creating a new map
...
...
@@ -261,7 +261,7 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
if
ref
.
Annotations
==
nil
{
ref
.
Annotations
=
make
(
map
[
string
]
string
)
}
ref
.
Annotations
[
kube
letT
ypes
.
ConfigSourceAnnotationKey
]
=
source
ref
.
Annotations
[
kube
t
ypes
.
ConfigSourceAnnotationKey
]
=
source
if
existing
,
found
:=
oldPods
[
name
];
found
{
pods
[
name
]
=
existing
if
checkAndUpdatePod
(
existing
,
ref
)
{
...
...
@@ -335,9 +335,9 @@ func filterInvalidPods(pods []*api.Pod, source string, recorder record.EventReco
// Annotations that the kubelet adds to the pod.
var
localAnnotations
=
[]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
,
kube
letT
ypes
.
ConfigMirrorAnnotationKey
,
kube
letT
ypes
.
ConfigFirstSeenAnnotationKey
,
kube
t
ypes
.
ConfigSourceAnnotationKey
,
kube
t
ypes
.
ConfigMirrorAnnotationKey
,
kube
t
ypes
.
ConfigFirstSeenAnnotationKey
,
}
func
isLocalAnnotationKey
(
key
string
)
bool
{
...
...
@@ -379,7 +379,7 @@ func isAnnotationMapEqual(existingMap, candidateMap map[string]string) bool {
// recordFirstSeenTime records the first seen time of this pod.
func
recordFirstSeenTime
(
pod
*
api
.
Pod
)
{
glog
.
V
(
4
)
.
Infof
(
"Receiving a new pod %q"
,
kubeletUtil
.
FormatPodName
(
pod
))
pod
.
Annotations
[
kube
letTypes
.
ConfigFirstSeenAnnotationKey
]
=
kubeletT
ypes
.
NewTimestamp
()
.
GetString
()
pod
.
Annotations
[
kube
types
.
ConfigFirstSeenAnnotationKey
]
=
kubet
ypes
.
NewTimestamp
()
.
GetString
()
}
// updateAnnotations returns an Annotation map containing the api annotation map plus
...
...
@@ -420,7 +420,7 @@ func checkAndUpdatePod(existing, ref *api.Pod) bool {
// Overwrite the first-seen time with the existing one. This is our own
// internal annotation, there is no need to update.
ref
.
Annotations
[
kube
letTypes
.
ConfigFirstSeenAnnotationKey
]
=
existing
.
Annotations
[
kubeletT
ypes
.
ConfigFirstSeenAnnotationKey
]
ref
.
Annotations
[
kube
types
.
ConfigFirstSeenAnnotationKey
]
=
existing
.
Annotations
[
kubet
ypes
.
ConfigFirstSeenAnnotationKey
]
existing
.
Spec
=
ref
.
Spec
existing
.
Labels
=
ref
.
Labels
...
...
@@ -434,7 +434,7 @@ func checkAndUpdatePod(existing, ref *api.Pod) bool {
func
(
s
*
podStorage
)
Sync
()
{
s
.
updateLock
.
Lock
()
defer
s
.
updateLock
.
Unlock
()
s
.
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
s
.
MergedState
()
.
([]
*
api
.
Pod
),
Op
:
kubeletTypes
.
SET
,
Source
:
kubeletT
ypes
.
AllSource
}
s
.
updates
<-
kube
types
.
PodUpdate
{
Pods
:
s
.
MergedState
()
.
([]
*
api
.
Pod
),
Op
:
kubetypes
.
SET
,
Source
:
kubet
ypes
.
AllSource
}
}
// Object implements config.Accessor
...
...
pkg/kubelet/config/config_test.go
View file @
a3e60cc3
This diff is collapsed.
Click to expand it.
pkg/kubelet/config/file.go
View file @
a3e60cc3
...
...
@@ -26,7 +26,7 @@ import (
"time"
"k8s.io/kubernetes/pkg/api"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util"
"github.com/golang/glog"
...
...
@@ -66,7 +66,7 @@ func (s *sourceFile) extractFromPath() error {
return
err
}
// Emit an update with an empty PodList to allow FileSource to be marked as seen
s
.
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{},
Op
:
kubeletTypes
.
SET
,
Source
:
kubeletT
ypes
.
FileSource
}
s
.
updates
<-
kube
types
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{},
Op
:
kubetypes
.
SET
,
Source
:
kubet
ypes
.
FileSource
}
return
fmt
.
Errorf
(
"path does not exist, ignoring"
)
}
...
...
@@ -76,14 +76,14 @@ func (s *sourceFile) extractFromPath() error {
if
err
!=
nil
{
return
err
}
s
.
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
pods
,
Op
:
kubeletTypes
.
SET
,
Source
:
kubeletT
ypes
.
FileSource
}
s
.
updates
<-
kube
types
.
PodUpdate
{
Pods
:
pods
,
Op
:
kubetypes
.
SET
,
Source
:
kubet
ypes
.
FileSource
}
case
statInfo
.
Mode
()
.
IsRegular
()
:
pod
,
err
:=
s
.
extractFromFile
(
path
)
if
err
!=
nil
{
return
err
}
s
.
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{
pod
},
Op
:
kubeletTypes
.
SET
,
Source
:
kubeletT
ypes
.
FileSource
}
s
.
updates
<-
kube
types
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{
pod
},
Op
:
kubetypes
.
SET
,
Source
:
kubet
ypes
.
FileSource
}
default
:
return
fmt
.
Errorf
(
"path is not a directory or file"
)
...
...
pkg/kubelet/config/file_test.go
View file @
a3e60cc3
...
...
@@ -26,7 +26,7 @@ import (
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/validation"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -46,8 +46,8 @@ func TestUpdateOnNonExistentFile(t *testing.T) {
NewSourceFile
(
"random_non_existent_path"
,
"localhost"
,
time
.
Millisecond
,
ch
)
select
{
case
got
:=
<-
ch
:
update
:=
got
.
(
kube
letT
ypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
FileSource
)
update
:=
got
.
(
kube
t
ypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
FileSource
)
if
!
api
.
Semantic
.
DeepDerivative
(
expected
,
update
)
{
t
.
Fatalf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
...
...
@@ -75,7 +75,7 @@ func TestReadPodsFromFile(t *testing.T) {
var
testCases
=
[]
struct
{
desc
string
pod
runtime
.
Object
expected
kube
letT
ypes
.
PodUpdate
expected
kube
t
ypes
.
PodUpdate
}{
{
desc
:
"Simple pod"
,
...
...
@@ -94,7 +94,7 @@ func TestReadPodsFromFile(t *testing.T) {
SecurityContext
:
&
api
.
PodSecurityContext
{},
},
},
expected
:
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
FileSource
,
&
api
.
Pod
{
expected
:
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
FileSource
,
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"test-"
+
hostname
,
UID
:
"12345"
,
...
...
@@ -137,7 +137,7 @@ func TestReadPodsFromFile(t *testing.T) {
NewSourceFile
(
file
.
Name
(),
hostname
,
time
.
Millisecond
,
ch
)
select
{
case
got
:=
<-
ch
:
update
:=
got
.
(
kube
letT
ypes
.
PodUpdate
)
update
:=
got
.
(
kube
t
ypes
.
PodUpdate
)
for
_
,
pod
:=
range
update
.
Pods
{
if
errs
:=
validation
.
ValidatePod
(
pod
);
len
(
errs
)
>
0
{
t
.
Errorf
(
"%s: Invalid pod %#v, %#v"
,
testCase
.
desc
,
pod
,
errs
)
...
...
@@ -180,8 +180,8 @@ func TestExtractFromEmptyDir(t *testing.T) {
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
update
:=
(
<-
ch
)
.
(
kube
letT
ypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kube
letTypes
.
SET
,
kubeletT
ypes
.
FileSource
)
update
:=
(
<-
ch
)
.
(
kube
t
ypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kube
types
.
SET
,
kubet
ypes
.
FileSource
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
...
...
pkg/kubelet/config/http.go
View file @
a3e60cc3
...
...
@@ -25,7 +25,7 @@ import (
"time"
"k8s.io/kubernetes/pkg/api"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util"
"github.com/golang/glog"
...
...
@@ -95,7 +95,7 @@ func (s *sourceURL) extractFromURL() error {
}
if
len
(
data
)
==
0
{
// Emit an update with an empty PodList to allow HTTPSource to be marked as seen
s
.
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{},
Op
:
kubeletTypes
.
SET
,
Source
:
kubeletT
ypes
.
HTTPSource
}
s
.
updates
<-
kube
types
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{},
Op
:
kubetypes
.
SET
,
Source
:
kubet
ypes
.
HTTPSource
}
return
fmt
.
Errorf
(
"zero-length data received from %v"
,
s
.
url
)
}
// Short circuit if the data has not changed since the last time it was read.
...
...
@@ -111,7 +111,7 @@ func (s *sourceURL) extractFromURL() error {
// It parsed but could not be used.
return
singlePodErr
}
s
.
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{
pod
},
Op
:
kubeletTypes
.
SET
,
Source
:
kubeletT
ypes
.
HTTPSource
}
s
.
updates
<-
kube
types
.
PodUpdate
{
Pods
:
[]
*
api
.
Pod
{
pod
},
Op
:
kubetypes
.
SET
,
Source
:
kubet
ypes
.
HTTPSource
}
return
nil
}
...
...
@@ -126,7 +126,7 @@ func (s *sourceURL) extractFromURL() error {
for
i
:=
range
podList
.
Items
{
pods
=
append
(
pods
,
&
podList
.
Items
[
i
])
}
s
.
updates
<-
kube
letTypes
.
PodUpdate
{
Pods
:
pods
,
Op
:
kubeletTypes
.
SET
,
Source
:
kubeletT
ypes
.
HTTPSource
}
s
.
updates
<-
kube
types
.
PodUpdate
{
Pods
:
pods
,
Op
:
kubetypes
.
SET
,
Source
:
kubet
ypes
.
HTTPSource
}
return
nil
}
...
...
pkg/kubelet/config/http_test.go
View file @
a3e60cc3
...
...
@@ -27,7 +27,7 @@ import (
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/validation"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/errors"
...
...
@@ -128,7 +128,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
var
testCases
=
[]
struct
{
desc
string
pods
runtime
.
Object
expected
kube
letT
ypes
.
PodUpdate
expected
kube
t
ypes
.
PodUpdate
}{
{
desc
:
"Single pod"
,
...
...
@@ -148,8 +148,8 @@ func TestExtractPodsFromHTTP(t *testing.T) {
SecurityContext
:
&
api
.
PodSecurityContext
{},
},
},
expected
:
CreatePodUpdate
(
kube
letT
ypes
.
SET
,
kube
letT
ypes
.
HTTPSource
,
expected
:
CreatePodUpdate
(
kube
t
ypes
.
SET
,
kube
t
ypes
.
HTTPSource
,
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"111"
,
...
...
@@ -206,15 +206,15 @@ func TestExtractPodsFromHTTP(t *testing.T) {
},
},
},
expected
:
CreatePodUpdate
(
kube
letT
ypes
.
SET
,
kube
letT
ypes
.
HTTPSource
,
expected
:
CreatePodUpdate
(
kube
t
ypes
.
SET
,
kube
t
ypes
.
HTTPSource
,
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"111"
,
Name
:
"foo"
+
"-"
+
hostname
,
Namespace
:
"default"
,
SelfLink
:
getSelfLink
(
"foo-"
+
hostname
,
kube
letT
ypes
.
NamespaceDefault
),
SelfLink
:
getSelfLink
(
"foo-"
+
hostname
,
kube
t
ypes
.
NamespaceDefault
),
},
Spec
:
api
.
PodSpec
{
NodeName
:
hostname
,
...
...
@@ -237,7 +237,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
Name
:
"bar"
+
"-"
+
hostname
,
Namespace
:
"default"
,
SelfLink
:
getSelfLink
(
"bar-"
+
hostname
,
kube
letT
ypes
.
NamespaceDefault
),
SelfLink
:
getSelfLink
(
"bar-"
+
hostname
,
kube
t
ypes
.
NamespaceDefault
),
},
Spec
:
api
.
PodSpec
{
NodeName
:
hostname
,
...
...
@@ -279,7 +279,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
t
.
Errorf
(
"%s: Unexpected error: %v"
,
testCase
.
desc
,
err
)
continue
}
update
:=
(
<-
ch
)
.
(
kube
letT
ypes
.
PodUpdate
)
update
:=
(
<-
ch
)
.
(
kube
t
ypes
.
PodUpdate
)
if
!
api
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
t
.
Errorf
(
"%s: Expected: %#v, Got: %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
...
...
@@ -325,7 +325,7 @@ func TestURLWithHeader(t *testing.T) {
if
err
:=
c
.
extractFromURL
();
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error extracting from URL: %v"
,
err
)
}
update
:=
(
<-
ch
)
.
(
kube
letT
ypes
.
PodUpdate
)
update
:=
(
<-
ch
)
.
(
kube
t
ypes
.
PodUpdate
)
headerVal
:=
fakeHandler
.
RequestReceived
.
Header
[
"Metadata-Flavor"
]
if
len
(
headerVal
)
!=
1
||
headerVal
[
0
]
!=
"Google"
{
...
...
pkg/kubelet/dockertools/convert.go
View file @
a3e60cc3
...
...
@@ -21,7 +21,7 @@ import (
docker
"github.com/fsouza/go-dockerclient"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
)
// This file contains helper functions to convert docker API types to runtime
...
...
@@ -38,7 +38,7 @@ func toRuntimeContainer(c *docker.APIContainers) (*kubecontainer.Container, erro
return
nil
,
err
}
return
&
kubecontainer
.
Container
{
ID
:
kube
letT
ypes
.
DockerID
(
c
.
ID
)
.
ContainerID
(),
ID
:
kube
t
ypes
.
DockerID
(
c
.
ID
)
.
ContainerID
(),
Name
:
dockerName
.
ContainerName
,
Image
:
c
.
Image
,
Hash
:
hash
,
...
...
pkg/kubelet/dockertools/docker.go
View file @
a3e60cc3
...
...
@@ -32,7 +32,7 @@ import (
"k8s.io/kubernetes/pkg/credentialprovider"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/leaky"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
...
...
@@ -212,7 +212,7 @@ func (p throttledDockerPuller) IsImagePresent(name string) (bool, error) {
}
// DockerContainers is a map of containers
type
DockerContainers
map
[
kube
letT
ypes
.
DockerID
]
*
docker
.
APIContainers
type
DockerContainers
map
[
kube
t
ypes
.
DockerID
]
*
docker
.
APIContainers
func
(
c
DockerContainers
)
FindPodContainer
(
podFullName
string
,
uid
types
.
UID
,
containerName
string
)
(
*
docker
.
APIContainers
,
bool
,
uint64
)
{
for
_
,
dockerContainer
:=
range
c
{
...
...
@@ -368,7 +368,7 @@ func GetKubeletDockerContainers(client DockerInterface, allContainers bool) (Doc
glog
.
V
(
3
)
.
Infof
(
"Docker Container: %s is not managed by kubelet."
,
container
.
Names
[
0
])
continue
}
result
[
kube
letT
ypes
.
DockerID
(
container
.
ID
)]
=
container
result
[
kube
t
ypes
.
DockerID
(
container
.
ID
)]
=
container
}
return
result
,
nil
}
pkg/kubelet/dockertools/docker_test.go
View file @
a3e60cc3
...
...
@@ -34,7 +34,7 @@ import (
"k8s.io/kubernetes/pkg/credentialprovider"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/network"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
)
...
...
@@ -172,7 +172,7 @@ func TestExecSupportNotExists(t *testing.T) {
func
TestDockerContainerCommand
(
t
*
testing
.
T
)
{
runner
:=
&
DockerManager
{}
containerID
:=
kube
letT
ypes
.
DockerID
(
"1234"
)
.
ContainerID
()
containerID
:=
kube
t
ypes
.
DockerID
(
"1234"
)
.
ContainerID
()
command
:=
[]
string
{
"ls"
}
cmd
,
_
:=
runner
.
getRunInContainerCommand
(
containerID
,
command
)
if
cmd
.
Dir
!=
"/var/lib/docker/execdriver/native/"
+
containerID
.
ID
{
...
...
@@ -561,12 +561,12 @@ func TestFindContainersByPod(t *testing.T) {
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
ID
:
kube
letT
ypes
.
DockerID
(
"foobar"
)
.
ContainerID
(),
ID
:
kube
t
ypes
.
DockerID
(
"foobar"
)
.
ContainerID
(),
Name
:
"foobar"
,
Hash
:
0x1234
,
},
{
ID
:
kube
letT
ypes
.
DockerID
(
"baz"
)
.
ContainerID
(),
ID
:
kube
t
ypes
.
DockerID
(
"baz"
)
.
ContainerID
(),
Name
:
"baz"
,
Hash
:
0x1234
,
},
...
...
@@ -578,7 +578,7 @@ func TestFindContainersByPod(t *testing.T) {
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
ID
:
kube
letT
ypes
.
DockerID
(
"barbar"
)
.
ContainerID
(),
ID
:
kube
t
ypes
.
DockerID
(
"barbar"
)
.
ContainerID
(),
Name
:
"barbar"
,
Hash
:
0x1234
,
},
...
...
@@ -619,17 +619,17 @@ func TestFindContainersByPod(t *testing.T) {
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
ID
:
kube
letT
ypes
.
DockerID
(
"foobar"
)
.
ContainerID
(),
ID
:
kube
t
ypes
.
DockerID
(
"foobar"
)
.
ContainerID
(),
Name
:
"foobar"
,
Hash
:
0x1234
,
},
{
ID
:
kube
letT
ypes
.
DockerID
(
"barfoo"
)
.
ContainerID
(),
ID
:
kube
t
ypes
.
DockerID
(
"barfoo"
)
.
ContainerID
(),
Name
:
"barfoo"
,
Hash
:
0x1234
,
},
{
ID
:
kube
letT
ypes
.
DockerID
(
"baz"
)
.
ContainerID
(),
ID
:
kube
t
ypes
.
DockerID
(
"baz"
)
.
ContainerID
(),
Name
:
"baz"
,
Hash
:
0x1234
,
},
...
...
@@ -641,7 +641,7 @@ func TestFindContainersByPod(t *testing.T) {
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
ID
:
kube
letT
ypes
.
DockerID
(
"barbar"
)
.
ContainerID
(),
ID
:
kube
t
ypes
.
DockerID
(
"barbar"
)
.
ContainerID
(),
Name
:
"barbar"
,
Hash
:
0x1234
,
},
...
...
@@ -653,7 +653,7 @@ func TestFindContainersByPod(t *testing.T) {
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
ID
:
kube
letT
ypes
.
DockerID
(
"bazbaz"
)
.
ContainerID
(),
ID
:
kube
t
ypes
.
DockerID
(
"bazbaz"
)
.
ContainerID
(),
Name
:
"bazbaz"
,
Hash
:
0x1234
,
},
...
...
pkg/kubelet/dockertools/fake_manager.go
View file @
a3e60cc3
...
...
@@ -22,7 +22,7 @@ import (
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/network"
"k8s.io/kubernetes/pkg/kubelet/prober"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/oom"
"k8s.io/kubernetes/pkg/util/procfs"
...
...
@@ -41,7 +41,7 @@ func NewFakeDockerManager(
osInterface
kubecontainer
.
OSInterface
,
networkPlugin
network
.
NetworkPlugin
,
generator
kubecontainer
.
RunContainerOptionsGenerator
,
httpClient
kube
letT
ypes
.
HttpGetter
,
imageBackOff
*
util
.
Backoff
)
*
DockerManager
{
httpClient
kube
t
ypes
.
HttpGetter
,
imageBackOff
*
util
.
Backoff
)
*
DockerManager
{
fakeOOMAdjuster
:=
oom
.
NewFakeOOMAdjuster
()
fakeProcFs
:=
procfs
.
NewFakeProcFs
()
...
...
pkg/kubelet/dockertools/manager.go
View file @
a3e60cc3
...
...
@@ -46,7 +46,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/network/hairpin"
"k8s.io/kubernetes/pkg/kubelet/prober"
"k8s.io/kubernetes/pkg/kubelet/qos"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/types"
...
...
@@ -157,7 +157,7 @@ func NewDockerManager(
osInterface
kubecontainer
.
OSInterface
,
networkPlugin
network
.
NetworkPlugin
,
generator
kubecontainer
.
RunContainerOptionsGenerator
,
httpClient
kube
letT
ypes
.
HttpGetter
,
httpClient
kube
t
ypes
.
HttpGetter
,
execHandler
ExecHandler
,
oomAdjuster
*
oom
.
OOMAdjuster
,
procFs
procfs
.
ProcFsInterface
,
...
...
@@ -343,7 +343,7 @@ func (dm *DockerManager) inspectContainer(dockerID, containerName, tPath string,
}
// override the above if a network plugin exists
if
dm
.
networkPlugin
.
Name
()
!=
network
.
DefaultPluginName
{
netStatus
,
err
:=
dm
.
networkPlugin
.
Status
(
pod
.
Namespace
,
pod
.
Name
,
kube
letT
ypes
.
DockerID
(
dockerID
))
netStatus
,
err
:=
dm
.
networkPlugin
.
Status
(
pod
.
Namespace
,
pod
.
Name
,
kube
t
ypes
.
DockerID
(
dockerID
))
if
err
!=
nil
{
glog
.
Errorf
(
"NetworkPlugin %s failed on the status hook for pod '%s' - %v"
,
dm
.
networkPlugin
.
Name
(),
pod
.
Name
,
err
)
}
else
if
netStatus
!=
nil
{
...
...
@@ -573,7 +573,7 @@ func (dm *DockerManager) GetPodStatus(pod *api.Pod) (*api.PodStatus, error) {
// Sort the container statuses since clients of this interface expect the list
// of containers in a pod to behave like the output of `docker list`, which has a
// deterministic order.
sort
.
Sort
(
kube
letT
ypes
.
SortedContainerStatuses
(
podStatus
.
ContainerStatuses
))
sort
.
Sort
(
kube
t
ypes
.
SortedContainerStatuses
(
podStatus
.
ContainerStatuses
))
return
&
podStatus
,
nil
}
...
...
@@ -808,7 +808,7 @@ func (dm *DockerManager) runContainer(
if
ref
!=
nil
{
dm
.
recorder
.
Eventf
(
ref
,
"Started"
,
"Started with docker id %v"
,
util
.
ShortenString
(
dockerContainer
.
ID
,
12
))
}
return
kube
letT
ypes
.
DockerID
(
dockerContainer
.
ID
)
.
ContainerID
(),
nil
return
kube
t
ypes
.
DockerID
(
dockerContainer
.
ID
)
.
ContainerID
(),
nil
}
func
setEntrypointAndCommand
(
container
*
api
.
Container
,
opts
*
kubecontainer
.
RunContainerOptions
,
dockerOpts
*
docker
.
CreateContainerOptions
)
{
...
...
@@ -1296,7 +1296,7 @@ func (dm *DockerManager) KillPod(pod *api.Pod, runningPod kubecontainer.Pod) err
}
wg
.
Wait
()
if
networkContainer
!=
nil
{
if
err
:=
dm
.
networkPlugin
.
TearDownPod
(
runningPod
.
Namespace
,
runningPod
.
Name
,
kube
letT
ypes
.
DockerID
(
networkContainer
.
ID
.
ID
));
err
!=
nil
{
if
err
:=
dm
.
networkPlugin
.
TearDownPod
(
runningPod
.
Namespace
,
runningPod
.
Name
,
kube
t
ypes
.
DockerID
(
networkContainer
.
ID
.
ID
));
err
!=
nil
{
glog
.
Errorf
(
"Failed tearing down the infra container: %v"
,
err
)
errs
<-
err
}
...
...
@@ -1585,7 +1585,7 @@ func appendToFile(filePath, stringToAppend string) error {
}
// createPodInfraContainer starts the pod infra container for a pod. Returns the docker container ID of the newly created container.
func
(
dm
*
DockerManager
)
createPodInfraContainer
(
pod
*
api
.
Pod
)
(
kube
letT
ypes
.
DockerID
,
error
)
{
func
(
dm
*
DockerManager
)
createPodInfraContainer
(
pod
*
api
.
Pod
)
(
kube
t
ypes
.
DockerID
,
error
)
{
start
:=
time
.
Now
()
defer
func
()
{
metrics
.
ContainerManagerLatency
.
WithLabelValues
(
"createPodInfraContainer"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
...
...
@@ -1626,7 +1626,7 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
return
""
,
err
}
return
kube
letT
ypes
.
DockerID
(
id
.
ID
),
nil
return
kube
t
ypes
.
DockerID
(
id
.
ID
),
nil
}
// TODO(vmarmol): This will soon be made non-public when its only use is internal.
...
...
@@ -1643,9 +1643,9 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
type
empty
struct
{}
type
PodContainerChangesSpec
struct
{
StartInfraContainer
bool
InfraContainerId
kube
letT
ypes
.
DockerID
InfraContainerId
kube
t
ypes
.
DockerID
ContainersToStart
map
[
int
]
empty
ContainersToKeep
map
[
kube
letT
ypes
.
DockerID
]
int
ContainersToKeep
map
[
kube
t
ypes
.
DockerID
]
int
}
func
(
dm
*
DockerManager
)
computePodContainerChanges
(
pod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
podStatus
api
.
PodStatus
)
(
PodContainerChangesSpec
,
error
)
{
...
...
@@ -1659,10 +1659,10 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, runningPod kub
glog
.
V
(
4
)
.
Infof
(
"Syncing Pod %+v, podFullName: %q, uid: %q"
,
pod
,
podFullName
,
uid
)
containersToStart
:=
make
(
map
[
int
]
empty
)
containersToKeep
:=
make
(
map
[
kube
letT
ypes
.
DockerID
]
int
)
containersToKeep
:=
make
(
map
[
kube
t
ypes
.
DockerID
]
int
)
var
err
error
var
podInfraContainerID
kube
letT
ypes
.
DockerID
var
podInfraContainerID
kube
t
ypes
.
DockerID
var
changed
bool
podInfraContainer
:=
runningPod
.
FindContainerByName
(
PodInfraContainerName
)
if
podInfraContainer
!=
nil
{
...
...
@@ -1681,7 +1681,7 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, runningPod kub
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Pod infra container looks good, keep it %q"
,
podFullName
)
createPodInfraContainer
=
false
podInfraContainerID
=
kube
letT
ypes
.
DockerID
(
podInfraContainer
.
ID
.
ID
)
podInfraContainerID
=
kube
t
ypes
.
DockerID
(
podInfraContainer
.
ID
.
ID
)
containersToKeep
[
podInfraContainerID
]
=
-
1
}
...
...
@@ -1700,7 +1700,7 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, runningPod kub
continue
}
containerID
:=
kube
letT
ypes
.
DockerID
(
c
.
ID
.
ID
)
containerID
:=
kube
t
ypes
.
DockerID
(
c
.
ID
.
ID
)
hash
:=
c
.
Hash
glog
.
V
(
3
)
.
Infof
(
"pod %q container %q exists as %v"
,
podFullName
,
container
.
Name
,
containerID
)
...
...
@@ -1750,7 +1750,7 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, runningPod kub
// If Infra container is the last running one, we don't want to keep it.
if
!
createPodInfraContainer
&&
len
(
containersToStart
)
==
0
&&
len
(
containersToKeep
)
==
1
{
containersToKeep
=
make
(
map
[
kube
letT
ypes
.
DockerID
]
int
)
containersToKeep
=
make
(
map
[
kube
t
ypes
.
DockerID
]
int
)
}
return
PodContainerChangesSpec
{
...
...
@@ -1804,7 +1804,7 @@ func (dm *DockerManager) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, pod
}
else
{
// Otherwise kill any containers in this pod which are not specified as ones to keep.
for
_
,
container
:=
range
runningPod
.
Containers
{
_
,
keep
:=
containerChanges
.
ContainersToKeep
[
kube
letT
ypes
.
DockerID
(
container
.
ID
.
ID
)]
_
,
keep
:=
containerChanges
.
ContainersToKeep
[
kube
t
ypes
.
DockerID
(
container
.
ID
.
ID
)]
if
!
keep
{
glog
.
V
(
3
)
.
Infof
(
"Killing unwanted container %+v"
,
container
)
// attempt to find the appropriate container policy
...
...
pkg/kubelet/fake_pod_workers.go
View file @
a3e60cc3
...
...
@@ -19,7 +19,7 @@ package kubelet
import
(
"k8s.io/kubernetes/pkg/api"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/types"
)
...
...
@@ -31,12 +31,12 @@ type fakePodWorkers struct {
t
TestingInterface
}
func
(
f
*
fakePodWorkers
)
UpdatePod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
updateType
kube
letT
ypes
.
SyncPodType
,
updateComplete
func
())
{
func
(
f
*
fakePodWorkers
)
UpdatePod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
updateType
kube
t
ypes
.
SyncPodType
,
updateComplete
func
())
{
pods
,
err
:=
f
.
runtimeCache
.
GetPods
()
if
err
!=
nil
{
f
.
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
}
if
err
:=
f
.
syncPodFn
(
pod
,
mirrorPod
,
kubecontainer
.
Pods
(
pods
)
.
FindPodByID
(
pod
.
UID
),
kube
letT
ypes
.
SyncPodUpdate
);
err
!=
nil
{
if
err
:=
f
.
syncPodFn
(
pod
,
mirrorPod
,
kubecontainer
.
Pods
(
pods
)
.
FindPodByID
(
pod
.
UID
),
kube
t
ypes
.
SyncPodUpdate
);
err
!=
nil
{
f
.
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
}
}
...
...
pkg/kubelet/kubelet.go
View file @
a3e60cc3
...
...
@@ -55,7 +55,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/prober"
"k8s.io/kubernetes/pkg/kubelet/rkt"
"k8s.io/kubernetes/pkg/kubelet/status"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubeletUtil
"k8s.io/kubernetes/pkg/kubelet/util"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/probe"
...
...
@@ -462,7 +462,7 @@ type Kubelet struct {
// Optional, defaults to simple Docker implementation
runner
kubecontainer
.
ContainerCommandRunner
// Optional, client for http requests, defaults to empty client
httpClient
kube
letT
ypes
.
HttpGetter
httpClient
kube
t
ypes
.
HttpGetter
// cAdvisor used for container information.
cadvisor
cadvisor
.
Interface
...
...
@@ -777,7 +777,7 @@ func (kl *Kubelet) StartGarbageCollection() {
}
// Run starts the kubelet reacting to config updates
func
(
kl
*
Kubelet
)
Run
(
updates
<-
chan
kube
letT
ypes
.
PodUpdate
)
{
func
(
kl
*
Kubelet
)
Run
(
updates
<-
chan
kube
t
ypes
.
PodUpdate
)
{
if
kl
.
logServer
==
nil
{
kl
.
logServer
=
http
.
StripPrefix
(
"/logs/"
,
http
.
FileServer
(
http
.
Dir
(
"/var/log/"
)))
}
...
...
@@ -1248,15 +1248,15 @@ func (kl *Kubelet) makePodDataDirs(pod *api.Pod) error {
return
nil
}
func
(
kl
*
Kubelet
)
syncPod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kube
letT
ypes
.
SyncPodType
)
error
{
func
(
kl
*
Kubelet
)
syncPod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kube
t
ypes
.
SyncPodType
)
error
{
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
uid
:=
pod
.
UID
start
:=
time
.
Now
()
var
firstSeenTime
time
.
Time
if
firstSeenTimeStr
,
ok
:=
pod
.
Annotations
[
kube
letT
ypes
.
ConfigFirstSeenAnnotationKey
];
!
ok
{
if
firstSeenTimeStr
,
ok
:=
pod
.
Annotations
[
kube
t
ypes
.
ConfigFirstSeenAnnotationKey
];
!
ok
{
glog
.
V
(
3
)
.
Infof
(
"First seen time not recorded for pod %q"
,
pod
.
UID
)
}
else
{
firstSeenTime
=
kube
letT
ypes
.
ConvertToTimestamp
(
firstSeenTimeStr
)
.
Get
()
firstSeenTime
=
kube
t
ypes
.
ConvertToTimestamp
(
firstSeenTimeStr
)
.
Get
()
}
// Before returning, regenerate status and store it in the cache.
...
...
@@ -1332,7 +1332,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
// it's OK to pretend like the kubelet started them after it restarted.
var
podStatus
api
.
PodStatus
if
updateType
==
kube
letT
ypes
.
SyncPodCreate
{
if
updateType
==
kube
t
ypes
.
SyncPodCreate
{
// This is the first time we are syncing the pod. Record the latency
// since kubelet first saw the pod if firstSeenTime is set.
if
!
firstSeenTime
.
IsZero
()
{
...
...
@@ -1902,7 +1902,7 @@ func (kl *Kubelet) canAdmitPod(pods []*api.Pod, pod *api.Pod) (bool, string, str
// any new change seen, will run a sync against desired state and running state. If
// no changes are seen to the configuration, will synchronize the last known desired
// state every sync-frequency seconds. Never returns.
func
(
kl
*
Kubelet
)
syncLoop
(
updates
<-
chan
kube
letT
ypes
.
PodUpdate
,
handler
SyncHandler
)
{
func
(
kl
*
Kubelet
)
syncLoop
(
updates
<-
chan
kube
t
ypes
.
PodUpdate
,
handler
SyncHandler
)
{
glog
.
Info
(
"Starting kubelet main sync loop."
)
var
housekeepingTimestamp
time
.
Time
for
{
...
...
@@ -1944,7 +1944,7 @@ func (kl *Kubelet) syncLoop(updates <-chan kubeletTypes.PodUpdate, handler SyncH
}
}
func
(
kl
*
Kubelet
)
syncLoopIteration
(
updates
<-
chan
kube
letT
ypes
.
PodUpdate
,
handler
SyncHandler
)
bool
{
func
(
kl
*
Kubelet
)
syncLoopIteration
(
updates
<-
chan
kube
t
ypes
.
PodUpdate
,
handler
SyncHandler
)
bool
{
kl
.
syncLoopMonitor
.
Store
(
time
.
Now
())
select
{
case
u
,
open
:=
<-
updates
:
...
...
@@ -1954,16 +1954,16 @@ func (kl *Kubelet) syncLoopIteration(updates <-chan kubeletTypes.PodUpdate, hand
}
kl
.
addSource
(
u
.
Source
)
switch
u
.
Op
{
case
kube
letT
ypes
.
ADD
:
case
kube
t
ypes
.
ADD
:
glog
.
V
(
2
)
.
Infof
(
"SyncLoop (ADD): %q"
,
kubeletUtil
.
FormatPodNames
(
u
.
Pods
))
handler
.
HandlePodAdditions
(
u
.
Pods
)
case
kube
letT
ypes
.
UPDATE
:
case
kube
t
ypes
.
UPDATE
:
glog
.
V
(
2
)
.
Infof
(
"SyncLoop (UPDATE): %q"
,
kubeletUtil
.
FormatPodNames
(
u
.
Pods
))
handler
.
HandlePodUpdates
(
u
.
Pods
)
case
kube
letT
ypes
.
REMOVE
:
case
kube
t
ypes
.
REMOVE
:
glog
.
V
(
2
)
.
Infof
(
"SyncLoop (REMOVE): %q"
,
kubeletUtil
.
FormatPodNames
(
u
.
Pods
))
handler
.
HandlePodDeletions
(
u
.
Pods
)
case
kube
letT
ypes
.
SET
:
case
kube
t
ypes
.
SET
:
// TODO: Do we want to support this?
glog
.
Errorf
(
"Kubelet does not support snapshot update"
)
}
...
...
@@ -1976,7 +1976,7 @@ func (kl *Kubelet) syncLoopIteration(updates <-chan kubeletTypes.PodUpdate, hand
return
true
}
func
(
kl
*
Kubelet
)
dispatchWork
(
pod
*
api
.
Pod
,
syncType
kube
letT
ypes
.
SyncPodType
,
mirrorPod
*
api
.
Pod
,
start
time
.
Time
)
{
func
(
kl
*
Kubelet
)
dispatchWork
(
pod
*
api
.
Pod
,
syncType
kube
t
ypes
.
SyncPodType
,
mirrorPod
*
api
.
Pod
,
start
time
.
Time
)
{
if
kl
.
podIsTerminated
(
pod
)
{
return
}
...
...
@@ -1985,7 +1985,7 @@ func (kl *Kubelet) dispatchWork(pod *api.Pod, syncType kubeletTypes.SyncPodType,
metrics
.
PodWorkerLatency
.
WithLabelValues
(
syncType
.
String
())
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
})
// Note the number of containers for new pods.
if
syncType
==
kube
letT
ypes
.
SyncPodCreate
{
if
syncType
==
kube
t
ypes
.
SyncPodCreate
{
metrics
.
ContainersPerPodCount
.
Observe
(
float64
(
len
(
pod
.
Spec
.
Containers
)))
}
}
...
...
@@ -1996,7 +1996,7 @@ func (kl *Kubelet) handleMirrorPod(mirrorPod *api.Pod, start time.Time) {
// corresponding static pod. Send update to the pod worker if the static
// pod exists.
if
pod
,
ok
:=
kl
.
podManager
.
GetPodByMirrorPod
(
mirrorPod
);
ok
{
kl
.
dispatchWork
(
pod
,
kube
letT
ypes
.
SyncPodUpdate
,
mirrorPod
,
start
)
kl
.
dispatchWork
(
pod
,
kube
t
ypes
.
SyncPodUpdate
,
mirrorPod
,
start
)
}
}
...
...
@@ -2021,7 +2021,7 @@ func (kl *Kubelet) HandlePodAdditions(pods []*api.Pod) {
continue
}
mirrorPod
,
_
:=
kl
.
podManager
.
GetMirrorPodByPod
(
pod
)
kl
.
dispatchWork
(
pod
,
kube
letT
ypes
.
SyncPodCreate
,
mirrorPod
,
start
)
kl
.
dispatchWork
(
pod
,
kube
t
ypes
.
SyncPodCreate
,
mirrorPod
,
start
)
kl
.
probeManager
.
AddPod
(
pod
)
}
}
...
...
@@ -2037,7 +2037,7 @@ func (kl *Kubelet) HandlePodUpdates(pods []*api.Pod) {
// TODO: Evaluate if we need to validate and reject updates.
mirrorPod
,
_
:=
kl
.
podManager
.
GetMirrorPodByPod
(
pod
)
kl
.
dispatchWork
(
pod
,
kube
letT
ypes
.
SyncPodUpdate
,
mirrorPod
,
start
)
kl
.
dispatchWork
(
pod
,
kube
t
ypes
.
SyncPodUpdate
,
mirrorPod
,
start
)
}
}
...
...
@@ -2062,7 +2062,7 @@ func (kl *Kubelet) HandlePodSyncs(pods []*api.Pod) {
start
:=
time
.
Now
()
for
_
,
pod
:=
range
pods
{
mirrorPod
,
_
:=
kl
.
podManager
.
GetMirrorPodByPod
(
pod
)
kl
.
dispatchWork
(
pod
,
kube
letT
ypes
.
SyncPodSync
,
mirrorPod
,
start
)
kl
.
dispatchWork
(
pod
,
kube
t
ypes
.
SyncPodSync
,
mirrorPod
,
start
)
}
}
...
...
pkg/kubelet/kubelet_test.go
View file @
a3e60cc3
...
...
@@ -47,7 +47,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/network"
"k8s.io/kubernetes/pkg/kubelet/prober"
"k8s.io/kubernetes/pkg/kubelet/status"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -313,7 +313,7 @@ func TestKubeletDirsCompat(t *testing.T) {
}
}
var
emptyPodUIDs
map
[
types
.
UID
]
kube
letT
ypes
.
SyncPodType
var
emptyPodUIDs
map
[
types
.
UID
]
kube
t
ypes
.
SyncPodType
func
TestSyncLoopTimeUpdate
(
t
*
testing
.
T
)
{
testKubelet
:=
newTestKubelet
(
t
)
...
...
@@ -325,12 +325,12 @@ func TestSyncLoopTimeUpdate(t *testing.T) {
t
.
Errorf
(
"Unexpected sync loop time: %s, expected 0"
,
loopTime1
)
}
kubelet
.
syncLoopIteration
(
make
(
chan
kube
letT
ypes
.
PodUpdate
),
kubelet
)
kubelet
.
syncLoopIteration
(
make
(
chan
kube
t
ypes
.
PodUpdate
),
kubelet
)
loopTime2
:=
kubelet
.
LatestLoopEntryTime
()
if
loopTime2
.
IsZero
()
{
t
.
Errorf
(
"Unexpected sync loop time: 0, expected non-zero value."
)
}
kubelet
.
syncLoopIteration
(
make
(
chan
kube
letT
ypes
.
PodUpdate
),
kubelet
)
kubelet
.
syncLoopIteration
(
make
(
chan
kube
t
ypes
.
PodUpdate
),
kubelet
)
loopTime3
:=
kubelet
.
LatestLoopEntryTime
()
if
!
loopTime3
.
After
(
loopTime1
)
{
t
.
Errorf
(
"Sync Loop Time was not updated correctly. Second update timestamp should be greater than first update timestamp"
)
...
...
@@ -347,7 +347,7 @@ func TestSyncLoopAbort(t *testing.T) {
// the channel close
kubelet
.
resyncInterval
=
time
.
Second
*
30
ch
:=
make
(
chan
kube
letT
ypes
.
PodUpdate
)
ch
:=
make
(
chan
kube
t
ypes
.
PodUpdate
)
close
(
ch
)
// sanity check (also prevent this test from hanging in the next step)
...
...
@@ -2659,7 +2659,7 @@ func TestUpdateNodeStatusError(t *testing.T) {
}
func
TestCreateMirrorPod
(
t
*
testing
.
T
)
{
for
_
,
updateType
:=
range
[]
kube
letTypes
.
SyncPodType
{
kubeletTypes
.
SyncPodCreate
,
kubeletT
ypes
.
SyncPodUpdate
}
{
for
_
,
updateType
:=
range
[]
kube
types
.
SyncPodType
{
kubetypes
.
SyncPodCreate
,
kubet
ypes
.
SyncPodUpdate
}
{
testKubelet
:=
newTestKubelet
(
t
)
kl
:=
testKubelet
.
kubelet
manager
:=
testKubelet
.
fakeMirrorClient
...
...
@@ -2669,7 +2669,7 @@ func TestCreateMirrorPod(t *testing.T) {
Name
:
"bar"
,
Namespace
:
"foo"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"file"
,
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"file"
,
},
},
}
...
...
@@ -2702,7 +2702,7 @@ func TestDeleteOutdatedMirrorPod(t *testing.T) {
Name
:
"foo"
,
Namespace
:
"ns"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"file"
,
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"file"
,
},
},
Spec
:
api
.
PodSpec
{
...
...
@@ -2718,8 +2718,8 @@ func TestDeleteOutdatedMirrorPod(t *testing.T) {
Name
:
"foo"
,
Namespace
:
"ns"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
letT
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
t
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
},
},
Spec
:
api
.
PodSpec
{
...
...
@@ -2731,7 +2731,7 @@ func TestDeleteOutdatedMirrorPod(t *testing.T) {
pods
:=
[]
*
api
.
Pod
{
pod
,
mirrorPod
}
kl
.
podManager
.
SetPods
(
pods
)
err
:=
kl
.
syncPod
(
pod
,
mirrorPod
,
container
.
Pod
{},
kube
letT
ypes
.
SyncPodUpdate
)
err
:=
kl
.
syncPod
(
pod
,
mirrorPod
,
container
.
Pod
{},
kube
t
ypes
.
SyncPodUpdate
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
...
...
@@ -2756,8 +2756,8 @@ func TestDeleteOrphanedMirrorPods(t *testing.T) {
Name
:
"pod1"
,
Namespace
:
"ns"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
letT
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
t
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
},
},
},
...
...
@@ -2767,8 +2767,8 @@ func TestDeleteOrphanedMirrorPods(t *testing.T) {
Name
:
"pod2"
,
Namespace
:
"ns"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
letT
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
t
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
},
},
},
...
...
@@ -2799,7 +2799,7 @@ func TestGetContainerInfoForMirrorPods(t *testing.T) {
Name
:
"qux"
,
Namespace
:
"ns"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"file"
,
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"file"
,
},
},
Spec
:
api
.
PodSpec
{
...
...
@@ -2814,8 +2814,8 @@ func TestGetContainerInfoForMirrorPods(t *testing.T) {
Name
:
"qux"
,
Namespace
:
"ns"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
letT
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
t
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
},
},
Spec
:
api
.
PodSpec
{
...
...
@@ -2881,7 +2881,7 @@ func TestDoNotCacheStatusForStaticPods(t *testing.T) {
Name
:
"staticFoo"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"file"
,
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"file"
,
},
},
Spec
:
api
.
PodSpec
{
...
...
@@ -2906,7 +2906,7 @@ func TestHostNetworkAllowed(t *testing.T) {
capabilities
.
SetForTests
(
capabilities
.
Capabilities
{
PrivilegedSources
:
capabilities
.
PrivilegedSources
{
HostNetworkSources
:
[]
string
{
kube
letTypes
.
ApiserverSource
,
kubeletT
ypes
.
FileSource
},
HostNetworkSources
:
[]
string
{
kube
types
.
ApiserverSource
,
kubet
ypes
.
FileSource
},
},
})
pod
:=
&
api
.
Pod
{
...
...
@@ -2915,7 +2915,7 @@ func TestHostNetworkAllowed(t *testing.T) {
Name
:
"foo"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
kube
letTypes
.
ConfigSourceAnnotationKey
:
kubeletT
ypes
.
FileSource
,
kube
types
.
ConfigSourceAnnotationKey
:
kubet
ypes
.
FileSource
,
},
},
Spec
:
api
.
PodSpec
{
...
...
@@ -2928,7 +2928,7 @@ func TestHostNetworkAllowed(t *testing.T) {
},
}
kubelet
.
podManager
.
SetPods
([]
*
api
.
Pod
{
pod
})
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{},
kube
letT
ypes
.
SyncPodUpdate
)
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{},
kube
t
ypes
.
SyncPodUpdate
)
if
err
!=
nil
{
t
.
Errorf
(
"expected pod infra creation to succeed: %v"
,
err
)
}
...
...
@@ -2949,7 +2949,7 @@ func TestHostNetworkDisallowed(t *testing.T) {
Name
:
"foo"
,
Namespace
:
"new"
,
Annotations
:
map
[
string
]
string
{
kube
letTypes
.
ConfigSourceAnnotationKey
:
kubeletT
ypes
.
FileSource
,
kube
types
.
ConfigSourceAnnotationKey
:
kubet
ypes
.
FileSource
,
},
},
Spec
:
api
.
PodSpec
{
...
...
@@ -2961,7 +2961,7 @@ func TestHostNetworkDisallowed(t *testing.T) {
},
},
}
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{},
kube
letT
ypes
.
SyncPodUpdate
)
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{},
kube
t
ypes
.
SyncPodUpdate
)
if
err
==
nil
{
t
.
Errorf
(
"expected pod infra creation to fail"
)
}
...
...
@@ -2988,7 +2988,7 @@ func TestPrivilegeContainerAllowed(t *testing.T) {
},
}
kubelet
.
podManager
.
SetPods
([]
*
api
.
Pod
{
pod
})
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{},
kube
letT
ypes
.
SyncPodUpdate
)
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{},
kube
t
ypes
.
SyncPodUpdate
)
if
err
!=
nil
{
t
.
Errorf
(
"expected pod infra creation to succeed: %v"
,
err
)
}
...
...
@@ -3014,7 +3014,7 @@ func TestPrivilegeContainerDisallowed(t *testing.T) {
},
},
}
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{},
kube
letT
ypes
.
SyncPodUpdate
)
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{},
kube
t
ypes
.
SyncPodUpdate
)
if
err
==
nil
{
t
.
Errorf
(
"expected pod infra creation to fail"
)
}
...
...
pkg/kubelet/lifecycle/handlers.go
View file @
a3e60cc3
...
...
@@ -24,12 +24,12 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util"
)
type
HandlerRunner
struct
{
httpGetter
kube
letT
ypes
.
HttpGetter
httpGetter
kube
t
ypes
.
HttpGetter
commandRunner
kubecontainer
.
ContainerCommandRunner
containerManager
podStatusProvider
}
...
...
@@ -38,7 +38,7 @@ type podStatusProvider interface {
GetPodStatus
(
pod
*
api
.
Pod
)
(
*
api
.
PodStatus
,
error
)
}
func
NewHandlerRunner
(
httpGetter
kube
letT
ypes
.
HttpGetter
,
commandRunner
kubecontainer
.
ContainerCommandRunner
,
containerManager
podStatusProvider
)
kubecontainer
.
HandlerRunner
{
func
NewHandlerRunner
(
httpGetter
kube
t
ypes
.
HttpGetter
,
commandRunner
kubecontainer
.
ContainerCommandRunner
,
containerManager
podStatusProvider
)
kubecontainer
.
HandlerRunner
{
return
&
HandlerRunner
{
httpGetter
:
httpGetter
,
commandRunner
:
commandRunner
,
...
...
pkg/kubelet/mirror_client.go
View file @
a3e60cc3
...
...
@@ -23,7 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
client
"k8s.io/kubernetes/pkg/client/unversioned"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
)
// Mirror client is used to create/delete a mirror pod.
...
...
@@ -55,7 +55,7 @@ func (mc *basicMirrorClient) CreateMirrorPod(pod *api.Pod) error {
for
k
,
v
:=
range
pod
.
Annotations
{
copyPod
.
Annotations
[
k
]
=
v
}
copyPod
.
Annotations
[
kube
letTypes
.
ConfigMirrorAnnotationKey
]
=
kubeletT
ypes
.
MirrorType
copyPod
.
Annotations
[
kube
types
.
ConfigMirrorAnnotationKey
]
=
kubet
ypes
.
MirrorType
_
,
err
:=
mc
.
apiserverClient
.
Pods
(
copyPod
.
Namespace
)
.
Create
(
&
copyPod
)
return
err
...
...
@@ -81,7 +81,7 @@ func (mc *basicMirrorClient) DeleteMirrorPod(podFullName string) error {
// Helper functions.
func
getPodSource
(
pod
*
api
.
Pod
)
(
string
,
error
)
{
if
pod
.
Annotations
!=
nil
{
if
source
,
ok
:=
pod
.
Annotations
[
kube
letT
ypes
.
ConfigSourceAnnotationKey
];
ok
{
if
source
,
ok
:=
pod
.
Annotations
[
kube
t
ypes
.
ConfigSourceAnnotationKey
];
ok
{
return
source
,
nil
}
}
...
...
@@ -90,13 +90,13 @@ func getPodSource(pod *api.Pod) (string, error) {
func
isStaticPod
(
pod
*
api
.
Pod
)
bool
{
source
,
err
:=
getPodSource
(
pod
)
return
err
==
nil
&&
source
!=
kube
letT
ypes
.
ApiserverSource
return
err
==
nil
&&
source
!=
kube
t
ypes
.
ApiserverSource
}
func
isMirrorPod
(
pod
*
api
.
Pod
)
bool
{
if
value
,
ok
:=
pod
.
Annotations
[
kube
letT
ypes
.
ConfigMirrorAnnotationKey
];
!
ok
{
if
value
,
ok
:=
pod
.
Annotations
[
kube
t
ypes
.
ConfigMirrorAnnotationKey
];
!
ok
{
return
false
}
else
{
return
value
==
kube
letT
ypes
.
MirrorType
return
value
==
kube
t
ypes
.
MirrorType
}
}
pkg/kubelet/network/cni/cni.go
View file @
a3e60cc3
...
...
@@ -28,7 +28,7 @@ import (
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/kubelet/network"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
)
const
(
...
...
@@ -102,7 +102,7 @@ func (plugin *cniNetworkPlugin) Name() string {
return
CNIPluginName
}
func
(
plugin
*
cniNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kube
letT
ypes
.
DockerID
)
error
{
func
(
plugin
*
cniNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kube
t
ypes
.
DockerID
)
error
{
runtime
,
ok
:=
plugin
.
host
.
GetRuntime
()
.
(
*
dockertools
.
DockerManager
)
if
!
ok
{
return
fmt
.
Errorf
(
"CNI execution called on non-docker runtime"
)
...
...
@@ -121,7 +121,7 @@ func (plugin *cniNetworkPlugin) SetUpPod(namespace string, name string, id kubel
return
err
}
func
(
plugin
*
cniNetworkPlugin
)
TearDownPod
(
namespace
string
,
name
string
,
id
kube
letT
ypes
.
DockerID
)
error
{
func
(
plugin
*
cniNetworkPlugin
)
TearDownPod
(
namespace
string
,
name
string
,
id
kube
t
ypes
.
DockerID
)
error
{
runtime
,
ok
:=
plugin
.
host
.
GetRuntime
()
.
(
*
dockertools
.
DockerManager
)
if
!
ok
{
return
fmt
.
Errorf
(
"CNI execution called on non-docker runtime"
)
...
...
@@ -136,7 +136,7 @@ func (plugin *cniNetworkPlugin) TearDownPod(namespace string, name string, id ku
// TODO: Use the addToNetwork function to obtain the IP of the Pod. That will assume idempotent ADD call to the plugin.
// Also fix the runtime's call to Status function to be done only in the case that the IP is lost, no need to do periodic calls
func
(
plugin
*
cniNetworkPlugin
)
Status
(
namespace
string
,
name
string
,
id
kube
letT
ypes
.
DockerID
)
(
*
network
.
PodNetworkStatus
,
error
)
{
func
(
plugin
*
cniNetworkPlugin
)
Status
(
namespace
string
,
name
string
,
id
kube
t
ypes
.
DockerID
)
(
*
network
.
PodNetworkStatus
,
error
)
{
runtime
,
ok
:=
plugin
.
host
.
GetRuntime
()
.
(
*
dockertools
.
DockerManager
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"CNI execution called on non-docker runtime"
)
...
...
pkg/kubelet/network/exec/exec.go
View file @
a3e60cc3
...
...
@@ -67,7 +67,7 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/kubelet/network"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
utilexec
"k8s.io/kubernetes/pkg/util/exec"
)
...
...
@@ -132,19 +132,19 @@ func (plugin *execNetworkPlugin) validate() error {
return
nil
}
func
(
plugin
*
execNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kube
letT
ypes
.
DockerID
)
error
{
func
(
plugin
*
execNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kube
t
ypes
.
DockerID
)
error
{
out
,
err
:=
utilexec
.
New
()
.
Command
(
plugin
.
getExecutable
(),
setUpCmd
,
namespace
,
name
,
string
(
id
))
.
CombinedOutput
()
glog
.
V
(
5
)
.
Infof
(
"SetUpPod 'exec' network plugin output: %s, %v"
,
string
(
out
),
err
)
return
err
}
func
(
plugin
*
execNetworkPlugin
)
TearDownPod
(
namespace
string
,
name
string
,
id
kube
letT
ypes
.
DockerID
)
error
{
func
(
plugin
*
execNetworkPlugin
)
TearDownPod
(
namespace
string
,
name
string
,
id
kube
t
ypes
.
DockerID
)
error
{
out
,
err
:=
utilexec
.
New
()
.
Command
(
plugin
.
getExecutable
(),
tearDownCmd
,
namespace
,
name
,
string
(
id
))
.
CombinedOutput
()
glog
.
V
(
5
)
.
Infof
(
"TearDownPod 'exec' network plugin output: %s, %v"
,
string
(
out
),
err
)
return
err
}
func
(
plugin
*
execNetworkPlugin
)
Status
(
namespace
string
,
name
string
,
id
kube
letT
ypes
.
DockerID
)
(
*
network
.
PodNetworkStatus
,
error
)
{
func
(
plugin
*
execNetworkPlugin
)
Status
(
namespace
string
,
name
string
,
id
kube
t
ypes
.
DockerID
)
(
*
network
.
PodNetworkStatus
,
error
)
{
out
,
err
:=
utilexec
.
New
()
.
Command
(
plugin
.
getExecutable
(),
statusCmd
,
namespace
,
name
,
string
(
id
))
.
CombinedOutput
()
glog
.
V
(
5
)
.
Infof
(
"Status 'exec' network plugin output: %s, %v"
,
string
(
out
),
err
)
if
err
!=
nil
{
...
...
pkg/kubelet/network/plugins.go
View file @
a3e60cc3
...
...
@@ -26,7 +26,7 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/validation"
)
...
...
@@ -46,13 +46,13 @@ type NetworkPlugin interface {
// SetUpPod is the method called after the infra container of
// the pod has been created but before the other containers of the
// pod are launched.
SetUpPod
(
namespace
string
,
name
string
,
podInfraContainerID
kube
letT
ypes
.
DockerID
)
error
SetUpPod
(
namespace
string
,
name
string
,
podInfraContainerID
kube
t
ypes
.
DockerID
)
error
// TearDownPod is the method called before a pod's infra container will be deleted
TearDownPod
(
namespace
string
,
name
string
,
podInfraContainerID
kube
letT
ypes
.
DockerID
)
error
TearDownPod
(
namespace
string
,
name
string
,
podInfraContainerID
kube
t
ypes
.
DockerID
)
error
// Status is the method called to obtain the ipv4 or ipv6 addresses of the container
Status
(
namespace
string
,
name
string
,
podInfraContainerID
kube
letT
ypes
.
DockerID
)
(
*
PodNetworkStatus
,
error
)
Status
(
namespace
string
,
name
string
,
podInfraContainerID
kube
t
ypes
.
DockerID
)
(
*
PodNetworkStatus
,
error
)
}
// PodNetworkStatus stores the network status of a pod (currently just the primary IP address)
...
...
@@ -134,14 +134,14 @@ func (plugin *noopNetworkPlugin) Name() string {
return
DefaultPluginName
}
func
(
plugin
*
noopNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kube
letT
ypes
.
DockerID
)
error
{
func
(
plugin
*
noopNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kube
t
ypes
.
DockerID
)
error
{
return
nil
}
func
(
plugin
*
noopNetworkPlugin
)
TearDownPod
(
namespace
string
,
name
string
,
id
kube
letT
ypes
.
DockerID
)
error
{
func
(
plugin
*
noopNetworkPlugin
)
TearDownPod
(
namespace
string
,
name
string
,
id
kube
t
ypes
.
DockerID
)
error
{
return
nil
}
func
(
plugin
*
noopNetworkPlugin
)
Status
(
namespace
string
,
name
string
,
id
kube
letT
ypes
.
DockerID
)
(
*
PodNetworkStatus
,
error
)
{
func
(
plugin
*
noopNetworkPlugin
)
Status
(
namespace
string
,
name
string
,
id
kube
t
ypes
.
DockerID
)
(
*
PodNetworkStatus
,
error
)
{
return
nil
,
nil
}
pkg/kubelet/pod_manager_test.go
View file @
a3e60cc3
...
...
@@ -21,7 +21,7 @@ import (
"testing"
"k8s.io/kubernetes/pkg/api"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
)
// Stub out mirror client for testing purpose.
...
...
@@ -41,8 +41,8 @@ func TestGetSetPods(t *testing.T) {
Name
:
"bar"
,
Namespace
:
"default"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
letT
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"api"
,
kube
t
ypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
},
},
}
...
...
@@ -51,7 +51,7 @@ func TestGetSetPods(t *testing.T) {
UID
:
"123456789"
,
Name
:
"bar"
,
Namespace
:
"default"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"file"
},
Annotations
:
map
[
string
]
string
{
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"file"
},
},
}
...
...
@@ -61,7 +61,7 @@ func TestGetSetPods(t *testing.T) {
UID
:
"999999999"
,
Name
:
"taco"
,
Namespace
:
"default"
,
Annotations
:
map
[
string
]
string
{
kube
letT
ypes
.
ConfigSourceAnnotationKey
:
"api"
},
Annotations
:
map
[
string
]
string
{
kube
t
ypes
.
ConfigSourceAnnotationKey
:
"api"
},
},
},
staticPod
,
...
...
pkg/kubelet/pod_workers.go
View file @
a3e60cc3
...
...
@@ -24,19 +24,19 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/record"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
)
// PodWorkers is an abstract interface for testability.
type
PodWorkers
interface
{
UpdatePod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
updateType
kube
letT
ypes
.
SyncPodType
,
updateComplete
func
())
UpdatePod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
updateType
kube
t
ypes
.
SyncPodType
,
updateComplete
func
())
ForgetNonExistingPodWorkers
(
desiredPods
map
[
types
.
UID
]
empty
)
ForgetWorker
(
uid
types
.
UID
)
}
type
syncPodFnType
func
(
*
api
.
Pod
,
*
api
.
Pod
,
kubecontainer
.
Pod
,
kube
letT
ypes
.
SyncPodType
)
error
type
syncPodFnType
func
(
*
api
.
Pod
,
*
api
.
Pod
,
kubecontainer
.
Pod
,
kube
t
ypes
.
SyncPodType
)
error
type
podWorkers
struct
{
// Protects all per worker fields.
...
...
@@ -75,7 +75,7 @@ type workUpdate struct {
updateCompleteFn
func
()
// A string describing the type of this update, eg: create
updateType
kube
letT
ypes
.
SyncPodType
updateType
kube
t
ypes
.
SyncPodType
}
func
newPodWorkers
(
runtimeCache
kubecontainer
.
RuntimeCache
,
syncPodFn
syncPodFnType
,
...
...
@@ -122,7 +122,7 @@ func (p *podWorkers) managePodLoop(podUpdates <-chan workUpdate) {
}
// Apply the new setting to the specified pod. updateComplete is called when the update is completed.
func
(
p
*
podWorkers
)
UpdatePod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
updateType
kube
letT
ypes
.
SyncPodType
,
updateComplete
func
())
{
func
(
p
*
podWorkers
)
UpdatePod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
updateType
kube
t
ypes
.
SyncPodType
,
updateComplete
func
())
{
uid
:=
pod
.
UID
var
podUpdates
chan
workUpdate
var
exists
bool
...
...
pkg/kubelet/pod_workers_test.go
View file @
a3e60cc3
...
...
@@ -30,7 +30,7 @@ import (
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/kubelet/network"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/types"
)
...
...
@@ -57,7 +57,7 @@ func createPodWorkers() (*podWorkers, map[types.UID][]string) {
fakeRuntimeCache
:=
createFakeRuntimeCache
(
fakeRecorder
)
podWorkers
:=
newPodWorkers
(
fakeRuntimeCache
,
func
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kube
letT
ypes
.
SyncPodType
)
error
{
func
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kube
t
ypes
.
SyncPodType
)
error
{
func
()
{
lock
.
Lock
()
defer
lock
.
Unlock
()
...
...
@@ -94,7 +94,7 @@ func TestUpdatePod(t *testing.T) {
numPods
:=
20
for
i
:=
0
;
i
<
numPods
;
i
++
{
for
j
:=
i
;
j
<
numPods
;
j
++
{
podWorkers
.
UpdatePod
(
newPod
(
string
(
j
),
string
(
i
)),
nil
,
kube
letT
ypes
.
SyncPodCreate
,
func
()
{})
podWorkers
.
UpdatePod
(
newPod
(
string
(
j
),
string
(
i
)),
nil
,
kube
t
ypes
.
SyncPodCreate
,
func
()
{})
}
}
drainWorkers
(
podWorkers
,
numPods
)
...
...
@@ -127,7 +127,7 @@ func TestForgetNonExistingPodWorkers(t *testing.T) {
numPods
:=
20
for
i
:=
0
;
i
<
numPods
;
i
++
{
podWorkers
.
UpdatePod
(
newPod
(
string
(
i
),
"name"
),
nil
,
kube
letT
ypes
.
SyncPodUpdate
,
func
()
{})
podWorkers
.
UpdatePod
(
newPod
(
string
(
i
),
"name"
),
nil
,
kube
t
ypes
.
SyncPodUpdate
,
func
()
{})
}
drainWorkers
(
podWorkers
,
numPods
)
...
...
@@ -163,12 +163,12 @@ type simpleFakeKubelet struct {
wg
sync
.
WaitGroup
}
func
(
kl
*
simpleFakeKubelet
)
syncPod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kube
letT
ypes
.
SyncPodType
)
error
{
func
(
kl
*
simpleFakeKubelet
)
syncPod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kube
t
ypes
.
SyncPodType
)
error
{
kl
.
pod
,
kl
.
mirrorPod
,
kl
.
runningPod
=
pod
,
mirrorPod
,
runningPod
return
nil
}
func
(
kl
*
simpleFakeKubelet
)
syncPodWithWaitGroup
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kube
letT
ypes
.
SyncPodType
)
error
{
func
(
kl
*
simpleFakeKubelet
)
syncPodWithWaitGroup
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kube
t
ypes
.
SyncPodType
)
error
{
kl
.
pod
,
kl
.
mirrorPod
,
kl
.
runningPod
=
pod
,
mirrorPod
,
runningPod
kl
.
wg
.
Done
()
return
nil
...
...
@@ -354,8 +354,8 @@ func TestFakePodWorkers(t *testing.T) {
kubeletForRealWorkers
.
wg
.
Add
(
1
)
fakeDocker
.
ContainerList
=
tt
.
containerList
realPodWorkers
.
UpdatePod
(
tt
.
pod
,
tt
.
mirrorPod
,
kube
letT
ypes
.
SyncPodUpdate
,
func
()
{})
fakePodWorkers
.
UpdatePod
(
tt
.
pod
,
tt
.
mirrorPod
,
kube
letT
ypes
.
SyncPodUpdate
,
func
()
{})
realPodWorkers
.
UpdatePod
(
tt
.
pod
,
tt
.
mirrorPod
,
kube
t
ypes
.
SyncPodUpdate
,
func
()
{})
fakePodWorkers
.
UpdatePod
(
tt
.
pod
,
tt
.
mirrorPod
,
kube
t
ypes
.
SyncPodUpdate
,
func
()
{})
kubeletForRealWorkers
.
wg
.
Wait
()
...
...
pkg/kubelet/runonce.go
View file @
a3e60cc3
...
...
@@ -24,7 +24,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
)
const
(
...
...
@@ -40,7 +40,7 @@ type RunPodResult struct {
}
// RunOnce polls from one configuration update and run the associated pods.
func
(
kl
*
Kubelet
)
RunOnce
(
updates
<-
chan
kube
letT
ypes
.
PodUpdate
)
([]
RunPodResult
,
error
)
{
func
(
kl
*
Kubelet
)
RunOnce
(
updates
<-
chan
kube
t
ypes
.
PodUpdate
)
([]
RunPodResult
,
error
)
{
select
{
case
u
:=
<-
updates
:
glog
.
Infof
(
"processing manifest with %d pods"
,
len
(
u
.
Pods
))
...
...
@@ -110,7 +110,7 @@ func (kl *Kubelet) runPod(pod *api.Pod, retryDelay time.Duration) error {
glog
.
Infof
(
"pod %q containers not running: syncing"
,
pod
.
Name
)
// We don't create mirror pods in this mode; pass a dummy boolean value
// to sycnPod.
if
err
=
kl
.
syncPod
(
pod
,
nil
,
p
,
kube
letT
ypes
.
SyncPodUpdate
);
err
!=
nil
{
if
err
=
kl
.
syncPod
(
pod
,
nil
,
p
,
kube
t
ypes
.
SyncPodUpdate
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error syncing pod: %v"
,
err
)
}
if
retry
>=
RunOnceMaxRetries
{
...
...
pkg/kubelet/server_test.go
View file @
a3e60cc3
...
...
@@ -40,7 +40,7 @@ import (
"k8s.io/kubernetes/pkg/auth/user"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/httpstream"
"k8s.io/kubernetes/pkg/util/httpstream/spdy"
...
...
@@ -211,7 +211,7 @@ func readResp(resp *http.Response) (string, error) {
// A helper function to return the correct pod name.
func
getPodName
(
name
,
namespace
string
)
string
{
if
namespace
==
""
{
namespace
=
kube
letT
ypes
.
NamespaceDefault
namespace
=
kube
t
ypes
.
NamespaceDefault
}
return
name
+
"_"
+
namespace
}
...
...
pkg/kubelet/status/manager.go
View file @
a3e60cc3
...
...
@@ -27,7 +27,7 @@ import (
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
kube
letT
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kube
t
ypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubeletUtil
"k8s.io/kubernetes/pkg/kubelet/util"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -85,8 +85,8 @@ func NewManager(kubeClient client.Interface) Manager {
// isStatusEqual returns true if the given pod statuses are equal, false otherwise.
// This method sorts container statuses so order does not affect equality.
func
isStatusEqual
(
oldStatus
,
status
*
api
.
PodStatus
)
bool
{
sort
.
Sort
(
kube
letT
ypes
.
SortedContainerStatuses
(
status
.
ContainerStatuses
))
sort
.
Sort
(
kube
letT
ypes
.
SortedContainerStatuses
(
oldStatus
.
ContainerStatuses
))
sort
.
Sort
(
kube
t
ypes
.
SortedContainerStatuses
(
status
.
ContainerStatuses
))
sort
.
Sort
(
kube
t
ypes
.
SortedContainerStatuses
(
oldStatus
.
ContainerStatuses
))
// TODO: More sophisticated equality checking.
return
reflect
.
DeepEqual
(
status
,
oldStatus
)
...
...
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