mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
vendor update for CSI 0.3.0
This commit is contained in:
46
vendor/k8s.io/kubernetes/pkg/kubelet/container/BUILD
generated
vendored
46
vendor/k8s.io/kubernetes/pkg/kubelet/container/BUILD
generated
vendored
@ -14,49 +14,13 @@ go_library(
|
||||
"runtime_cache.go",
|
||||
"runtime_cache_fake.go",
|
||||
"sync_result.go",
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:android": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:darwin": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:dragonfly": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:freebsd": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"pty_linux.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:nacl": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:netbsd": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:openbsd": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:plan9": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:solaris": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:windows": [
|
||||
"pty_unsupported.go",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/container",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/kubelet/apis/cri/runtime/v1alpha2:go_default_library",
|
||||
"//pkg/kubelet/util/format:go_default_library",
|
||||
"//pkg/kubelet/util/ioutils:go_default_library",
|
||||
"//pkg/util/hash:go_default_library",
|
||||
"//pkg/volume:go_default_library",
|
||||
"//third_party/forked/golang/expansion:go_default_library",
|
||||
@ -71,12 +35,7 @@ go_library(
|
||||
"//vendor/k8s.io/client-go/tools/reference:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/remotecommand:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/flowcontrol:go_default_library",
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"//vendor/github.com/kr/pty:go_default_library",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
@ -89,7 +48,6 @@ go_test(
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/core/install:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
|
64
vendor/k8s.io/kubernetes/pkg/kubelet/container/helpers.go
generated
vendored
64
vendor/k8s.io/kubernetes/pkg/kubelet/container/helpers.go
generated
vendored
@ -17,12 +17,9 @@ limitations under the License.
|
||||
package container
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"hash/adler32"
|
||||
"hash/fnv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
@ -33,7 +30,6 @@ import (
|
||||
"k8s.io/client-go/tools/record"
|
||||
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
|
||||
"k8s.io/kubernetes/pkg/kubelet/util/format"
|
||||
"k8s.io/kubernetes/pkg/kubelet/util/ioutils"
|
||||
hashutil "k8s.io/kubernetes/pkg/util/hash"
|
||||
"k8s.io/kubernetes/third_party/forked/golang/expansion"
|
||||
)
|
||||
@ -46,7 +42,7 @@ type HandlerRunner interface {
|
||||
// RuntimeHelper wraps kubelet to make container runtime
|
||||
// able to get necessary informations like the RunContainerOptions, DNS settings, Host IP.
|
||||
type RuntimeHelper interface {
|
||||
GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string) (contOpts *RunContainerOptions, err error)
|
||||
GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string) (contOpts *RunContainerOptions, cleanupAction func(), err error)
|
||||
GetPodDNS(pod *v1.Pod) (dnsConfig *runtimeapi.DNSConfig, err error)
|
||||
// GetPodCgroupParent returns the CgroupName identifier, and its literal cgroupfs form on the host
|
||||
// of a pod.
|
||||
@ -100,17 +96,6 @@ func HashContainer(container *v1.Container) uint64 {
|
||||
return uint64(hash.Sum32())
|
||||
}
|
||||
|
||||
// HashContainerLegacy returns the hash of the container. It is used to compare
|
||||
// the running container with its desired spec.
|
||||
// This is used by rktnetes and dockershim (for handling <=1.5 containers).
|
||||
// TODO: Remove this function when kubernetes version is >=1.8 AND rktnetes
|
||||
// update its hash function.
|
||||
func HashContainerLegacy(container *v1.Container) uint64 {
|
||||
hash := adler32.New()
|
||||
hashutil.DeepHashObject(hash, *container)
|
||||
return uint64(hash.Sum32())
|
||||
}
|
||||
|
||||
// EnvVarsToMap constructs a map of environment name to value from a slice
|
||||
// of env vars.
|
||||
func EnvVarsToMap(envs []EnvVar) map[string]string {
|
||||
@ -145,6 +130,11 @@ func ExpandContainerCommandOnlyStatic(containerCommand []string, envs []v1.EnvVa
|
||||
return command
|
||||
}
|
||||
|
||||
func ExpandContainerVolumeMounts(mount v1.VolumeMount, envs []EnvVar) (expandedSubpath string) {
|
||||
mapping := expansion.MappingFuncFor(EnvVarsToMap(envs))
|
||||
return expansion.Expand(mount.SubPath, mapping)
|
||||
}
|
||||
|
||||
func ExpandContainerCommandAndArgs(container *v1.Container, envs []EnvVar) (command []string, args []string) {
|
||||
mapping := expansion.MappingFuncFor(EnvVarsToMap(envs))
|
||||
|
||||
@ -205,6 +195,13 @@ func (irecorder *innerEventRecorder) PastEventf(object runtime.Object, timestamp
|
||||
}
|
||||
}
|
||||
|
||||
func (irecorder *innerEventRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{}) {
|
||||
if ref, ok := irecorder.shouldRecordEvent(object); ok {
|
||||
irecorder.recorder.AnnotatedEventf(ref, annotations, eventtype, reason, messageFmt, args...)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Pod must not be nil.
|
||||
func IsHostNetworkPod(pod *v1.Pod) bool {
|
||||
return pod.Spec.HostNetwork
|
||||
@ -265,26 +262,6 @@ func FormatPod(pod *Pod) string {
|
||||
return fmt.Sprintf("%s_%s(%s)", pod.Name, pod.Namespace, pod.ID)
|
||||
}
|
||||
|
||||
type containerCommandRunnerWrapper struct {
|
||||
DirectStreamingRuntime
|
||||
}
|
||||
|
||||
var _ ContainerCommandRunner = &containerCommandRunnerWrapper{}
|
||||
|
||||
func DirectStreamingRunner(runtime DirectStreamingRuntime) ContainerCommandRunner {
|
||||
return &containerCommandRunnerWrapper{runtime}
|
||||
}
|
||||
|
||||
func (r *containerCommandRunnerWrapper) RunInContainer(id ContainerID, cmd []string, timeout time.Duration) ([]byte, error) {
|
||||
var buffer bytes.Buffer
|
||||
output := ioutils.WriteCloserWrapper(&buffer)
|
||||
err := r.ExecInContainer(id, cmd, nil, output, output, false, nil, timeout)
|
||||
// Even if err is non-nil, there still may be output (e.g. the exec wrote to stdout or stderr but
|
||||
// the command returned a nonzero exit code). Therefore, always return the output along with the
|
||||
// error.
|
||||
return buffer.Bytes(), err
|
||||
}
|
||||
|
||||
// GetContainerSpec gets the container spec by containerName.
|
||||
func GetContainerSpec(pod *v1.Pod, containerName string) *v1.Container {
|
||||
for i, c := range pod.Spec.Containers {
|
||||
@ -312,21 +289,6 @@ func HasPrivilegedContainer(pod *v1.Pod) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// MakeCapabilities creates string slices from Capability slices
|
||||
func MakeCapabilities(capAdd []v1.Capability, capDrop []v1.Capability) ([]string, []string) {
|
||||
var (
|
||||
addCaps []string
|
||||
dropCaps []string
|
||||
)
|
||||
for _, cap := range capAdd {
|
||||
addCaps = append(addCaps, string(cap))
|
||||
}
|
||||
for _, cap := range capDrop {
|
||||
dropCaps = append(dropCaps, string(cap))
|
||||
}
|
||||
return addCaps, dropCaps
|
||||
}
|
||||
|
||||
// MakePortMappings creates internal port mapping from api port mapping.
|
||||
func MakePortMappings(container *v1.Container) (ports []PortMapping) {
|
||||
names := make(map[string]struct{})
|
||||
|
108
vendor/k8s.io/kubernetes/pkg/kubelet/container/helpers_test.go
generated
vendored
108
vendor/k8s.io/kubernetes/pkg/kubelet/container/helpers_test.go
generated
vendored
@ -138,6 +138,114 @@ func TestExpandCommandAndArgs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExpandVolumeMountsWithSubpath(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
container *v1.Container
|
||||
envs []EnvVar
|
||||
expectedSubPath string
|
||||
expectedMountPath string
|
||||
}{
|
||||
{
|
||||
name: "subpath with no expansion",
|
||||
container: &v1.Container{
|
||||
VolumeMounts: []v1.VolumeMount{{SubPath: "foo"}},
|
||||
},
|
||||
expectedSubPath: "foo",
|
||||
expectedMountPath: "",
|
||||
},
|
||||
{
|
||||
name: "volumes with expanded subpath",
|
||||
container: &v1.Container{
|
||||
VolumeMounts: []v1.VolumeMount{{SubPath: "foo/$(POD_NAME)"}},
|
||||
},
|
||||
envs: []EnvVar{
|
||||
{
|
||||
Name: "POD_NAME",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
expectedSubPath: "foo/bar",
|
||||
expectedMountPath: "",
|
||||
},
|
||||
{
|
||||
name: "volumes expanded with empty subpath",
|
||||
container: &v1.Container{
|
||||
VolumeMounts: []v1.VolumeMount{{SubPath: ""}},
|
||||
},
|
||||
envs: []EnvVar{
|
||||
{
|
||||
Name: "POD_NAME",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
expectedSubPath: "",
|
||||
expectedMountPath: "",
|
||||
},
|
||||
{
|
||||
name: "volumes expanded with no envs subpath",
|
||||
container: &v1.Container{
|
||||
VolumeMounts: []v1.VolumeMount{{SubPath: "/foo/$(POD_NAME)"}},
|
||||
},
|
||||
expectedSubPath: "/foo/$(POD_NAME)",
|
||||
expectedMountPath: "",
|
||||
},
|
||||
{
|
||||
name: "volumes expanded with leading environment variable",
|
||||
container: &v1.Container{
|
||||
VolumeMounts: []v1.VolumeMount{{SubPath: "$(POD_NAME)/bar"}},
|
||||
},
|
||||
envs: []EnvVar{
|
||||
{
|
||||
Name: "POD_NAME",
|
||||
Value: "foo",
|
||||
},
|
||||
},
|
||||
expectedSubPath: "foo/bar",
|
||||
expectedMountPath: "",
|
||||
},
|
||||
{
|
||||
name: "volumes with volume and subpath",
|
||||
container: &v1.Container{
|
||||
VolumeMounts: []v1.VolumeMount{{MountPath: "/foo", SubPath: "$(POD_NAME)/bar"}},
|
||||
},
|
||||
envs: []EnvVar{
|
||||
{
|
||||
Name: "POD_NAME",
|
||||
Value: "foo",
|
||||
},
|
||||
},
|
||||
expectedSubPath: "foo/bar",
|
||||
expectedMountPath: "/foo",
|
||||
},
|
||||
{
|
||||
name: "volumes with volume and no subpath",
|
||||
container: &v1.Container{
|
||||
VolumeMounts: []v1.VolumeMount{{MountPath: "/foo"}},
|
||||
},
|
||||
envs: []EnvVar{
|
||||
{
|
||||
Name: "POD_NAME",
|
||||
Value: "foo",
|
||||
},
|
||||
},
|
||||
expectedSubPath: "",
|
||||
expectedMountPath: "/foo",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
actualSubPath := ExpandContainerVolumeMounts(tc.container.VolumeMounts[0], tc.envs)
|
||||
if e, a := tc.expectedSubPath, actualSubPath; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%v: unexpected subpath; expected %v, got %v", tc.name, e, a)
|
||||
}
|
||||
if e, a := tc.expectedMountPath, tc.container.VolumeMounts[0].MountPath; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%v: unexpected mountpath; expected %v, got %v", tc.name, e, a)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestShouldContainerBeRestarted(t *testing.T) {
|
||||
pod := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
2
vendor/k8s.io/kubernetes/pkg/kubelet/container/os.go
generated
vendored
2
vendor/k8s.io/kubernetes/pkg/kubelet/container/os.go
generated
vendored
@ -43,7 +43,7 @@ type OSInterface interface {
|
||||
// RealOS is used to dispatch the real system level operations.
|
||||
type RealOS struct{}
|
||||
|
||||
// MkDir will will call os.Mkdir to create a directory.
|
||||
// MkdirAll will call os.MkdirAll to create a directory.
|
||||
func (RealOS) MkdirAll(path string, perm os.FileMode) error {
|
||||
return os.MkdirAll(path, perm)
|
||||
}
|
||||
|
30
vendor/k8s.io/kubernetes/pkg/kubelet/container/pty_linux.go
generated
vendored
30
vendor/k8s.io/kubernetes/pkg/kubelet/container/pty_linux.go
generated
vendored
@ -1,30 +0,0 @@
|
||||
// +build linux
|
||||
|
||||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package container
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/kr/pty"
|
||||
)
|
||||
|
||||
func StartPty(c *exec.Cmd) (*os.File, error) {
|
||||
return pty.Start(c)
|
||||
}
|
28
vendor/k8s.io/kubernetes/pkg/kubelet/container/pty_unsupported.go
generated
vendored
28
vendor/k8s.io/kubernetes/pkg/kubelet/container/pty_unsupported.go
generated
vendored
@ -1,28 +0,0 @@
|
||||
// +build !linux
|
||||
|
||||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package container
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func StartPty(c *exec.Cmd) (pty *os.File, err error) {
|
||||
return nil, nil
|
||||
}
|
15
vendor/k8s.io/kubernetes/pkg/kubelet/container/ref_test.go
generated
vendored
15
vendor/k8s.io/kubernetes/pkg/kubelet/container/ref_test.go
generated
vendored
@ -21,7 +21,6 @@ import (
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
)
|
||||
|
||||
@ -68,14 +67,14 @@ func TestGenerateContainerRef(t *testing.T) {
|
||||
okPod = v1.Pod{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersion.String(),
|
||||
APIVersion: "v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "ok",
|
||||
Namespace: "test-ns",
|
||||
UID: "bar",
|
||||
ResourceVersion: "42",
|
||||
SelfLink: "/api/" + legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersion.String() + "/pods/foo",
|
||||
SelfLink: "/api/v1/pods/foo",
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
@ -92,7 +91,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
||||
noSelfLinkPod.Kind = ""
|
||||
noSelfLinkPod.APIVersion = ""
|
||||
noSelfLinkPod.ObjectMeta.SelfLink = ""
|
||||
defaultedSelfLinkPod.ObjectMeta.SelfLink = "/api/" + legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersion.String() + "/pods/ok"
|
||||
defaultedSelfLinkPod.ObjectMeta.SelfLink = "/api/v1/pods/ok"
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
@ -109,7 +108,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
||||
},
|
||||
expected: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
APIVersion: legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersion.String(),
|
||||
APIVersion: "v1",
|
||||
Name: "ok",
|
||||
Namespace: "test-ns",
|
||||
UID: "bar",
|
||||
@ -124,7 +123,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
||||
container: &v1.Container{},
|
||||
expected: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
APIVersion: legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersion.String(),
|
||||
APIVersion: "v1",
|
||||
Name: "ok",
|
||||
Namespace: "test-ns",
|
||||
UID: "bar",
|
||||
@ -148,7 +147,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
||||
},
|
||||
expected: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
APIVersion: legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersion.String(),
|
||||
APIVersion: "v1",
|
||||
Name: "ok",
|
||||
Namespace: "test-ns",
|
||||
UID: "bar",
|
||||
@ -165,7 +164,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
||||
},
|
||||
expected: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
APIVersion: legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersion.String(),
|
||||
APIVersion: "v1",
|
||||
Name: "ok",
|
||||
Namespace: "test-ns",
|
||||
UID: "bar",
|
||||
|
6
vendor/k8s.io/kubernetes/pkg/kubelet/container/resize.go
generated
vendored
6
vendor/k8s.io/kubernetes/pkg/kubelet/container/resize.go
generated
vendored
@ -32,11 +32,7 @@ func HandleResizing(resize <-chan remotecommand.TerminalSize, resizeFunc func(si
|
||||
go func() {
|
||||
defer runtime.HandleCrash()
|
||||
|
||||
for {
|
||||
size, ok := <-resize
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for size := range resize {
|
||||
if size.Height < 1 || size.Width < 1 {
|
||||
continue
|
||||
}
|
||||
|
25
vendor/k8s.io/kubernetes/pkg/kubelet/container/runtime.go
generated
vendored
25
vendor/k8s.io/kubernetes/pkg/kubelet/container/runtime.go
generated
vendored
@ -95,7 +95,7 @@ type Runtime interface {
|
||||
// it is useful when doing SIGKILL for hard eviction scenarios, or max grace period during soft eviction scenarios.
|
||||
KillPod(pod *v1.Pod, runningPod Pod, gracePeriodOverride *int64) error
|
||||
// GetPodStatus retrieves the status of the pod, including the
|
||||
// information of all containers in the pod that are visble in Runtime.
|
||||
// information of all containers in the pod that are visible in Runtime.
|
||||
GetPodStatus(uid types.UID, name, namespace string) (*PodStatus, error)
|
||||
// Returns the filesystem path of the pod's network namespace; if the
|
||||
// runtime does not handle namespace creation itself, or cannot return
|
||||
@ -124,22 +124,10 @@ type Runtime interface {
|
||||
UpdatePodCIDR(podCIDR string) error
|
||||
}
|
||||
|
||||
// DirectStreamingRuntime is the interface implemented by runtimes for which the streaming calls
|
||||
// (exec/attach/port-forward) should be served directly by the Kubelet.
|
||||
type DirectStreamingRuntime interface {
|
||||
// Runs the command in the container of the specified pod. Attaches
|
||||
// the processes stdin, stdout, and stderr. Optionally uses a tty.
|
||||
ExecInContainer(containerID ContainerID, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error
|
||||
// Forward the specified port from the specified pod to the stream.
|
||||
PortForward(pod *Pod, port int32, stream io.ReadWriteCloser) error
|
||||
// ContainerAttach encapsulates the attaching to containers for testability
|
||||
ContainerAttacher
|
||||
}
|
||||
|
||||
// IndirectStreamingRuntime is the interface implemented by runtimes that handle the serving of the
|
||||
// StreamingRuntime is the interface implemented by runtimes that handle the serving of the
|
||||
// streaming calls (exec/attach/port-forward) themselves. In this case, Kubelet should redirect to
|
||||
// the runtime server.
|
||||
type IndirectStreamingRuntime interface {
|
||||
type StreamingRuntime interface {
|
||||
GetExec(id ContainerID, cmd []string, stdin, stdout, stderr, tty bool) (*url.URL, error)
|
||||
GetAttach(id ContainerID, stdin, stdout, stderr, tty bool) (*url.URL, error)
|
||||
GetPortForward(podName, podNamespace string, podUID types.UID, ports []int32) (*url.URL, error)
|
||||
@ -198,7 +186,7 @@ type PodPair struct {
|
||||
|
||||
// ContainerID is a type that identifies a container.
|
||||
type ContainerID struct {
|
||||
// The type of the container runtime. e.g. 'docker', 'rkt'.
|
||||
// The type of the container runtime. e.g. 'docker'.
|
||||
Type string
|
||||
// The identification of the container, this is comsumable by
|
||||
// the underlying container runtime. (Note that the container
|
||||
@ -444,8 +432,6 @@ type RunContainerOptions struct {
|
||||
// this directory will be used to create and mount the log file to
|
||||
// container.TerminationMessagePath
|
||||
PodContainerDir string
|
||||
// The parent cgroup to pass to Docker
|
||||
CgroupParent string
|
||||
// The type of container rootfs
|
||||
ReadOnly bool
|
||||
// hostname for pod containers
|
||||
@ -470,6 +456,9 @@ type VolumeInfo struct {
|
||||
// Whether the volume permission is set to read-only or not
|
||||
// This value is passed from volume.spec
|
||||
ReadOnly bool
|
||||
// Inner volume spec name, which is the PV name if used, otherwise
|
||||
// it is the same as the outer volume spec name.
|
||||
InnerVolumeSpecName string
|
||||
}
|
||||
|
||||
type VolumeMap map[string]VolumeInfo
|
||||
|
73
vendor/k8s.io/kubernetes/pkg/kubelet/container/testing/fake_runtime.go
generated
vendored
73
vendor/k8s.io/kubernetes/pkg/kubelet/container/testing/fake_runtime.go
generated
vendored
@ -26,7 +26,6 @@ import (
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/client-go/tools/remotecommand"
|
||||
"k8s.io/client-go/util/flowcontrol"
|
||||
. "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
@ -59,34 +58,13 @@ type FakeRuntime struct {
|
||||
StatusErr error
|
||||
}
|
||||
|
||||
type FakeDirectStreamingRuntime struct {
|
||||
*FakeRuntime
|
||||
|
||||
// Arguments to streaming method calls.
|
||||
Args struct {
|
||||
// Attach / Exec args
|
||||
ContainerID ContainerID
|
||||
Cmd []string
|
||||
Stdin io.Reader
|
||||
Stdout io.WriteCloser
|
||||
Stderr io.WriteCloser
|
||||
TTY bool
|
||||
// Port-forward args
|
||||
Pod *Pod
|
||||
Port int32
|
||||
Stream io.ReadWriteCloser
|
||||
}
|
||||
}
|
||||
|
||||
var _ DirectStreamingRuntime = &FakeDirectStreamingRuntime{}
|
||||
|
||||
const FakeHost = "localhost:12345"
|
||||
|
||||
type FakeIndirectStreamingRuntime struct {
|
||||
type FakeStreamingRuntime struct {
|
||||
*FakeRuntime
|
||||
}
|
||||
|
||||
var _ IndirectStreamingRuntime = &FakeIndirectStreamingRuntime{}
|
||||
var _ StreamingRuntime = &FakeStreamingRuntime{}
|
||||
|
||||
// FakeRuntime should implement Runtime.
|
||||
var _ Runtime = &FakeRuntime{}
|
||||
@ -311,35 +289,6 @@ func (f *FakeRuntime) GetPodStatus(uid types.UID, name, namespace string) (*PodS
|
||||
return &status, f.Err
|
||||
}
|
||||
|
||||
func (f *FakeDirectStreamingRuntime) ExecInContainer(containerID ContainerID, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
f.CalledFunctions = append(f.CalledFunctions, "ExecInContainer")
|
||||
f.Args.ContainerID = containerID
|
||||
f.Args.Cmd = cmd
|
||||
f.Args.Stdin = stdin
|
||||
f.Args.Stdout = stdout
|
||||
f.Args.Stderr = stderr
|
||||
f.Args.TTY = tty
|
||||
|
||||
return f.Err
|
||||
}
|
||||
|
||||
func (f *FakeDirectStreamingRuntime) AttachContainer(containerID ContainerID, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
f.CalledFunctions = append(f.CalledFunctions, "AttachContainer")
|
||||
f.Args.ContainerID = containerID
|
||||
f.Args.Stdin = stdin
|
||||
f.Args.Stdout = stdout
|
||||
f.Args.Stderr = stderr
|
||||
f.Args.TTY = tty
|
||||
|
||||
return f.Err
|
||||
}
|
||||
|
||||
func (f *FakeRuntime) GetContainerLogs(pod *v1.Pod, containerID ContainerID, logOptions *v1.PodLogOptions, stdout, stderr io.Writer) (err error) {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
@ -394,18 +343,6 @@ func (f *FakeRuntime) RemoveImage(image ImageSpec) error {
|
||||
return f.Err
|
||||
}
|
||||
|
||||
func (f *FakeDirectStreamingRuntime) PortForward(pod *Pod, port int32, stream io.ReadWriteCloser) error {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
f.CalledFunctions = append(f.CalledFunctions, "PortForward")
|
||||
f.Args.Pod = pod
|
||||
f.Args.Port = port
|
||||
f.Args.Stream = stream
|
||||
|
||||
return f.Err
|
||||
}
|
||||
|
||||
func (f *FakeRuntime) GetNetNS(containerID ContainerID) (string, error) {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
@ -455,7 +392,7 @@ func (f *FakeRuntime) ImageStats() (*ImageStats, error) {
|
||||
return nil, f.Err
|
||||
}
|
||||
|
||||
func (f *FakeIndirectStreamingRuntime) GetExec(id ContainerID, cmd []string, stdin, stdout, stderr, tty bool) (*url.URL, error) {
|
||||
func (f *FakeStreamingRuntime) GetExec(id ContainerID, cmd []string, stdin, stdout, stderr, tty bool) (*url.URL, error) {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
@ -463,7 +400,7 @@ func (f *FakeIndirectStreamingRuntime) GetExec(id ContainerID, cmd []string, std
|
||||
return &url.URL{Host: FakeHost}, f.Err
|
||||
}
|
||||
|
||||
func (f *FakeIndirectStreamingRuntime) GetAttach(id ContainerID, stdin, stdout, stderr, tty bool) (*url.URL, error) {
|
||||
func (f *FakeStreamingRuntime) GetAttach(id ContainerID, stdin, stdout, stderr, tty bool) (*url.URL, error) {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
@ -471,7 +408,7 @@ func (f *FakeIndirectStreamingRuntime) GetAttach(id ContainerID, stdin, stdout,
|
||||
return &url.URL{Host: FakeHost}, f.Err
|
||||
}
|
||||
|
||||
func (f *FakeIndirectStreamingRuntime) GetPortForward(podName, podNamespace string, podUID types.UID, ports []int32) (*url.URL, error) {
|
||||
func (f *FakeStreamingRuntime) GetPortForward(podName, podNamespace string, podUID types.UID, ports []int32) (*url.URL, error) {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
|
4
vendor/k8s.io/kubernetes/pkg/kubelet/container/testing/fake_runtime_helper.go
generated
vendored
4
vendor/k8s.io/kubernetes/pkg/kubelet/container/testing/fake_runtime_helper.go
generated
vendored
@ -34,12 +34,12 @@ type FakeRuntimeHelper struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
func (f *FakeRuntimeHelper) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string) (*kubecontainer.RunContainerOptions, error) {
|
||||
func (f *FakeRuntimeHelper) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string) (*kubecontainer.RunContainerOptions, func(), error) {
|
||||
var opts kubecontainer.RunContainerOptions
|
||||
if len(container.TerminationMessagePath) != 0 {
|
||||
opts.PodContainerDir = f.PodContainerDir
|
||||
}
|
||||
return &opts, nil
|
||||
return &opts, nil, nil
|
||||
}
|
||||
|
||||
func (f *FakeRuntimeHelper) GetPodCgroupParent(pod *v1.Pod) string {
|
||||
|
Reference in New Issue
Block a user