Fresh dep ensure

This commit is contained in:
Mike Cronce
2018-11-26 13:23:56 -05:00
parent 93cb8a04d7
commit 407478ab9a
9016 changed files with 551394 additions and 279685 deletions

View File

@ -19,8 +19,8 @@ go_library(
"//pkg/kubelet/apis/cri:go_default_library",
"//pkg/kubelet/apis/cri/runtime/v1alpha2:go_default_library",
"//pkg/kubelet/util:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/utils/exec:go_default_library",
],
)

View File

@ -11,44 +11,11 @@ go_library(
name = "go_default_library",
srcs = [
"doc.go",
"endpoint.go",
"endpoint_windows.go",
"fake_image_service.go",
"fake_runtime.go",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:darwin": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:dragonfly": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:freebsd": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:linux": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:nacl": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:netbsd": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:openbsd": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:plan9": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:solaris": [
"endpoint.go",
],
"@io_bazel_rules_go//go/platform:windows": [
"endpoint_windows.go",
],
"//conditions:default": [],
}),
],
importpath = "k8s.io/kubernetes/pkg/kubelet/remote/fake",
tags = ["automanaged"],
deps = [

View File

@ -77,7 +77,7 @@ func (f *RemoteRuntime) Version(ctx context.Context, req *kubeapi.VersionRequest
// RunPodSandbox creates and starts a pod-level sandbox. Runtimes must ensure
// the sandbox is in the ready state on success.
func (f *RemoteRuntime) RunPodSandbox(ctx context.Context, req *kubeapi.RunPodSandboxRequest) (*kubeapi.RunPodSandboxResponse, error) {
sandboxID, err := f.RuntimeService.RunPodSandbox(req.Config)
sandboxID, err := f.RuntimeService.RunPodSandbox(req.Config, req.RuntimeHandler)
if err != nil {
return nil, err
}

View File

@ -17,12 +17,13 @@ limitations under the License.
package remote
import (
"context"
"errors"
"fmt"
"time"
"github.com/golang/glog"
"google.golang.org/grpc"
"k8s.io/klog"
internalapi "k8s.io/kubernetes/pkg/kubelet/apis/cri"
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
@ -37,15 +38,18 @@ type RemoteImageService struct {
// NewRemoteImageService creates a new internalapi.ImageManagerService.
func NewRemoteImageService(endpoint string, connectionTimeout time.Duration) (internalapi.ImageManagerService, error) {
glog.V(3).Infof("Connecting to image service %s", endpoint)
klog.V(3).Infof("Connecting to image service %s", endpoint)
addr, dailer, err := util.GetAddressAndDialer(endpoint)
if err != nil {
return nil, err
}
conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithTimeout(connectionTimeout), grpc.WithDialer(dailer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
defer cancel()
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithDialer(dailer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
if err != nil {
glog.Errorf("Connect remote image service %s failed: %v", addr, err)
klog.Errorf("Connect remote image service %s failed: %v", addr, err)
return nil, err
}
@ -64,7 +68,7 @@ func (r *RemoteImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runt
Filter: filter,
})
if err != nil {
glog.Errorf("ListImages with filter %+v from image service failed: %v", filter, err)
klog.Errorf("ListImages with filter %+v from image service failed: %v", filter, err)
return nil, err
}
@ -80,14 +84,14 @@ func (r *RemoteImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimea
Image: image,
})
if err != nil {
glog.Errorf("ImageStatus %q from image service failed: %v", image.Image, err)
klog.Errorf("ImageStatus %q from image service failed: %v", image.Image, err)
return nil, err
}
if resp.Image != nil {
if resp.Image.Id == "" || resp.Image.Size_ == 0 {
errorMessage := fmt.Sprintf("Id or size of image %q is not set", image.Image)
glog.Errorf("ImageStatus failed: %s", errorMessage)
klog.Errorf("ImageStatus failed: %s", errorMessage)
return nil, errors.New(errorMessage)
}
}
@ -105,13 +109,13 @@ func (r *RemoteImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtim
Auth: auth,
})
if err != nil {
glog.Errorf("PullImage %q from image service failed: %v", image.Image, err)
klog.Errorf("PullImage %q from image service failed: %v", image.Image, err)
return "", err
}
if resp.ImageRef == "" {
errorMessage := fmt.Sprintf("imageRef of image %q is not set", image.Image)
glog.Errorf("PullImage failed: %s", errorMessage)
klog.Errorf("PullImage failed: %s", errorMessage)
return "", errors.New(errorMessage)
}
@ -127,7 +131,7 @@ func (r *RemoteImageService) RemoveImage(image *runtimeapi.ImageSpec) error {
Image: image,
})
if err != nil {
glog.Errorf("RemoveImage %q from image service failed: %v", image.Image, err)
klog.Errorf("RemoveImage %q from image service failed: %v", image.Image, err)
return err
}
@ -143,7 +147,7 @@ func (r *RemoteImageService) ImageFsInfo() ([]*runtimeapi.FilesystemUsage, error
resp, err := r.imageClient.ImageFsInfo(ctx, &runtimeapi.ImageFsInfoRequest{})
if err != nil {
glog.Errorf("ImageFsInfo from image service failed: %v", err)
klog.Errorf("ImageFsInfo from image service failed: %v", err)
return nil, err
}
return resp.GetImageFilesystems(), nil

View File

@ -23,8 +23,8 @@ import (
"strings"
"time"
"github.com/golang/glog"
"google.golang.org/grpc"
"k8s.io/klog"
internalapi "k8s.io/kubernetes/pkg/kubelet/apis/cri"
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
@ -40,14 +40,17 @@ type RemoteRuntimeService struct {
// NewRemoteRuntimeService creates a new internalapi.RuntimeService.
func NewRemoteRuntimeService(endpoint string, connectionTimeout time.Duration) (internalapi.RuntimeService, error) {
glog.V(3).Infof("Connecting to runtime service %s", endpoint)
klog.V(3).Infof("Connecting to runtime service %s", endpoint)
addr, dailer, err := util.GetAddressAndDialer(endpoint)
if err != nil {
return nil, err
}
conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithTimeout(connectionTimeout), grpc.WithDialer(dailer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
defer cancel()
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithDialer(dailer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
if err != nil {
glog.Errorf("Connect remote runtime %s failed: %v", addr, err)
klog.Errorf("Connect remote runtime %s failed: %v", addr, err)
return nil, err
}
@ -66,7 +69,7 @@ func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeapi.VersionRe
Version: apiVersion,
})
if err != nil {
glog.Errorf("Version from runtime service failed: %v", err)
klog.Errorf("Version from runtime service failed: %v", err)
return nil, err
}
@ -79,23 +82,24 @@ func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeapi.VersionRe
// RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
// the sandbox is in ready state.
func (r *RemoteRuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig) (string, error) {
func (r *RemoteRuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig, runtimeHandler string) (string, error) {
// Use 2 times longer timeout for sandbox operation (4 mins by default)
// TODO: Make the pod sandbox timeout configurable.
ctx, cancel := getContextWithTimeout(r.timeout * 2)
defer cancel()
resp, err := r.runtimeClient.RunPodSandbox(ctx, &runtimeapi.RunPodSandboxRequest{
Config: config,
Config: config,
RuntimeHandler: runtimeHandler,
})
if err != nil {
glog.Errorf("RunPodSandbox from runtime service failed: %v", err)
klog.Errorf("RunPodSandbox from runtime service failed: %v", err)
return "", err
}
if resp.PodSandboxId == "" {
errorMessage := fmt.Sprintf("PodSandboxId is not set for sandbox %q", config.GetMetadata())
glog.Errorf("RunPodSandbox failed: %s", errorMessage)
klog.Errorf("RunPodSandbox failed: %s", errorMessage)
return "", errors.New(errorMessage)
}
@ -112,7 +116,7 @@ func (r *RemoteRuntimeService) StopPodSandbox(podSandBoxID string) error {
PodSandboxId: podSandBoxID,
})
if err != nil {
glog.Errorf("StopPodSandbox %q from runtime service failed: %v", podSandBoxID, err)
klog.Errorf("StopPodSandbox %q from runtime service failed: %v", podSandBoxID, err)
return err
}
@ -129,7 +133,7 @@ func (r *RemoteRuntimeService) RemovePodSandbox(podSandBoxID string) error {
PodSandboxId: podSandBoxID,
})
if err != nil {
glog.Errorf("RemovePodSandbox %q from runtime service failed: %v", podSandBoxID, err)
klog.Errorf("RemovePodSandbox %q from runtime service failed: %v", podSandBoxID, err)
return err
}
@ -166,7 +170,7 @@ func (r *RemoteRuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilte
Filter: filter,
})
if err != nil {
glog.Errorf("ListPodSandbox with filter %+v from runtime service failed: %v", filter, err)
klog.Errorf("ListPodSandbox with filter %+v from runtime service failed: %v", filter, err)
return nil, err
}
@ -184,13 +188,13 @@ func (r *RemoteRuntimeService) CreateContainer(podSandBoxID string, config *runt
SandboxConfig: sandboxConfig,
})
if err != nil {
glog.Errorf("CreateContainer in sandbox %q from runtime service failed: %v", podSandBoxID, err)
klog.Errorf("CreateContainer in sandbox %q from runtime service failed: %v", podSandBoxID, err)
return "", err
}
if resp.ContainerId == "" {
errorMessage := fmt.Sprintf("ContainerId is not set for container %q", config.GetMetadata())
glog.Errorf("CreateContainer failed: %s", errorMessage)
klog.Errorf("CreateContainer failed: %s", errorMessage)
return "", errors.New(errorMessage)
}
@ -206,7 +210,7 @@ func (r *RemoteRuntimeService) StartContainer(containerID string) error {
ContainerId: containerID,
})
if err != nil {
glog.Errorf("StartContainer %q from runtime service failed: %v", containerID, err)
klog.Errorf("StartContainer %q from runtime service failed: %v", containerID, err)
return err
}
@ -226,7 +230,7 @@ func (r *RemoteRuntimeService) StopContainer(containerID string, timeout int64)
Timeout: timeout,
})
if err != nil {
glog.Errorf("StopContainer %q from runtime service failed: %v", containerID, err)
klog.Errorf("StopContainer %q from runtime service failed: %v", containerID, err)
return err
}
@ -243,7 +247,7 @@ func (r *RemoteRuntimeService) RemoveContainer(containerID string) error {
ContainerId: containerID,
})
if err != nil {
glog.Errorf("RemoveContainer %q from runtime service failed: %v", containerID, err)
klog.Errorf("RemoveContainer %q from runtime service failed: %v", containerID, err)
return err
}
@ -259,7 +263,7 @@ func (r *RemoteRuntimeService) ListContainers(filter *runtimeapi.ContainerFilter
Filter: filter,
})
if err != nil {
glog.Errorf("ListContainers with filter %+v from runtime service failed: %v", filter, err)
klog.Errorf("ListContainers with filter %+v from runtime service failed: %v", filter, err)
return nil, err
}
@ -275,13 +279,13 @@ func (r *RemoteRuntimeService) ContainerStatus(containerID string) (*runtimeapi.
ContainerId: containerID,
})
if err != nil {
glog.Errorf("ContainerStatus %q from runtime service failed: %v", containerID, err)
klog.Errorf("ContainerStatus %q from runtime service failed: %v", containerID, err)
return nil, err
}
if resp.Status != nil {
if err := verifyContainerStatus(resp.Status); err != nil {
glog.Errorf("ContainerStatus of %q failed: %v", containerID, err)
klog.Errorf("ContainerStatus of %q failed: %v", containerID, err)
return nil, err
}
}
@ -299,7 +303,7 @@ func (r *RemoteRuntimeService) UpdateContainerResources(containerID string, reso
Linux: resources,
})
if err != nil {
glog.Errorf("UpdateContainerResources %q from runtime service failed: %v", containerID, err)
klog.Errorf("UpdateContainerResources %q from runtime service failed: %v", containerID, err)
return err
}
@ -329,7 +333,7 @@ func (r *RemoteRuntimeService) ExecSync(containerID string, cmd []string, timeou
}
resp, err := r.runtimeClient.ExecSync(ctx, req)
if err != nil {
glog.Errorf("ExecSync %s '%s' from runtime service failed: %v", containerID, strings.Join(cmd, " "), err)
klog.Errorf("ExecSync %s '%s' from runtime service failed: %v", containerID, strings.Join(cmd, " "), err)
return nil, nil, err
}
@ -351,13 +355,13 @@ func (r *RemoteRuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.Ex
resp, err := r.runtimeClient.Exec(ctx, req)
if err != nil {
glog.Errorf("Exec %s '%s' from runtime service failed: %v", req.ContainerId, strings.Join(req.Cmd, " "), err)
klog.Errorf("Exec %s '%s' from runtime service failed: %v", req.ContainerId, strings.Join(req.Cmd, " "), err)
return nil, err
}
if resp.Url == "" {
errorMessage := "URL is not set"
glog.Errorf("Exec failed: %s", errorMessage)
klog.Errorf("Exec failed: %s", errorMessage)
return nil, errors.New(errorMessage)
}
@ -371,13 +375,13 @@ func (r *RemoteRuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeap
resp, err := r.runtimeClient.Attach(ctx, req)
if err != nil {
glog.Errorf("Attach %s from runtime service failed: %v", req.ContainerId, err)
klog.Errorf("Attach %s from runtime service failed: %v", req.ContainerId, err)
return nil, err
}
if resp.Url == "" {
errorMessage := "URL is not set"
glog.Errorf("Exec failed: %s", errorMessage)
klog.Errorf("Exec failed: %s", errorMessage)
return nil, errors.New(errorMessage)
}
return resp, nil
@ -390,13 +394,13 @@ func (r *RemoteRuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (
resp, err := r.runtimeClient.PortForward(ctx, req)
if err != nil {
glog.Errorf("PortForward %s from runtime service failed: %v", req.PodSandboxId, err)
klog.Errorf("PortForward %s from runtime service failed: %v", req.PodSandboxId, err)
return nil, err
}
if resp.Url == "" {
errorMessage := "URL is not set"
glog.Errorf("Exec failed: %s", errorMessage)
klog.Errorf("Exec failed: %s", errorMessage)
return nil, errors.New(errorMessage)
}
@ -431,13 +435,13 @@ func (r *RemoteRuntimeService) Status() (*runtimeapi.RuntimeStatus, error) {
resp, err := r.runtimeClient.Status(ctx, &runtimeapi.StatusRequest{})
if err != nil {
glog.Errorf("Status from runtime service failed: %v", err)
klog.Errorf("Status from runtime service failed: %v", err)
return nil, err
}
if resp.Status == nil || len(resp.Status.Conditions) < 2 {
errorMessage := "RuntimeReady or NetworkReady condition are not set"
glog.Errorf("Status failed: %s", errorMessage)
klog.Errorf("Status failed: %s", errorMessage)
return nil, errors.New(errorMessage)
}
@ -453,7 +457,7 @@ func (r *RemoteRuntimeService) ContainerStats(containerID string) (*runtimeapi.C
ContainerId: containerID,
})
if err != nil {
glog.Errorf("ContainerStatus %q from runtime service failed: %v", containerID, err)
klog.Errorf("ContainerStatus %q from runtime service failed: %v", containerID, err)
return nil, err
}
@ -470,7 +474,7 @@ func (r *RemoteRuntimeService) ListContainerStats(filter *runtimeapi.ContainerSt
Filter: filter,
})
if err != nil {
glog.Errorf("ListContainerStats with filter %+v from runtime service failed: %v", filter, err)
klog.Errorf("ListContainerStats with filter %+v from runtime service failed: %v", filter, err)
return nil, err
}
@ -483,7 +487,7 @@ func (r *RemoteRuntimeService) ReopenContainerLog(containerID string) error {
_, err := r.runtimeClient.ReopenContainerLog(ctx, &runtimeapi.ReopenContainerLogRequest{ContainerId: containerID})
if err != nil {
glog.Errorf("ReopenContainerLog %q from runtime service failed: %v", containerID, err)
klog.Errorf("ReopenContainerLog %q from runtime service failed: %v", containerID, err)
return err
}
return nil

View File

@ -24,9 +24,9 @@ import (
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
)
// maxMsgSize use 8MB as the default message size limit.
// maxMsgSize use 16MB as the default message size limit.
// grpc library default is 4MB
const maxMsgSize = 1024 * 1024 * 8
const maxMsgSize = 1024 * 1024 * 16
// getContextWithTimeout returns a context with timeout.
func getContextWithTimeout(timeout time.Duration) (context.Context, context.CancelFunc) {