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
f197a9db
Commit
f197a9db
authored
Jun 04, 2015
by
Yifan Gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubelet: Minor refactors.
Remove some TODOs. Unexport DockerManager.Puller and DockerManager.PodInfraContainerImage. Add "docker" for all "go-dockerclient" imports.
parent
b4286918
Show 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 @
f197a9db
...
...
@@ -29,7 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"github.com/google/gofuzz"
"speter.net/go/exp/math/dec/inf"
...
...
pkg/kubelet/container/runtime_cache.go
View file @
f197a9db
...
...
@@ -32,8 +32,6 @@ type RuntimeCache interface {
ForceUpdateIfOlder
(
time
.
Time
)
error
}
// TODO(yifan): This interface can be removed once docker manager has implemented
// all the runtime interfaces, (thus we can pass the runtime directly).
type
podsGetter
interface
{
GetPods
(
bool
)
([]
*
Pod
,
error
)
}
...
...
pkg/kubelet/container_gc.go
View file @
f197a9db
...
...
@@ -23,7 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"github.com/golang/glog"
)
...
...
pkg/kubelet/container_gc_test.go
View file @
f197a9db
...
...
@@ -22,7 +22,7 @@ import (
"time"
"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/require"
)
...
...
pkg/kubelet/dockertools/exec.go
View file @
f197a9db
...
...
@@ -24,7 +24,7 @@ import (
"time"
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.
...
...
pkg/kubelet/dockertools/fake_docker_client.go
View file @
f197a9db
...
...
@@ -24,7 +24,7 @@ import (
"sort"
"sync"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
...
...
pkg/kubelet/dockertools/fake_manager.go
View file @
f197a9db
...
...
@@ -41,7 +41,7 @@ func NewFakeDockerManager(
dm
:=
NewDockerManager
(
client
,
recorder
,
readinessManager
,
containerRefManager
,
podInfraContainerImage
,
qps
,
burst
,
containerLogsDir
,
osInterface
,
networkPlugin
,
generator
,
httpClient
,
runtimeHooks
,
&
NativeExecHandler
{})
dm
.
P
uller
=
&
FakeDockerPuller
{}
dm
.
p
uller
=
&
FakeDockerPuller
{}
dm
.
prober
=
prober
.
New
(
nil
,
readinessManager
,
containerRefManager
,
recorder
)
return
dm
}
pkg/kubelet/dockertools/instrumented_docker.go
View file @
f197a9db
...
...
@@ -20,7 +20,7 @@ import (
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/metrics"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
)
type
instrumentedDockerInterface
struct
{
...
...
pkg/kubelet/dockertools/manager.go
View file @
f197a9db
...
...
@@ -68,9 +68,8 @@ type DockerManager struct {
containerRefManager
*
kubecontainer
.
RefManager
os
kubecontainer
.
OSInterface
// TODO(yifan): PodInfraContainerImage can be unexported once
// we move createPodInfraContainer into dockertools.
PodInfraContainerImage
string
// The image name of the pod infra container.
podInfraContainerImage
string
// reasonCache stores the failure reason of the last container creation
// 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
...
...
@@ -80,11 +79,9 @@ type DockerManager struct {
// means that some entries may be recycled before a pod has been
// deleted.
reasonCache
stringCache
// TODO(yifan): We export this for testability, so when we have a fake
// container manager, then we can unexport this. Also at that time, we
// use the concrete type so that we can record the pull failure and eliminate
// the image checking in GetPodStatus().
Puller
DockerPuller
// TODO(yifan): Record the pull failure so we can eliminate the image checking
// in GetPodStatus()?
puller
DockerPuller
// Root of the Docker runtime.
dockerRoot
string
...
...
@@ -164,9 +161,9 @@ func NewDockerManager(
readinessManager
:
readinessManager
,
containerRefManager
:
containerRefManager
,
os
:
osInterface
,
P
odInfraContainerImage
:
podInfraContainerImage
,
p
odInfraContainerImage
:
podInfraContainerImage
,
reasonCache
:
reasonCache
,
P
uller
:
newDockerPuller
(
client
,
qps
,
burst
),
p
uller
:
newDockerPuller
(
client
,
qps
,
burst
),
dockerRoot
:
dockerRoot
,
containerLogsDir
:
containerLogsDir
,
networkPlugin
:
networkPlugin
,
...
...
@@ -784,12 +781,12 @@ func (dm *DockerManager) ListImages() ([]kubecontainer.Image, error) {
// TODO(vmarmol): Consider unexporting.
// PullImage pulls an image from network to local storage.
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.
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.
...
...
@@ -825,7 +822,7 @@ func (dm *DockerManager) podInfraContainerChanged(pod *api.Pod, podInfraContaine
}
expectedPodInfraContainer
:=
&
api
.
Container
{
Name
:
PodInfraContainerName
,
Image
:
dm
.
P
odInfraContainerImage
,
Image
:
dm
.
p
odInfraContainerImage
,
Ports
:
ports
,
}
return
podInfraContainer
.
Hash
!=
kubecontainer
.
HashContainer
(
expectedPodInfraContainer
),
nil
...
...
@@ -1203,7 +1200,7 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
container
:=
&
api
.
Container
{
Name
:
PodInfraContainerName
,
Image
:
dm
.
P
odInfraContainerImage
,
Image
:
dm
.
p
odInfraContainerImage
,
Ports
:
ports
,
}
ref
,
err
:=
kubecontainer
.
GenerateContainerRef
(
pod
,
container
)
...
...
pkg/kubelet/dockertools/manager_test.go
View file @
f197a9db
...
...
@@ -38,7 +38,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
uexec
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
)
type
fakeHTTP
struct
{
...
...
@@ -876,7 +876,7 @@ func runSyncPod(t *testing.T, dm *DockerManager, fakeDocker *FakeDockerClient, p
func
TestSyncPodCreateNetAndContainer
(
t
*
testing
.
T
)
{
dm
,
fakeDocker
:=
newTestDockerManager
()
dm
.
P
odInfraContainerImage
=
"custom_image_name"
dm
.
p
odInfraContainerImage
=
"custom_image_name"
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
...
...
@@ -921,10 +921,10 @@ func TestSyncPodCreateNetAndContainer(t *testing.T) {
func
TestSyncPodCreatesNetAndContainerPullsImage
(
t
*
testing
.
T
)
{
dm
,
fakeDocker
:=
newTestDockerManager
()
dm
.
P
odInfraContainerImage
=
"custom_image_name"
puller
:=
dm
.
P
uller
.
(
*
FakeDockerPuller
)
dm
.
p
odInfraContainerImage
=
"custom_image_name"
puller
:=
dm
.
p
uller
.
(
*
FakeDockerPuller
)
puller
.
HasImages
=
[]
string
{}
dm
.
P
odInfraContainerImage
=
"custom_image_name"
dm
.
p
odInfraContainerImage
=
"custom_image_name"
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
...
...
@@ -1282,9 +1282,9 @@ func TestSyncPodsDoesNothing(t *testing.T) {
func
TestSyncPodWithPullPolicy
(
t
*
testing
.
T
)
{
dm
,
fakeDocker
:=
newTestDockerManager
()
puller
:=
dm
.
P
uller
.
(
*
FakeDockerPuller
)
puller
:=
dm
.
p
uller
.
(
*
FakeDockerPuller
)
puller
.
HasImages
=
[]
string
{
"existing_one"
,
"want:latest"
}
dm
.
P
odInfraContainerImage
=
"custom_image_name"
dm
.
p
odInfraContainerImage
=
"custom_image_name"
fakeDocker
.
ContainerList
=
[]
docker
.
APIContainers
{}
pod
:=
&
api
.
Pod
{
...
...
@@ -1649,7 +1649,7 @@ func TestGetPodPullImageFailureReason(t *testing.T) {
dm
,
fakeDocker
:=
newTestDockerManager
()
// Initialize the FakeDockerPuller so that it'd try to pull non-existent
// images.
puller
:=
dm
.
P
uller
.
(
*
FakeDockerPuller
)
puller
:=
dm
.
p
uller
.
(
*
FakeDockerPuller
)
puller
.
HasImages
=
[]
string
{}
// Inject the pull image failure error.
failureReason
:=
"pull image faiulre"
...
...
pkg/kubelet/kubelet.go
View file @
f197a9db
...
...
@@ -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.
// 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
)
{
pods
,
err
:=
kl
.
containerRuntime
.
GetPods
(
false
)
if
err
!=
nil
{
...
...
pkg/kubelet/kubelet_test.go
View file @
f197a9db
...
...
@@ -50,7 +50,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
_
"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"
cadvisorApiv2
"github.com/google/cadvisor/info/v2"
)
...
...
@@ -2176,17 +2176,12 @@ func TestPortForward(t *testing.T) {
var
port
uint16
=
5000
stream
:=
&
fakeReadWriteCloser
{}
podInfraContainerImage
:=
"POD"
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
{
{
ID
:
infraContainerID
,
Names
:
[]
string
{
"/k8s_
"
+
podInfraContainerImage
+
"_"
+
podName
+
"_"
+
podNamespace
+
"_12345678_42"
},
Names
:
[]
string
{
"/k8s_
POD"
+
"_"
+
podName
+
"_"
+
podNamespace
+
"_12345678_42"
},
},
{
ID
:
containerID
,
...
...
pkg/kubelet/pod_workers_test.go
View file @
f197a9db
...
...
@@ -29,7 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/fsouza/go-dockerclient"
docker
"github.com/fsouza/go-dockerclient"
)
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