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
14654754
Commit
14654754
authored
May 11, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8079 from yifan-gu/rm_command_runner
kubelet/container: Move prober.ContainerCommandRunner to container.
parents
ac87ed65
7831b7da
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
42 deletions
+28
-42
runtime.go
pkg/kubelet/container/runtime.go
+17
-11
kubelet.go
pkg/kubelet/kubelet.go
+1
-12
kubelet_test.go
pkg/kubelet/kubelet_test.go
+1
-0
handlers.go
pkg/kubelet/lifecycle/handlers.go
+2
-4
prober.go
pkg/kubelet/prober/prober.go
+7
-15
No files found.
pkg/kubelet/container/runtime.go
View file @
14654754
...
...
@@ -58,17 +58,6 @@ type Runtime interface {
// GetPodStatus retrieves the status of the pod, including the information of
// all containers in the pod.
GetPodStatus
(
*
api
.
Pod
)
(
*
api
.
PodStatus
,
error
)
// TODO(vmarmol): Merge RunInContainer and ExecInContainer.
// Runs the command in the container of the specified pod using nsinit.
// TODO(yifan): Use strong type for containerID.
RunInContainer
(
containerID
string
,
cmd
[]
string
)
([]
byte
,
error
)
// Runs the command in the container of the specified pod using nsenter.
// Attaches the processes stdin, stdout, and stderr. Optionally uses a
// tty.
// TODO(yifan): Use strong type for containerID.
ExecInContainer
(
containerID
string
,
cmd
[]
string
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
,
tty
bool
)
error
// Forward the specified port from the specified pod to the stream.
PortForward
(
pod
*
Pod
,
port
uint16
,
stream
io
.
ReadWriteCloser
)
error
// PullImage pulls an image from the network to local storage using the supplied
// secrets if necessary.
PullImage
(
image
ImageSpec
,
secrets
[]
api
.
Secret
)
error
...
...
@@ -84,6 +73,23 @@ type Runtime interface {
// stream the log. Set 'follow' to false and specify the number of lines (e.g.
// "100" or "all") to tail the log.
GetContainerLogs
(
pod
*
api
.
Pod
,
containerID
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
(
err
error
)
// ContainerCommandRunner encapsulates the command runner interfaces for testability.
ContainerCommandRunner
}
// CommandRunner encapsulates the command runner interfaces for testability.
type
ContainerCommandRunner
interface
{
// TODO(vmarmol): Merge RunInContainer and ExecInContainer.
// Runs the command in the container of the specified pod using nsinit.
// TODO(yifan): Use strong type for containerID.
RunInContainer
(
containerID
string
,
cmd
[]
string
)
([]
byte
,
error
)
// Runs the command in the container of the specified pod using nsenter.
// Attaches the processes stdin, stdout, and stderr. Optionally uses a
// tty.
// TODO(yifan): Use strong type for containerID.
ExecInContainer
(
containerID
string
,
cmd
[]
string
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
,
tty
bool
)
error
// Forward the specified port from the specified pod to the stream.
PortForward
(
pod
*
Pod
,
port
uint16
,
stream
io
.
ReadWriteCloser
)
error
}
// Customizable hooks injected into container runtimes.
...
...
pkg/kubelet/kubelet.go
View file @
14654754
...
...
@@ -44,7 +44,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/envvars"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/metrics"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/prober"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/rkt"
kubeletTypes
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
...
...
@@ -345,7 +344,7 @@ type Kubelet struct {
// Optional, defaults to /logs/ from /var/log
logServer
http
.
Handler
// Optional, defaults to simple Docker implementation
runner
prob
er
.
ContainerCommandRunner
runner
kubecontain
er
.
ContainerCommandRunner
// Optional, client for http requests, defaults to empty client
httpClient
kubeletTypes
.
HttpGetter
...
...
@@ -1781,9 +1780,6 @@ func (kl *Kubelet) findContainer(podFullName string, podUID types.UID, container
func
(
kl
*
Kubelet
)
RunInContainer
(
podFullName
string
,
podUID
types
.
UID
,
containerName
string
,
cmd
[]
string
)
([]
byte
,
error
)
{
podUID
=
kl
.
podManager
.
TranslatePodUID
(
podUID
)
if
kl
.
runner
==
nil
{
return
nil
,
fmt
.
Errorf
(
"no runner specified."
)
}
container
,
err
:=
kl
.
findContainer
(
podFullName
,
podUID
,
containerName
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -1799,9 +1795,6 @@ func (kl *Kubelet) RunInContainer(podFullName string, podUID types.UID, containe
func
(
kl
*
Kubelet
)
ExecInContainer
(
podFullName
string
,
podUID
types
.
UID
,
containerName
string
,
cmd
[]
string
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
,
tty
bool
)
error
{
podUID
=
kl
.
podManager
.
TranslatePodUID
(
podUID
)
if
kl
.
runner
==
nil
{
return
fmt
.
Errorf
(
"no runner specified."
)
}
container
,
err
:=
kl
.
findContainer
(
podFullName
,
podUID
,
containerName
)
if
err
!=
nil
{
return
err
...
...
@@ -1817,10 +1810,6 @@ func (kl *Kubelet) ExecInContainer(podFullName string, podUID types.UID, contain
func
(
kl
*
Kubelet
)
PortForward
(
podFullName
string
,
podUID
types
.
UID
,
port
uint16
,
stream
io
.
ReadWriteCloser
)
error
{
podUID
=
kl
.
podManager
.
TranslatePodUID
(
podUID
)
if
kl
.
runner
==
nil
{
return
fmt
.
Errorf
(
"no runner specified."
)
}
pods
,
err
:=
kl
.
containerRuntime
.
GetPods
(
false
)
if
err
!=
nil
{
return
err
...
...
pkg/kubelet/kubelet_test.go
View file @
14654754
...
...
@@ -1570,6 +1570,7 @@ func (f *fakeContainerCommandRunner) PortForward(pod *kubecontainer.Pod, port ui
f
.
Stream
=
stream
return
nil
}
func
TestRunInContainerNoSuchPod
(
t
*
testing
.
T
)
{
fakeCommandRunner
:=
fakeContainerCommandRunner
{}
testKubelet
:=
newTestKubelet
(
t
)
...
...
pkg/kubelet/lifecycle/handlers.go
View file @
14654754
...
...
@@ -23,7 +23,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/prober"
kubeletTypes
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
...
...
@@ -31,7 +30,7 @@ import (
type
HandlerRunner
struct
{
httpGetter
kubeletTypes
.
HttpGetter
commandRunner
prob
er
.
ContainerCommandRunner
commandRunner
kubecontain
er
.
ContainerCommandRunner
containerManager
podStatusProvider
}
...
...
@@ -39,8 +38,7 @@ type podStatusProvider interface {
GetPodStatus
(
pod
*
api
.
Pod
)
(
*
api
.
PodStatus
,
error
)
}
// TODO(yifan): Merge commandRunner and containerManager once containerManager implements the ContainerCommandRunner interface.
func
NewHandlerRunner
(
httpGetter
kubeletTypes
.
HttpGetter
,
commandRunner
prober
.
ContainerCommandRunner
,
containerManager
podStatusProvider
)
kubecontainer
.
HandlerRunner
{
func
NewHandlerRunner
(
httpGetter
kubeletTypes
.
HttpGetter
,
commandRunner
kubecontainer
.
ContainerCommandRunner
,
containerManager
podStatusProvider
)
kubecontainer
.
HandlerRunner
{
return
&
HandlerRunner
{
httpGetter
:
httpGetter
,
commandRunner
:
commandRunner
,
...
...
pkg/kubelet/prober/prober.go
View file @
14654754
...
...
@@ -18,7 +18,6 @@ package prober
import
(
"fmt"
"io"
"strconv"
"time"
...
...
@@ -42,19 +41,12 @@ type Prober interface {
Probe
(
pod
*
api
.
Pod
,
status
api
.
PodStatus
,
container
api
.
Container
,
containerID
string
,
createdAt
int64
)
(
probe
.
Result
,
error
)
}
type
ContainerCommandRunner
interface
{
RunInContainer
(
containerID
string
,
cmd
[]
string
)
([]
byte
,
error
)
ExecInContainer
(
containerID
string
,
cmd
[]
string
,
in
io
.
Reader
,
out
,
err
io
.
WriteCloser
,
tty
bool
)
error
PortForward
(
pod
*
kubecontainer
.
Pod
,
port
uint16
,
stream
io
.
ReadWriteCloser
)
error
}
// Prober helps to check the liveness/readiness of a container.
type
prober
struct
{
exec
execprobe
.
ExecProber
http
httprobe
.
HTTPProber
tcp
tcprobe
.
TCPProber
// TODO(vmarmol): Remove when we remove the circular dependency to DockerManager.
Runner
ContainerCommandRunner
exec
execprobe
.
ExecProber
http
httprobe
.
HTTPProber
tcp
tcprobe
.
TCPProber
runner
kubecontainer
.
ContainerCommandRunner
readinessManager
*
kubecontainer
.
ReadinessManager
refManager
*
kubecontainer
.
RefManager
...
...
@@ -64,7 +56,7 @@ type prober struct {
// NewProber creates a Prober, it takes a command runner and
// several container info managers.
func
New
(
runner
ContainerCommandRunner
,
runner
kubecontainer
.
ContainerCommandRunner
,
readinessManager
*
kubecontainer
.
ReadinessManager
,
refManager
*
kubecontainer
.
RefManager
,
recorder
record
.
EventRecorder
)
Prober
{
...
...
@@ -73,7 +65,7 @@ func New(
exec
:
execprobe
.
New
(),
http
:
httprobe
.
New
(),
tcp
:
tcprobe
.
New
(),
R
unner
:
runner
,
r
unner
:
runner
,
readinessManager
:
readinessManager
,
refManager
:
refManager
,
...
...
@@ -256,7 +248,7 @@ type execInContainer struct {
func
(
p
*
prober
)
newExecInContainer
(
pod
*
api
.
Pod
,
container
api
.
Container
,
containerID
string
,
cmd
[]
string
)
exec
.
Cmd
{
return
execInContainer
{
func
()
([]
byte
,
error
)
{
return
p
.
R
unner
.
RunInContainer
(
containerID
,
cmd
)
return
p
.
r
unner
.
RunInContainer
(
containerID
,
cmd
)
}}
}
...
...
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