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
d6004a1c
Commit
d6004a1c
authored
Jun 04, 2015
by
Quinton Hoole
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9279 from yifan-gu/refactor
kubelet: Minor refactors.
parents
950df31c
f197a9db
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
29 additions
and
40 deletions
+29
-40
fuzzer.go
pkg/api/testing/fuzzer.go
+1
-1
runtime_cache.go
pkg/kubelet/container/runtime_cache.go
+0
-2
container_gc.go
pkg/kubelet/container_gc.go
+1
-1
container_gc_test.go
pkg/kubelet/container_gc_test.go
+1
-1
exec.go
pkg/kubelet/dockertools/exec.go
+1
-1
fake_docker_client.go
pkg/kubelet/dockertools/fake_docker_client.go
+1
-1
fake_manager.go
pkg/kubelet/dockertools/fake_manager.go
+1
-1
instrumented_docker.go
pkg/kubelet/dockertools/instrumented_docker.go
+1
-1
manager.go
pkg/kubelet/dockertools/manager.go
+11
-14
manager_test.go
pkg/kubelet/dockertools/manager_test.go
+8
-8
kubelet.go
pkg/kubelet/kubelet.go
+0
-1
kubelet_test.go
pkg/kubelet/kubelet_test.go
+2
-7
pod_workers_test.go
pkg/kubelet/pod_workers_test.go
+1
-1
No files found.
pkg/api/testing/fuzzer.go
View file @
d6004a1c
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"github.com/google/gofuzz"
"github.com/google/gofuzz"
"speter.net/go/exp/math/dec/inf"
"speter.net/go/exp/math/dec/inf"
...
...
pkg/kubelet/container/runtime_cache.go
View file @
d6004a1c
...
@@ -32,8 +32,6 @@ type RuntimeCache interface {
...
@@ -32,8 +32,6 @@ type RuntimeCache interface {
ForceUpdateIfOlder
(
time
.
Time
)
error
ForceUpdateIfOlder
(
time
.
Time
)
error
}
}
// TODO(yifan): This interface can be removed once docker manager has implemented
// all the runtime interfaces, (thus we can pass the runtime directly).
type
podsGetter
interface
{
type
podsGetter
interface
{
GetPods
(
bool
)
([]
*
Pod
,
error
)
GetPods
(
bool
)
([]
*
Pod
,
error
)
}
}
...
...
pkg/kubelet/container_gc.go
View file @
d6004a1c
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
...
pkg/kubelet/container_gc_test.go
View file @
d6004a1c
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"time"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
...
...
pkg/kubelet/dockertools/exec.go
View file @
d6004a1c
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
"time"
"time"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
)
)
// ExecHandler knows how to execute a command in a running Docker container.
// ExecHandler knows how to execute a command in a running Docker container.
...
...
pkg/kubelet/dockertools/fake_docker_client.go
View file @
d6004a1c
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
"sort"
"sort"
"sync"
"sync"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
...
...
pkg/kubelet/dockertools/fake_manager.go
View file @
d6004a1c
...
@@ -41,7 +41,7 @@ func NewFakeDockerManager(
...
@@ -41,7 +41,7 @@ func NewFakeDockerManager(
dm
:=
NewDockerManager
(
client
,
recorder
,
readinessManager
,
containerRefManager
,
podInfraContainerImage
,
qps
,
dm
:=
NewDockerManager
(
client
,
recorder
,
readinessManager
,
containerRefManager
,
podInfraContainerImage
,
qps
,
burst
,
containerLogsDir
,
osInterface
,
networkPlugin
,
generator
,
httpClient
,
runtimeHooks
,
&
NativeExecHandler
{})
burst
,
containerLogsDir
,
osInterface
,
networkPlugin
,
generator
,
httpClient
,
runtimeHooks
,
&
NativeExecHandler
{})
dm
.
P
uller
=
&
FakeDockerPuller
{}
dm
.
p
uller
=
&
FakeDockerPuller
{}
dm
.
prober
=
prober
.
New
(
nil
,
readinessManager
,
containerRefManager
,
recorder
)
dm
.
prober
=
prober
.
New
(
nil
,
readinessManager
,
containerRefManager
,
recorder
)
return
dm
return
dm
}
}
pkg/kubelet/dockertools/instrumented_docker.go
View file @
d6004a1c
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"time"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/metrics"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/metrics"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
)
)
type
instrumentedDockerInterface
struct
{
type
instrumentedDockerInterface
struct
{
...
...
pkg/kubelet/dockertools/manager.go
View file @
d6004a1c
...
@@ -68,9 +68,8 @@ type DockerManager struct {
...
@@ -68,9 +68,8 @@ type DockerManager struct {
containerRefManager
*
kubecontainer
.
RefManager
containerRefManager
*
kubecontainer
.
RefManager
os
kubecontainer
.
OSInterface
os
kubecontainer
.
OSInterface
// TODO(yifan): PodInfraContainerImage can be unexported once
// The image name of the pod infra container.
// we move createPodInfraContainer into dockertools.
podInfraContainerImage
string
PodInfraContainerImage
string
// reasonCache stores the failure reason of the last container creation
// reasonCache stores the failure reason of the last container creation
// and/or start in a string, keyed by <pod_UID>_<container_name>. The goal
// and/or start in a string, keyed by <pod_UID>_<container_name>. The goal
// is to propagate this reason to the container status. This endeavor is
// is to propagate this reason to the container status. This endeavor is
...
@@ -80,11 +79,9 @@ type DockerManager struct {
...
@@ -80,11 +79,9 @@ type DockerManager struct {
// means that some entries may be recycled before a pod has been
// means that some entries may be recycled before a pod has been
// deleted.
// deleted.
reasonCache
stringCache
reasonCache
stringCache
// TODO(yifan): We export this for testability, so when we have a fake
// TODO(yifan): Record the pull failure so we can eliminate the image checking
// container manager, then we can unexport this. Also at that time, we
// in GetPodStatus()?
// use the concrete type so that we can record the pull failure and eliminate
puller
DockerPuller
// the image checking in GetPodStatus().
Puller
DockerPuller
// Root of the Docker runtime.
// Root of the Docker runtime.
dockerRoot
string
dockerRoot
string
...
@@ -164,9 +161,9 @@ func NewDockerManager(
...
@@ -164,9 +161,9 @@ func NewDockerManager(
readinessManager
:
readinessManager
,
readinessManager
:
readinessManager
,
containerRefManager
:
containerRefManager
,
containerRefManager
:
containerRefManager
,
os
:
osInterface
,
os
:
osInterface
,
P
odInfraContainerImage
:
podInfraContainerImage
,
p
odInfraContainerImage
:
podInfraContainerImage
,
reasonCache
:
reasonCache
,
reasonCache
:
reasonCache
,
P
uller
:
newDockerPuller
(
client
,
qps
,
burst
),
p
uller
:
newDockerPuller
(
client
,
qps
,
burst
),
dockerRoot
:
dockerRoot
,
dockerRoot
:
dockerRoot
,
containerLogsDir
:
containerLogsDir
,
containerLogsDir
:
containerLogsDir
,
networkPlugin
:
networkPlugin
,
networkPlugin
:
networkPlugin
,
...
@@ -784,12 +781,12 @@ func (dm *DockerManager) ListImages() ([]kubecontainer.Image, error) {
...
@@ -784,12 +781,12 @@ func (dm *DockerManager) ListImages() ([]kubecontainer.Image, error) {
// TODO(vmarmol): Consider unexporting.
// TODO(vmarmol): Consider unexporting.
// PullImage pulls an image from network to local storage.
// PullImage pulls an image from network to local storage.
func
(
dm
*
DockerManager
)
PullImage
(
image
kubecontainer
.
ImageSpec
,
secrets
[]
api
.
Secret
)
error
{
func
(
dm
*
DockerManager
)
PullImage
(
image
kubecontainer
.
ImageSpec
,
secrets
[]
api
.
Secret
)
error
{
return
dm
.
P
uller
.
Pull
(
image
.
Image
,
secrets
)
return
dm
.
p
uller
.
Pull
(
image
.
Image
,
secrets
)
}
}
// IsImagePresent checks whether the container image is already in the local storage.
// IsImagePresent checks whether the container image is already in the local storage.
func
(
dm
*
DockerManager
)
IsImagePresent
(
image
kubecontainer
.
ImageSpec
)
(
bool
,
error
)
{
func
(
dm
*
DockerManager
)
IsImagePresent
(
image
kubecontainer
.
ImageSpec
)
(
bool
,
error
)
{
return
dm
.
P
uller
.
IsImagePresent
(
image
.
Image
)
return
dm
.
p
uller
.
IsImagePresent
(
image
.
Image
)
}
}
// Removes the specified image.
// Removes the specified image.
...
@@ -825,7 +822,7 @@ func (dm *DockerManager) podInfraContainerChanged(pod *api.Pod, podInfraContaine
...
@@ -825,7 +822,7 @@ func (dm *DockerManager) podInfraContainerChanged(pod *api.Pod, podInfraContaine
}
}
expectedPodInfraContainer
:=
&
api
.
Container
{
expectedPodInfraContainer
:=
&
api
.
Container
{
Name
:
PodInfraContainerName
,
Name
:
PodInfraContainerName
,
Image
:
dm
.
P
odInfraContainerImage
,
Image
:
dm
.
p
odInfraContainerImage
,
Ports
:
ports
,
Ports
:
ports
,
}
}
return
podInfraContainer
.
Hash
!=
kubecontainer
.
HashContainer
(
expectedPodInfraContainer
),
nil
return
podInfraContainer
.
Hash
!=
kubecontainer
.
HashContainer
(
expectedPodInfraContainer
),
nil
...
@@ -1203,7 +1200,7 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
...
@@ -1203,7 +1200,7 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
container
:=
&
api
.
Container
{
container
:=
&
api
.
Container
{
Name
:
PodInfraContainerName
,
Name
:
PodInfraContainerName
,
Image
:
dm
.
P
odInfraContainerImage
,
Image
:
dm
.
p
odInfraContainerImage
,
Ports
:
ports
,
Ports
:
ports
,
}
}
ref
,
err
:=
kubecontainer
.
GenerateContainerRef
(
pod
,
container
)
ref
,
err
:=
kubecontainer
.
GenerateContainerRef
(
pod
,
container
)
...
...
pkg/kubelet/dockertools/manager_test.go
View file @
d6004a1c
...
@@ -38,7 +38,7 @@ import (
...
@@ -38,7 +38,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
uexec
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
uexec
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
)
)
type
fakeHTTP
struct
{
type
fakeHTTP
struct
{
...
@@ -876,7 +876,7 @@ func runSyncPod(t *testing.T, dm *DockerManager, fakeDocker *FakeDockerClient, p
...
@@ -876,7 +876,7 @@ func runSyncPod(t *testing.T, dm *DockerManager, fakeDocker *FakeDockerClient, p
func
TestSyncPodCreateNetAndContainer
(
t
*
testing
.
T
)
{
func
TestSyncPodCreateNetAndContainer
(
t
*
testing
.
T
)
{
dm
,
fakeDocker
:=
newTestDockerManager
()
dm
,
fakeDocker
:=
newTestDockerManager
()
dm
.
P
odInfraContainerImage
=
"custom_image_name"
dm
.
p
odInfraContainerImage
=
"custom_image_name"
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
pod
:=
&
api
.
Pod
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
...
@@ -921,10 +921,10 @@ func TestSyncPodCreateNetAndContainer(t *testing.T) {
...
@@ -921,10 +921,10 @@ func TestSyncPodCreateNetAndContainer(t *testing.T) {
func
TestSyncPodCreatesNetAndContainerPullsImage
(
t
*
testing
.
T
)
{
func
TestSyncPodCreatesNetAndContainerPullsImage
(
t
*
testing
.
T
)
{
dm
,
fakeDocker
:=
newTestDockerManager
()
dm
,
fakeDocker
:=
newTestDockerManager
()
dm
.
P
odInfraContainerImage
=
"custom_image_name"
dm
.
p
odInfraContainerImage
=
"custom_image_name"
puller
:=
dm
.
P
uller
.
(
*
FakeDockerPuller
)
puller
:=
dm
.
p
uller
.
(
*
FakeDockerPuller
)
puller
.
HasImages
=
[]
string
{}
puller
.
HasImages
=
[]
string
{}
dm
.
P
odInfraContainerImage
=
"custom_image_name"
dm
.
p
odInfraContainerImage
=
"custom_image_name"
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
pod
:=
&
api
.
Pod
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
...
@@ -1282,9 +1282,9 @@ func TestSyncPodsDoesNothing(t *testing.T) {
...
@@ -1282,9 +1282,9 @@ func TestSyncPodsDoesNothing(t *testing.T) {
func
TestSyncPodWithPullPolicy
(
t
*
testing
.
T
)
{
func
TestSyncPodWithPullPolicy
(
t
*
testing
.
T
)
{
dm
,
fakeDocker
:=
newTestDockerManager
()
dm
,
fakeDocker
:=
newTestDockerManager
()
puller
:=
dm
.
P
uller
.
(
*
FakeDockerPuller
)
puller
:=
dm
.
p
uller
.
(
*
FakeDockerPuller
)
puller
.
HasImages
=
[]
string
{
"existing_one"
,
"want:latest"
}
puller
.
HasImages
=
[]
string
{
"existing_one"
,
"want:latest"
}
dm
.
P
odInfraContainerImage
=
"custom_image_name"
dm
.
p
odInfraContainerImage
=
"custom_image_name"
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
pod
:=
&
api
.
Pod
{
pod
:=
&
api
.
Pod
{
...
@@ -1649,7 +1649,7 @@ func TestGetPodPullImageFailureReason(t *testing.T) {
...
@@ -1649,7 +1649,7 @@ func TestGetPodPullImageFailureReason(t *testing.T) {
dm
,
fakeDocker
:=
newTestDockerManager
()
dm
,
fakeDocker
:=
newTestDockerManager
()
// Initialize the FakeDockerPuller so that it'd try to pull non-existent
// Initialize the FakeDockerPuller so that it'd try to pull non-existent
// images.
// images.
puller
:=
dm
.
P
uller
.
(
*
FakeDockerPuller
)
puller
:=
dm
.
p
uller
.
(
*
FakeDockerPuller
)
puller
.
HasImages
=
[]
string
{}
puller
.
HasImages
=
[]
string
{}
// Inject the pull image failure error.
// Inject the pull image failure error.
failureReason
:=
"pull image faiulre"
failureReason
:=
"pull image faiulre"
...
...
pkg/kubelet/kubelet.go
View file @
d6004a1c
...
@@ -2124,7 +2124,6 @@ func (kl *Kubelet) ServeLogs(w http.ResponseWriter, req *http.Request) {
...
@@ -2124,7 +2124,6 @@ func (kl *Kubelet) ServeLogs(w http.ResponseWriter, req *http.Request) {
// findContainer finds and returns the container with the given pod ID, full name, and container name.
// findContainer finds and returns the container with the given pod ID, full name, and container name.
// It returns nil if not found.
// It returns nil if not found.
// TODO(yifan): Move this to runtime once the runtime interface has been all implemented.
func
(
kl
*
Kubelet
)
findContainer
(
podFullName
string
,
podUID
types
.
UID
,
containerName
string
)
(
*
kubecontainer
.
Container
,
error
)
{
func
(
kl
*
Kubelet
)
findContainer
(
podFullName
string
,
podUID
types
.
UID
,
containerName
string
)
(
*
kubecontainer
.
Container
,
error
)
{
pods
,
err
:=
kl
.
containerRuntime
.
GetPods
(
false
)
pods
,
err
:=
kl
.
containerRuntime
.
GetPods
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/kubelet/kubelet_test.go
View file @
d6004a1c
...
@@ -50,7 +50,7 @@ import (
...
@@ -50,7 +50,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
_
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/host_path"
_
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/host_path"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
cadvisorApi
"github.com/google/cadvisor/info/v1"
cadvisorApi
"github.com/google/cadvisor/info/v1"
cadvisorApiv2
"github.com/google/cadvisor/info/v2"
cadvisorApiv2
"github.com/google/cadvisor/info/v2"
)
)
...
@@ -2176,17 +2176,12 @@ func TestPortForward(t *testing.T) {
...
@@ -2176,17 +2176,12 @@ func TestPortForward(t *testing.T) {
var
port
uint16
=
5000
var
port
uint16
=
5000
stream
:=
&
fakeReadWriteCloser
{}
stream
:=
&
fakeReadWriteCloser
{}
podInfraContainerImage
:=
"POD"
infraContainerID
:=
"infra"
infraContainerID
:=
"infra"
// TODO: Move this test to dockertools so that we don't have to do the hacky
// type assertion here.
dm
:=
kubelet
.
containerRuntime
.
(
*
dockertools
.
DockerManager
)
dm
.
PodInfraContainerImage
=
podInfraContainerImage
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{
{
{
ID
:
infraContainerID
,
ID
:
infraContainerID
,
Names
:
[]
string
{
"/k8s_
"
+
podInfraContainerImage
+
"_"
+
podName
+
"_"
+
podNamespace
+
"_12345678_42"
},
Names
:
[]
string
{
"/k8s_
POD"
+
"_"
+
podName
+
"_"
+
podNamespace
+
"_12345678_42"
},
},
},
{
{
ID
:
containerID
,
ID
:
containerID
,
...
...
pkg/kubelet/pod_workers_test.go
View file @
d6004a1c
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
)
)
func
newPod
(
uid
,
name
string
)
*
api
.
Pod
{
func
newPod
(
uid
,
name
string
)
*
api
.
Pod
{
...
...
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