Move ComputePodChanges to DockerManager.

This logic is specific to the Docker runtime. This move is the first
step towards making syncPod() runtime-agnostic.
This commit is contained in:
Victor Marmol
2015-04-28 17:51:21 -07:00
parent 134e585195
commit fe4600ba17
10 changed files with 245 additions and 195 deletions

View File

@@ -18,13 +18,13 @@ package prober
import (
"fmt"
"io"
"strconv"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
kubecontainer "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/probe"
execprobe "github.com/GoogleCloudPlatform/kubernetes/pkg/probe/exec"
httprobe "github.com/GoogleCloudPlatform/kubernetes/pkg/probe/http"
@@ -42,12 +42,19 @@ 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
runner dockertools.ContainerCommandRunner
exec execprobe.ExecProber
http httprobe.HTTPProber
tcp tcprobe.TCPProber
// TODO(vmarmol): Remove when we remove the circular dependency to DockerManager.
Runner ContainerCommandRunner
readinessManager *kubecontainer.ReadinessManager
refManager *kubecontainer.RefManager
@@ -57,7 +64,7 @@ type prober struct {
// NewProber creates a Prober, it takes a command runner and
// several container info managers.
func New(
runner dockertools.ContainerCommandRunner,
runner ContainerCommandRunner,
readinessManager *kubecontainer.ReadinessManager,
refManager *kubecontainer.RefManager,
recorder record.EventRecorder) Prober {
@@ -66,7 +73,7 @@ func New(
exec: execprobe.New(),
http: httprobe.New(),
tcp: tcprobe.New(),
runner: runner,
Runner: runner,
readinessManager: readinessManager,
refManager: refManager,
@@ -249,7 +256,7 @@ type execInContainer struct {
func (p *prober) newExecInContainer(pod *api.Pod, container api.Container, containerID string) exec.Cmd {
return execInContainer{func() ([]byte, error) {
return p.runner.RunInContainer(containerID, container.LivenessProbe.Exec.Command)
return p.Runner.RunInContainer(containerID, container.LivenessProbe.Exec.Command)
}}
}