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