Remove legacy dockershim streaming
This commit is contained in:
		@@ -18,7 +18,6 @@ package dockershim
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/glog"
 | 
						"github.com/golang/glog"
 | 
				
			||||||
	"github.com/golang/protobuf/proto"
 | 
						"github.com/golang/protobuf/proto"
 | 
				
			||||||
@@ -33,7 +32,6 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/kubelet/network/cni"
 | 
						"k8s.io/kubernetes/pkg/kubelet/network/cni"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/network/kubenet"
 | 
						"k8s.io/kubernetes/pkg/kubelet/network/kubenet"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/server/streaming"
 | 
						"k8s.io/kubernetes/pkg/kubelet/server/streaming"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/term"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -132,25 +130,14 @@ func NewDockerService(client dockertools.DockerInterface, seccompProfileRoot str
 | 
				
			|||||||
	return ds, nil
 | 
						return ds, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DockerService is an interface that embeds both the new RuntimeService and
 | 
					// DockerService is an interface that embeds the new RuntimeService and
 | 
				
			||||||
// ImageService interfaces, while including DockerLegacyService for backward
 | 
					// ImageService interfaces.
 | 
				
			||||||
// compatibility.
 | 
					 | 
				
			||||||
type DockerService interface {
 | 
					type DockerService interface {
 | 
				
			||||||
	internalApi.RuntimeService
 | 
						internalApi.RuntimeService
 | 
				
			||||||
	internalApi.ImageManagerService
 | 
						internalApi.ImageManagerService
 | 
				
			||||||
	DockerLegacyService
 | 
					 | 
				
			||||||
	Start() error
 | 
						Start() error
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DockerLegacyService is an interface that embeds all legacy methods for
 | 
					 | 
				
			||||||
// backward compatibility.
 | 
					 | 
				
			||||||
type DockerLegacyService interface {
 | 
					 | 
				
			||||||
	// Supporting legacy methods for docker.
 | 
					 | 
				
			||||||
	LegacyExec(containerID kubecontainer.ContainerID, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan term.Size) error
 | 
					 | 
				
			||||||
	LegacyAttach(id kubecontainer.ContainerID, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan term.Size) error
 | 
					 | 
				
			||||||
	LegacyPortForward(sandboxID string, port uint16, stream io.ReadWriteCloser) error
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type dockerService struct {
 | 
					type dockerService struct {
 | 
				
			||||||
	seccompProfileRoot string
 | 
						seccompProfileRoot string
 | 
				
			||||||
	client             dockertools.DockerInterface
 | 
						client             dockertools.DockerInterface
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,41 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
Copyright 2016 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 dockershim
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import (
 | 
					 | 
				
			||||||
	"io"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/term"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// This file implements the functions that are needed for backward
 | 
					 | 
				
			||||||
// compatibility. Therefore, it imports various kubernetes packages
 | 
					 | 
				
			||||||
// directly.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// TODO: implement the methods in this file.
 | 
					 | 
				
			||||||
func (ds *dockerService) LegacyAttach(id kubecontainer.ContainerID, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan term.Size) (err error) {
 | 
					 | 
				
			||||||
	return ds.streamingRuntime.Attach(id.ID, stdin, stdout, stderr, resize)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (ds *dockerService) LegacyPortForward(sandboxID string, port uint16, stream io.ReadWriteCloser) error {
 | 
					 | 
				
			||||||
	return ds.streamingRuntime.PortForward(sandboxID, int32(port), stream)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (ds *dockerService) LegacyExec(containerID kubecontainer.ContainerID, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan term.Size) error {
 | 
					 | 
				
			||||||
	return ds.streamingRuntime.Exec(containerID.ID, cmd, stdin, stdout, stderr, tty, resize)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -567,13 +567,7 @@ func NewMainKubelet(kubeCfg *componentconfig.KubeletConfiguration, kubeDeps *Kub
 | 
				
			|||||||
			// functions in CRI.
 | 
								// functions in CRI.
 | 
				
			||||||
			// TODO: Remove this hack after CRI is fully implemented.
 | 
								// TODO: Remove this hack after CRI is fully implemented.
 | 
				
			||||||
			// TODO: Move the instrumented interface wrapping into kuberuntime.
 | 
								// TODO: Move the instrumented interface wrapping into kuberuntime.
 | 
				
			||||||
			runtimeService = &struct {
 | 
								runtimeService = kuberuntime.NewInstrumentedRuntimeService(rs)
 | 
				
			||||||
				internalApi.RuntimeService
 | 
					 | 
				
			||||||
				dockershim.DockerLegacyService
 | 
					 | 
				
			||||||
			}{
 | 
					 | 
				
			||||||
				RuntimeService:      kuberuntime.NewInstrumentedRuntimeService(rs),
 | 
					 | 
				
			||||||
				DockerLegacyService: ds,
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			imageService = is
 | 
								imageService = is
 | 
				
			||||||
		case "remote":
 | 
							case "remote":
 | 
				
			||||||
			runtimeService, imageService, err = getRuntimeAndImageServices(kubeCfg)
 | 
								runtimeService, imageService, err = getRuntimeAndImageServices(kubeCfg)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,6 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
	runtimeApi "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
 | 
						runtimeApi "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
 | 
				
			||||||
	kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
						kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/dockershim"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/events"
 | 
						"k8s.io/kubernetes/pkg/kubelet/events"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/qos"
 | 
						"k8s.io/kubernetes/pkg/kubelet/qos"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/types"
 | 
						"k8s.io/kubernetes/pkg/kubelet/types"
 | 
				
			||||||
@@ -42,7 +41,6 @@ import (
 | 
				
			|||||||
	utilruntime "k8s.io/kubernetes/pkg/util/runtime"
 | 
						utilruntime "k8s.io/kubernetes/pkg/util/runtime"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/selinux"
 | 
						"k8s.io/kubernetes/pkg/util/selinux"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/sets"
 | 
						"k8s.io/kubernetes/pkg/util/sets"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/term"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// startContainer starts a container and returns a message indicates why it is failed on error.
 | 
					// startContainer starts a container and returns a message indicates why it is failed on error.
 | 
				
			||||||
@@ -653,17 +651,6 @@ func findNextInitContainerToRun(pod *api.Pod, podStatus *kubecontainer.PodStatus
 | 
				
			|||||||
	return nil, &pod.Spec.InitContainers[0], false
 | 
						return nil, &pod.Spec.InitContainers[0], false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// AttachContainer attaches to the container's console
 | 
					 | 
				
			||||||
// TODO: Remove this method once the indirect streaming path is fully functional.
 | 
					 | 
				
			||||||
func (m *kubeGenericRuntimeManager) AttachContainer(id kubecontainer.ContainerID, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan term.Size) (err error) {
 | 
					 | 
				
			||||||
	// Use `docker attach` directly for in-process docker integration for
 | 
					 | 
				
			||||||
	// now to unblock other tests.
 | 
					 | 
				
			||||||
	if ds, ok := m.runtimeService.(dockershim.DockerLegacyService); ok {
 | 
					 | 
				
			||||||
		return ds.LegacyAttach(id, stdin, stdout, stderr, tty, resize)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return fmt.Errorf("not implemented")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// GetContainerLogs returns logs of a specific container.
 | 
					// GetContainerLogs returns logs of a specific container.
 | 
				
			||||||
func (m *kubeGenericRuntimeManager) GetContainerLogs(pod *api.Pod, containerID kubecontainer.ContainerID, logOptions *api.PodLogOptions, stdout, stderr io.Writer) (err error) {
 | 
					func (m *kubeGenericRuntimeManager) GetContainerLogs(pod *api.Pod, containerID kubecontainer.ContainerID, logOptions *api.PodLogOptions, stdout, stderr io.Writer) (err error) {
 | 
				
			||||||
	status, err := m.runtimeService.ContainerStatus(containerID.ID)
 | 
						status, err := m.runtimeService.ContainerStatus(containerID.ID)
 | 
				
			||||||
@@ -714,19 +701,6 @@ func (m *kubeGenericRuntimeManager) RunInContainer(id kubecontainer.ContainerID,
 | 
				
			|||||||
	return append(stdout, stderr...), err
 | 
						return append(stdout, stderr...), err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Runs the command in the container of the specified pod using nsenter.
 | 
					 | 
				
			||||||
// Attaches the processes stdin, stdout, and stderr. Optionally uses a
 | 
					 | 
				
			||||||
// tty.
 | 
					 | 
				
			||||||
// TODO: Remove this method once the indirect streaming path is fully functional.
 | 
					 | 
				
			||||||
func (m *kubeGenericRuntimeManager) ExecInContainer(containerID kubecontainer.ContainerID, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan term.Size, timeout time.Duration) error {
 | 
					 | 
				
			||||||
	// Use `docker exec` directly for in-process docker integration for
 | 
					 | 
				
			||||||
	// now to unblock other tests.
 | 
					 | 
				
			||||||
	if ds, ok := m.runtimeService.(dockershim.DockerLegacyService); ok {
 | 
					 | 
				
			||||||
		return ds.LegacyExec(containerID, cmd, stdin, stdout, stderr, tty, resize)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return fmt.Errorf("not implemented")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// removeContainer removes the container and the container logs.
 | 
					// removeContainer removes the container and the container logs.
 | 
				
			||||||
// Notice that we remove the container logs first, so that container will not be removed if
 | 
					// Notice that we remove the container logs first, so that container will not be removed if
 | 
				
			||||||
// container logs are failed to be removed, and kubelet will retry this later. This guarantees
 | 
					// container logs are failed to be removed, and kubelet will retry this later. This guarantees
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,6 @@ package kuberuntime
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
					 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -33,7 +32,6 @@ import (
 | 
				
			|||||||
	internalApi "k8s.io/kubernetes/pkg/kubelet/api"
 | 
						internalApi "k8s.io/kubernetes/pkg/kubelet/api"
 | 
				
			||||||
	runtimeApi "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
 | 
						runtimeApi "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
 | 
				
			||||||
	kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
						kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/dockershim"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/events"
 | 
						"k8s.io/kubernetes/pkg/kubelet/events"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/images"
 | 
						"k8s.io/kubernetes/pkg/kubelet/images"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/lifecycle"
 | 
						"k8s.io/kubernetes/pkg/kubelet/lifecycle"
 | 
				
			||||||
@@ -114,8 +112,6 @@ type KubeGenericRuntime interface {
 | 
				
			|||||||
	kubecontainer.Runtime
 | 
						kubecontainer.Runtime
 | 
				
			||||||
	kubecontainer.IndirectStreamingRuntime
 | 
						kubecontainer.IndirectStreamingRuntime
 | 
				
			||||||
	kubecontainer.ContainerCommandRunner
 | 
						kubecontainer.ContainerCommandRunner
 | 
				
			||||||
	// TODO(timstclair): Remove this once the indirect path is fully functional.
 | 
					 | 
				
			||||||
	kubecontainer.DirectStreamingRuntime
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewKubeGenericRuntimeManager creates a new kubeGenericRuntimeManager
 | 
					// NewKubeGenericRuntimeManager creates a new kubeGenericRuntimeManager
 | 
				
			||||||
@@ -919,24 +915,6 @@ func (m *kubeGenericRuntimeManager) GetPodContainerID(pod *kubecontainer.Pod) (k
 | 
				
			|||||||
	return pod.Sandboxes[0].ID, nil
 | 
						return pod.Sandboxes[0].ID, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Forward the specified port from the specified pod to the stream.
 | 
					 | 
				
			||||||
// TODO: Remove this method once the indirect streaming path is fully functional.
 | 
					 | 
				
			||||||
func (m *kubeGenericRuntimeManager) PortForward(pod *kubecontainer.Pod, port uint16, stream io.ReadWriteCloser) error {
 | 
					 | 
				
			||||||
	formattedPod := kubecontainer.FormatPod(pod)
 | 
					 | 
				
			||||||
	if len(pod.Sandboxes) == 0 {
 | 
					 | 
				
			||||||
		glog.Errorf("No sandboxes are found for pod %q", formattedPod)
 | 
					 | 
				
			||||||
		return fmt.Errorf("sandbox for pod %q not found", formattedPod)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Use docker portforward directly for in-process docker integration
 | 
					 | 
				
			||||||
	// now to unblock other tests.
 | 
					 | 
				
			||||||
	if ds, ok := m.runtimeService.(dockershim.DockerLegacyService); ok {
 | 
					 | 
				
			||||||
		return ds.LegacyPortForward(pod.Sandboxes[0].ID.ID, port, stream)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return fmt.Errorf("not implemented")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// UpdatePodCIDR is just a passthrough method to update the runtimeConfig of the shim
 | 
					// UpdatePodCIDR is just a passthrough method to update the runtimeConfig of the shim
 | 
				
			||||||
// with the podCIDR supplied by the kubelet.
 | 
					// with the podCIDR supplied by the kubelet.
 | 
				
			||||||
func (m *kubeGenericRuntimeManager) UpdatePodCIDR(podCIDR string) error {
 | 
					func (m *kubeGenericRuntimeManager) UpdatePodCIDR(podCIDR string) error {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user