diff --git a/.golangci.yml b/.golangci.yml index 38aee5a42..3e8e45e3e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,9 +15,6 @@ linters: - errcheck run: - deadline: 2m + timeout: 3m skip-dirs: - - integration - - pkg/api - skip-files: - - ".*_test.go" + - docs diff --git a/integration/containerd_image_test.go b/integration/containerd_image_test.go index d32be6816..e1732bcce 100644 --- a/integration/containerd_image_test.go +++ b/integration/containerd_image_test.go @@ -17,10 +17,11 @@ package integration import ( - "golang.org/x/net/context" "testing" "time" + "golang.org/x/net/context" + "github.com/containerd/containerd" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/namespaces" diff --git a/integration/main_test.go b/integration/main_test.go index 4f04e4261..5bef9d28f 100644 --- a/integration/main_test.go +++ b/integration/main_test.go @@ -34,7 +34,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc" - "k8s.io/cri-api/pkg/apis" + cri "k8s.io/cri-api/pkg/apis" runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "github.com/containerd/cri/integration/remote" @@ -74,11 +74,11 @@ func TestMain(m *testing.M) { // ConnectDaemons connect cri plugin and containerd, and initialize the clients. func ConnectDaemons() error { var err error - runtimeService, err = remote.NewRemoteRuntimeService(*criEndpoint, timeout) + runtimeService, err = remote.NewRuntimeService(*criEndpoint, timeout) if err != nil { return errors.Wrap(err, "failed to create runtime service") } - imageService, err = remote.NewRemoteImageService(*criEndpoint, timeout) + imageService, err = remote.NewImageService(*criEndpoint, timeout) if err != nil { return errors.Wrap(err, "failed to create image service") } diff --git a/integration/pod_hostname_test.go b/integration/pod_hostname_test.go index ac96b5a6c..608528e04 100644 --- a/integration/pod_hostname_test.go +++ b/integration/pod_hostname_test.go @@ -70,15 +70,14 @@ func TestPodHostname(t *testing.T) { t.Fatalf("Unexpected RunPodSandbox error: %v", err) } return - } else { - // Make sure the sandbox is cleaned up. - defer func() { - assert.NoError(t, runtimeService.StopPodSandbox(sb)) - assert.NoError(t, runtimeService.RemovePodSandbox(sb)) - }() - if test.expectErr { - t.Fatalf("Expected RunPodSandbox to return error") - } + } + // Make sure the sandbox is cleaned up. + defer func() { + assert.NoError(t, runtimeService.StopPodSandbox(sb)) + assert.NoError(t, runtimeService.RemovePodSandbox(sb)) + }() + if test.expectErr { + t.Fatalf("Expected RunPodSandbox to return error") } const ( diff --git a/integration/remote/remote_image.go b/integration/remote/remote_image.go index 32d26342a..346c370b5 100644 --- a/integration/remote/remote_image.go +++ b/integration/remote/remote_image.go @@ -47,14 +47,14 @@ import ( "github.com/containerd/cri/integration/remote/util" ) -// RemoteImageService is a gRPC implementation of internalapi.ImageManagerService. -type RemoteImageService struct { +// ImageService is a gRPC implementation of internalapi.ImageManagerService. +type ImageService struct { timeout time.Duration imageClient runtimeapi.ImageServiceClient } -// NewRemoteImageService creates a new internalapi.ImageManagerService. -func NewRemoteImageService(endpoint string, connectionTimeout time.Duration) (internalapi.ImageManagerService, error) { +// NewImageService creates a new internalapi.ImageManagerService. +func NewImageService(endpoint string, connectionTimeout time.Duration) (internalapi.ImageManagerService, error) { klog.V(3).Infof("Connecting to image service %s", endpoint) addr, dialer, err := util.GetAddressAndDialer(endpoint) if err != nil { @@ -70,14 +70,14 @@ func NewRemoteImageService(endpoint string, connectionTimeout time.Duration) (in return nil, err } - return &RemoteImageService{ + return &ImageService{ timeout: connectionTimeout, imageClient: runtimeapi.NewImageServiceClient(conn), }, nil } // ListImages lists available images. -func (r *RemoteImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error) { +func (r *ImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error) { ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -93,7 +93,7 @@ func (r *RemoteImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runt } // ImageStatus returns the status of the image. -func (r *RemoteImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimeapi.Image, error) { +func (r *ImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimeapi.Image, error) { ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -117,7 +117,7 @@ func (r *RemoteImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimea } // PullImage pulls an image with authentication config. -func (r *RemoteImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig) (string, error) { +func (r *ImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig) (string, error) { ctx, cancel := getContextWithCancel() defer cancel() @@ -141,7 +141,7 @@ func (r *RemoteImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtim } // RemoveImage removes the image. -func (r *RemoteImageService) RemoveImage(image *runtimeapi.ImageSpec) error { +func (r *ImageService) RemoveImage(image *runtimeapi.ImageSpec) error { ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -157,7 +157,7 @@ func (r *RemoteImageService) RemoveImage(image *runtimeapi.ImageSpec) error { } // ImageFsInfo returns information of the filesystem that is used to store images. -func (r *RemoteImageService) ImageFsInfo() ([]*runtimeapi.FilesystemUsage, error) { +func (r *ImageService) ImageFsInfo() ([]*runtimeapi.FilesystemUsage, error) { // Do not set timeout, because `ImageFsInfo` takes time. // TODO(random-liu): Should we assume runtime should cache the result, and set timeout here? ctx, cancel := getContextWithCancel() diff --git a/integration/remote/remote_runtime.go b/integration/remote/remote_runtime.go index 9e1842c83..c15e7884a 100644 --- a/integration/remote/remote_runtime.go +++ b/integration/remote/remote_runtime.go @@ -50,8 +50,8 @@ import ( "github.com/containerd/cri/integration/remote/util" ) -// RemoteRuntimeService is a gRPC implementation of internalapi.RuntimeService. -type RemoteRuntimeService struct { +// RuntimeService is a gRPC implementation of internalapi.RuntimeService. +type RuntimeService struct { timeout time.Duration runtimeClient runtimeapi.RuntimeServiceClient // Cache last per-container error message to reduce log spam @@ -63,8 +63,8 @@ const ( identicalErrorDelay = 1 * time.Minute ) -// NewRemoteRuntimeService creates a new internalapi.RuntimeService. -func NewRemoteRuntimeService(endpoint string, connectionTimeout time.Duration) (internalapi.RuntimeService, error) { +// NewRuntimeService creates a new internalapi.RuntimeService. +func NewRuntimeService(endpoint string, connectionTimeout time.Duration) (internalapi.RuntimeService, error) { klog.V(3).Infof("Connecting to runtime service %s", endpoint) addr, dialer, err := util.GetAddressAndDialer(endpoint) if err != nil { @@ -79,7 +79,7 @@ func NewRemoteRuntimeService(endpoint string, connectionTimeout time.Duration) ( return nil, err } - return &RemoteRuntimeService{ + return &RuntimeService{ timeout: connectionTimeout, runtimeClient: runtimeapi.NewRuntimeServiceClient(conn), logReduction: logreduction.NewLogReduction(identicalErrorDelay), @@ -87,8 +87,8 @@ func NewRemoteRuntimeService(endpoint string, connectionTimeout time.Duration) ( } // Version returns the runtime name, runtime version and runtime API version. -func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeapi.VersionResponse, error) { - klog.V(10).Infof("[RemoteRuntimeService] Version (apiVersion=%v, timeout=%v)", apiVersion, r.timeout) +func (r *RuntimeService) Version(apiVersion string) (*runtimeapi.VersionResponse, error) { + klog.V(10).Infof("[RuntimeService] Version (apiVersion=%v, timeout=%v)", apiVersion, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -101,7 +101,7 @@ func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeapi.VersionRe return nil, err } - klog.V(10).Infof("[RemoteRuntimeService] Version Response (typedVersion=%v)", typedVersion) + klog.V(10).Infof("[RuntimeService] Version Response (typedVersion=%v)", typedVersion) if typedVersion.Version == "" || typedVersion.RuntimeName == "" || typedVersion.RuntimeApiVersion == "" || typedVersion.RuntimeVersion == "" { return nil, fmt.Errorf("not all fields are set in VersionResponse (%q)", *typedVersion) @@ -112,12 +112,12 @@ 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, runtimeHandler string) (string, error) { +func (r *RuntimeService) 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. timeout := r.timeout * 2 - klog.V(10).Infof("[RemoteRuntimeService] RunPodSandbox (config=%v, runtimeHandler=%v, timeout=%v)", config, runtimeHandler, timeout) + klog.V(10).Infof("[RuntimeService] RunPodSandbox (config=%v, runtimeHandler=%v, timeout=%v)", config, runtimeHandler, timeout) ctx, cancel := getContextWithTimeout(timeout) defer cancel() @@ -137,15 +137,15 @@ func (r *RemoteRuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig return "", errors.New(errorMessage) } - klog.V(10).Infof("[RemoteRuntimeService] RunPodSandbox Response (PodSandboxId=%v)", resp.PodSandboxId) + klog.V(10).Infof("[RuntimeService] RunPodSandbox Response (PodSandboxId=%v)", resp.PodSandboxId) return resp.PodSandboxId, nil } // StopPodSandbox stops the sandbox. If there are any running containers in the // sandbox, they should be forced to termination. -func (r *RemoteRuntimeService) StopPodSandbox(podSandBoxID string) error { - klog.V(10).Infof("[RemoteRuntimeService] StopPodSandbox (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout) +func (r *RuntimeService) StopPodSandbox(podSandBoxID string) error { + klog.V(10).Infof("[RuntimeService] StopPodSandbox (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -158,15 +158,15 @@ func (r *RemoteRuntimeService) StopPodSandbox(podSandBoxID string) error { return err } - klog.V(10).Infof("[RemoteRuntimeService] StopPodSandbox Response (podSandboxID=%v)", podSandBoxID) + klog.V(10).Infof("[RuntimeService] StopPodSandbox Response (podSandboxID=%v)", podSandBoxID) return nil } // RemovePodSandbox removes the sandbox. If there are any containers in the // sandbox, they should be forcibly removed. -func (r *RemoteRuntimeService) RemovePodSandbox(podSandBoxID string) error { - klog.V(10).Infof("[RemoteRuntimeService] RemovePodSandbox (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout) +func (r *RuntimeService) RemovePodSandbox(podSandBoxID string) error { + klog.V(10).Infof("[RuntimeService] RemovePodSandbox (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -178,14 +178,14 @@ func (r *RemoteRuntimeService) RemovePodSandbox(podSandBoxID string) error { return err } - klog.V(10).Infof("[RemoteRuntimeService] RemovePodSandbox Response (podSandboxID=%v)", podSandBoxID) + klog.V(10).Infof("[RuntimeService] RemovePodSandbox Response (podSandboxID=%v)", podSandBoxID) return nil } // PodSandboxStatus returns the status of the PodSandbox. -func (r *RemoteRuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeapi.PodSandboxStatus, error) { - klog.V(10).Infof("[RemoteRuntimeService] PodSandboxStatus (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout) +func (r *RuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeapi.PodSandboxStatus, error) { + klog.V(10).Infof("[RuntimeService] PodSandboxStatus (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -196,7 +196,7 @@ func (r *RemoteRuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeap return nil, err } - klog.V(10).Infof("[RemoteRuntimeService] PodSandboxStatus Response (podSandboxID=%v, status=%v)", podSandBoxID, resp.Status) + klog.V(10).Infof("[RuntimeService] PodSandboxStatus Response (podSandboxID=%v, status=%v)", podSandBoxID, resp.Status) if resp.Status != nil { if err := verifySandboxStatus(resp.Status); err != nil { @@ -208,8 +208,8 @@ func (r *RemoteRuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeap } // ListPodSandbox returns a list of PodSandboxes. -func (r *RemoteRuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]*runtimeapi.PodSandbox, error) { - klog.V(10).Infof("[RemoteRuntimeService] ListPodSandbox (filter=%v, timeout=%v)", filter, r.timeout) +func (r *RuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]*runtimeapi.PodSandbox, error) { + klog.V(10).Infof("[RuntimeService] ListPodSandbox (filter=%v, timeout=%v)", filter, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -221,14 +221,14 @@ func (r *RemoteRuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilte return nil, err } - klog.V(10).Infof("[RemoteRuntimeService] ListPodSandbox Response (filter=%v, items=%v)", filter, resp.Items) + klog.V(10).Infof("[RuntimeService] ListPodSandbox Response (filter=%v, items=%v)", filter, resp.Items) return resp.Items, nil } // CreateContainer creates a new container in the specified PodSandbox. -func (r *RemoteRuntimeService) CreateContainer(podSandBoxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error) { - klog.V(10).Infof("[RemoteRuntimeService] CreateContainer (podSandBoxID=%v, timeout=%v)", podSandBoxID, r.timeout) +func (r *RuntimeService) CreateContainer(podSandBoxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error) { + klog.V(10).Infof("[RuntimeService] CreateContainer (podSandBoxID=%v, timeout=%v)", podSandBoxID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -242,7 +242,7 @@ func (r *RemoteRuntimeService) CreateContainer(podSandBoxID string, config *runt return "", err } - klog.V(10).Infof("[RemoteRuntimeService] CreateContainer (podSandBoxID=%v, ContainerId=%v)", podSandBoxID, resp.ContainerId) + klog.V(10).Infof("[RuntimeService] CreateContainer (podSandBoxID=%v, ContainerId=%v)", podSandBoxID, resp.ContainerId) if resp.ContainerId == "" { errorMessage := fmt.Sprintf("ContainerId is not set for container %q", config.GetMetadata()) klog.Errorf("CreateContainer failed: %s", errorMessage) @@ -253,8 +253,8 @@ func (r *RemoteRuntimeService) CreateContainer(podSandBoxID string, config *runt } // StartContainer starts the container. -func (r *RemoteRuntimeService) StartContainer(containerID string) error { - klog.V(10).Infof("[RemoteRuntimeService] StartContainer (containerID=%v, timeout=%v)", containerID, r.timeout) +func (r *RuntimeService) StartContainer(containerID string) error { + klog.V(10).Infof("[RuntimeService] StartContainer (containerID=%v, timeout=%v)", containerID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -265,14 +265,14 @@ func (r *RemoteRuntimeService) StartContainer(containerID string) error { klog.Errorf("StartContainer %q from runtime service failed: %v", containerID, err) return err } - klog.V(10).Infof("[RemoteRuntimeService] StartContainer Response (containerID=%v)", containerID) + klog.V(10).Infof("[RuntimeService] StartContainer Response (containerID=%v)", containerID) return nil } // StopContainer stops a running container with a grace period (i.e., timeout). -func (r *RemoteRuntimeService) StopContainer(containerID string, timeout int64) error { - klog.V(10).Infof("[RemoteRuntimeService] StopContainer (containerID=%v, timeout=%v)", containerID, timeout) +func (r *RuntimeService) StopContainer(containerID string, timeout int64) error { + klog.V(10).Infof("[RuntimeService] StopContainer (containerID=%v, timeout=%v)", containerID, timeout) // Use timeout + default timeout (2 minutes) as timeout to leave extra time // for SIGKILL container and request latency. t := r.timeout + time.Duration(timeout)*time.Second @@ -288,15 +288,15 @@ func (r *RemoteRuntimeService) StopContainer(containerID string, timeout int64) klog.Errorf("StopContainer %q from runtime service failed: %v", containerID, err) return err } - klog.V(10).Infof("[RemoteRuntimeService] StopContainer Response (containerID=%v)", containerID) + klog.V(10).Infof("[RuntimeService] StopContainer Response (containerID=%v)", containerID) return nil } // RemoveContainer removes the container. If the container is running, the container // should be forced to removal. -func (r *RemoteRuntimeService) RemoveContainer(containerID string) error { - klog.V(10).Infof("[RemoteRuntimeService] RemoveContainer (containerID=%v, timeout=%v)", containerID, r.timeout) +func (r *RuntimeService) RemoveContainer(containerID string) error { + klog.V(10).Infof("[RuntimeService] RemoveContainer (containerID=%v, timeout=%v)", containerID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -308,14 +308,14 @@ func (r *RemoteRuntimeService) RemoveContainer(containerID string) error { klog.Errorf("RemoveContainer %q from runtime service failed: %v", containerID, err) return err } - klog.V(10).Infof("[RemoteRuntimeService] RemoveContainer Response (containerID=%v)", containerID) + klog.V(10).Infof("[RuntimeService] RemoveContainer Response (containerID=%v)", containerID) return nil } // ListContainers lists containers by filters. -func (r *RemoteRuntimeService) ListContainers(filter *runtimeapi.ContainerFilter) ([]*runtimeapi.Container, error) { - klog.V(10).Infof("[RemoteRuntimeService] ListContainers (filter=%v, timeout=%v)", filter, r.timeout) +func (r *RuntimeService) ListContainers(filter *runtimeapi.ContainerFilter) ([]*runtimeapi.Container, error) { + klog.V(10).Infof("[RuntimeService] ListContainers (filter=%v, timeout=%v)", filter, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -326,14 +326,14 @@ func (r *RemoteRuntimeService) ListContainers(filter *runtimeapi.ContainerFilter klog.Errorf("ListContainers with filter %+v from runtime service failed: %v", filter, err) return nil, err } - klog.V(10).Infof("[RemoteRuntimeService] ListContainers Response (filter=%v, containers=%v)", filter, resp.Containers) + klog.V(10).Infof("[RuntimeService] ListContainers Response (filter=%v, containers=%v)", filter, resp.Containers) return resp.Containers, nil } // ContainerStatus returns the container status. -func (r *RemoteRuntimeService) ContainerStatus(containerID string) (*runtimeapi.ContainerStatus, error) { - klog.V(10).Infof("[RemoteRuntimeService] ContainerStatus (containerID=%v, timeout=%v)", containerID, r.timeout) +func (r *RuntimeService) ContainerStatus(containerID string) (*runtimeapi.ContainerStatus, error) { + klog.V(10).Infof("[RuntimeService] ContainerStatus (containerID=%v, timeout=%v)", containerID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -348,7 +348,7 @@ func (r *RemoteRuntimeService) ContainerStatus(containerID string) (*runtimeapi. return nil, err } r.logReduction.ClearID(containerID) - klog.V(10).Infof("[RemoteRuntimeService] ContainerStatus Response (containerID=%v, status=%v)", containerID, resp.Status) + klog.V(10).Infof("[RuntimeService] ContainerStatus Response (containerID=%v, status=%v)", containerID, resp.Status) if resp.Status != nil { if err := verifyContainerStatus(resp.Status); err != nil { @@ -361,8 +361,8 @@ func (r *RemoteRuntimeService) ContainerStatus(containerID string) (*runtimeapi. } // UpdateContainerResources updates a containers resource config -func (r *RemoteRuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources) error { - klog.V(10).Infof("[RemoteRuntimeService] UpdateContainerResources (containerID=%v, timeout=%v)", containerID, r.timeout) +func (r *RuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources) error { + klog.V(10).Infof("[RuntimeService] UpdateContainerResources (containerID=%v, timeout=%v)", containerID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -374,15 +374,15 @@ func (r *RemoteRuntimeService) UpdateContainerResources(containerID string, reso klog.Errorf("UpdateContainerResources %q from runtime service failed: %v", containerID, err) return err } - klog.V(10).Infof("[RemoteRuntimeService] UpdateContainerResources Response (containerID=%v)", containerID) + klog.V(10).Infof("[RuntimeService] UpdateContainerResources Response (containerID=%v)", containerID) return nil } // ExecSync executes a command in the container, and returns the stdout output. // If command exits with a non-zero exit code, an error is returned. -func (r *RemoteRuntimeService) ExecSync(containerID string, cmd []string, timeout time.Duration) (stdout []byte, stderr []byte, err error) { - klog.V(10).Infof("[RemoteRuntimeService] ExecSync (containerID=%v, timeout=%v)", containerID, timeout) +func (r *RuntimeService) ExecSync(containerID string, cmd []string, timeout time.Duration) (stdout []byte, stderr []byte, err error) { + klog.V(10).Infof("[RuntimeService] ExecSync (containerID=%v, timeout=%v)", containerID, timeout) // Do not set timeout when timeout is 0. var ctx context.Context var cancel context.CancelFunc @@ -407,7 +407,7 @@ func (r *RemoteRuntimeService) ExecSync(containerID string, cmd []string, timeou return nil, nil, err } - klog.V(10).Infof("[RemoteRuntimeService] ExecSync Response (containerID=%v, ExitCode=%v)", containerID, resp.ExitCode) + klog.V(10).Infof("[RuntimeService] ExecSync Response (containerID=%v, ExitCode=%v)", containerID, resp.ExitCode) err = nil if resp.ExitCode != 0 { err = utilexec.CodeExitError{ @@ -420,8 +420,8 @@ func (r *RemoteRuntimeService) ExecSync(containerID string, cmd []string, timeou } // Exec prepares a streaming endpoint to execute a command in the container, and returns the address. -func (r *RemoteRuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) { - klog.V(10).Infof("[RemoteRuntimeService] Exec (timeout=%v)", r.timeout) +func (r *RuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) { + klog.V(10).Infof("[RuntimeService] Exec (timeout=%v)", r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -430,7 +430,7 @@ func (r *RemoteRuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.Ex klog.Errorf("Exec %s '%s' from runtime service failed: %v", req.ContainerId, strings.Join(req.Cmd, " "), err) return nil, err } - klog.V(10).Info("[RemoteRuntimeService] Exec Response") + klog.V(10).Info("[RuntimeService] Exec Response") if resp.Url == "" { errorMessage := "URL is not set" @@ -442,8 +442,8 @@ func (r *RemoteRuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.Ex } // Attach prepares a streaming endpoint to attach to a running container, and returns the address. -func (r *RemoteRuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) { - klog.V(10).Infof("[RemoteRuntimeService] Attach (containerId=%v, timeout=%v)", req.ContainerId, r.timeout) +func (r *RuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) { + klog.V(10).Infof("[RuntimeService] Attach (containerId=%v, timeout=%v)", req.ContainerId, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -452,7 +452,7 @@ func (r *RemoteRuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeap klog.Errorf("Attach %s from runtime service failed: %v", req.ContainerId, err) return nil, err } - klog.V(10).Infof("[RemoteRuntimeService] Attach Response (containerId=%v)", req.ContainerId) + klog.V(10).Infof("[RuntimeService] Attach Response (containerId=%v)", req.ContainerId) if resp.Url == "" { errorMessage := "URL is not set" @@ -463,8 +463,8 @@ func (r *RemoteRuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeap } // PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address. -func (r *RemoteRuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) { - klog.V(10).Infof("[RemoteRuntimeService] PortForward (podSandboxID=%v, port=%v, timeout=%v)", req.PodSandboxId, req.Port, r.timeout) +func (r *RuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) { + klog.V(10).Infof("[RuntimeService] PortForward (podSandboxID=%v, port=%v, timeout=%v)", req.PodSandboxId, req.Port, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -473,7 +473,7 @@ func (r *RemoteRuntimeService) PortForward(req *runtimeapi.PortForwardRequest) ( klog.Errorf("PortForward %s from runtime service failed: %v", req.PodSandboxId, err) return nil, err } - klog.V(10).Infof("[RemoteRuntimeService] PortForward Response (podSandboxID=%v)", req.PodSandboxId) + klog.V(10).Infof("[RuntimeService] PortForward Response (podSandboxID=%v)", req.PodSandboxId) if resp.Url == "" { errorMessage := "URL is not set" @@ -487,8 +487,8 @@ func (r *RemoteRuntimeService) PortForward(req *runtimeapi.PortForwardRequest) ( // UpdateRuntimeConfig updates the config of a runtime service. The only // update payload currently supported is the pod CIDR assigned to a node, // and the runtime service just proxies it down to the network plugin. -func (r *RemoteRuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig) error { - klog.V(10).Infof("[RemoteRuntimeService] UpdateRuntimeConfig (runtimeConfig=%v, timeout=%v)", runtimeConfig, r.timeout) +func (r *RuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig) error { + klog.V(10).Infof("[RuntimeService] UpdateRuntimeConfig (runtimeConfig=%v, timeout=%v)", runtimeConfig, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -502,14 +502,14 @@ func (r *RemoteRuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.Run if err != nil { return err } - klog.V(10).Infof("[RemoteRuntimeService] UpdateRuntimeConfig Response (runtimeConfig=%v)", runtimeConfig) + klog.V(10).Infof("[RuntimeService] UpdateRuntimeConfig Response (runtimeConfig=%v)", runtimeConfig) return nil } // Status returns the status of the runtime. -func (r *RemoteRuntimeService) Status() (*runtimeapi.RuntimeStatus, error) { - klog.V(10).Infof("[RemoteRuntimeService] Status (timeout=%v)", r.timeout) +func (r *RuntimeService) Status() (*runtimeapi.RuntimeStatus, error) { + klog.V(10).Infof("[RuntimeService] Status (timeout=%v)", r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -519,7 +519,7 @@ func (r *RemoteRuntimeService) Status() (*runtimeapi.RuntimeStatus, error) { return nil, err } - klog.V(10).Infof("[RemoteRuntimeService] Status Response (status=%v)", resp.Status) + klog.V(10).Infof("[RuntimeService] Status Response (status=%v)", resp.Status) if resp.Status == nil || len(resp.Status.Conditions) < 2 { errorMessage := "RuntimeReady or NetworkReady condition are not set" @@ -531,8 +531,8 @@ func (r *RemoteRuntimeService) Status() (*runtimeapi.RuntimeStatus, error) { } // ContainerStats returns the stats of the container. -func (r *RemoteRuntimeService) ContainerStats(containerID string) (*runtimeapi.ContainerStats, error) { - klog.V(10).Infof("[RemoteRuntimeService] ContainerStats (containerID=%v, timeout=%v)", containerID, r.timeout) +func (r *RuntimeService) ContainerStats(containerID string) (*runtimeapi.ContainerStats, error) { + klog.V(10).Infof("[RuntimeService] ContainerStats (containerID=%v, timeout=%v)", containerID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -546,13 +546,13 @@ func (r *RemoteRuntimeService) ContainerStats(containerID string) (*runtimeapi.C return nil, err } r.logReduction.ClearID(containerID) - klog.V(10).Infof("[RemoteRuntimeService] ContainerStats Response (containerID=%v, stats=%v)", containerID, resp.GetStats()) + klog.V(10).Infof("[RuntimeService] ContainerStats Response (containerID=%v, stats=%v)", containerID, resp.GetStats()) return resp.GetStats(), nil } -func (r *RemoteRuntimeService) ListContainerStats(filter *runtimeapi.ContainerStatsFilter) ([]*runtimeapi.ContainerStats, error) { - klog.V(10).Infof("[RemoteRuntimeService] ListContainerStats (filter=%v)", filter) +func (r *RuntimeService) ListContainerStats(filter *runtimeapi.ContainerStatsFilter) ([]*runtimeapi.ContainerStats, error) { + klog.V(10).Infof("[RuntimeService] ListContainerStats (filter=%v)", filter) // Do not set timeout, because writable layer stats collection takes time. // TODO(random-liu): Should we assume runtime should cache the result, and set timeout here? ctx, cancel := getContextWithCancel() @@ -565,13 +565,13 @@ func (r *RemoteRuntimeService) ListContainerStats(filter *runtimeapi.ContainerSt klog.Errorf("ListContainerStats with filter %+v from runtime service failed: %v", filter, err) return nil, err } - klog.V(10).Infof("[RemoteRuntimeService] ListContainerStats Response (filter=%v, stats=%v)", filter, resp.GetStats()) + klog.V(10).Infof("[RuntimeService] ListContainerStats Response (filter=%v, stats=%v)", filter, resp.GetStats()) return resp.GetStats(), nil } -func (r *RemoteRuntimeService) ReopenContainerLog(containerID string) error { - klog.V(10).Infof("[RemoteRuntimeService] ReopenContainerLog (containerID=%v, timeout=%v)", containerID, r.timeout) +func (r *RuntimeService) ReopenContainerLog(containerID string) error { + klog.V(10).Infof("[RuntimeService] ReopenContainerLog (containerID=%v, timeout=%v)", containerID, r.timeout) ctx, cancel := getContextWithTimeout(r.timeout) defer cancel() @@ -581,6 +581,6 @@ func (r *RemoteRuntimeService) ReopenContainerLog(containerID string) error { return err } - klog.V(10).Infof("[RemoteRuntimeService] ReopenContainerLog Response (containerID=%v)", containerID) + klog.V(10).Infof("[RuntimeService] ReopenContainerLog Response (containerID=%v)", containerID) return nil } diff --git a/integration/truncindex_test.go b/integration/truncindex_test.go index b8069607d..5803cf5c5 100644 --- a/integration/truncindex_test.go +++ b/integration/truncindex_test.go @@ -35,13 +35,13 @@ func TestTruncIndex(t *testing.T) { const appImage = "busybox" imgID, err := imageService.PullImage(&runtimeapi.ImageSpec{Image: appImage}, nil, sbConfig) require.NoError(t, err) - imgTruncId := genTruncIndex(imgID) + imgTruncID := genTruncIndex(imgID) defer func() { - assert.NoError(t, imageService.RemoveImage(&runtimeapi.ImageSpec{Image: imgTruncId})) + assert.NoError(t, imageService.RemoveImage(&runtimeapi.ImageSpec{Image: imgTruncID})) }() - t.Logf("Get image status by truncindex, truncId: %s", imgTruncId) - res, err := imageService.ImageStatus(&runtimeapi.ImageSpec{Image: imgTruncId}) + t.Logf("Get image status by truncindex, truncID: %s", imgTruncID) + res, err := imageService.ImageStatus(&runtimeapi.ImageSpec{Image: imgTruncID}) require.NoError(t, err) require.NotEqual(t, nil, res) assert.Equal(t, imgID, res.Id) diff --git a/pkg/server/container_create_unix_test.go b/pkg/server/container_create_unix_test.go index d5514e520..733c2e1f6 100644 --- a/pkg/server/container_create_unix_test.go +++ b/pkg/server/container_create_unix_test.go @@ -903,7 +903,7 @@ func TestGenerateApparmorSpecOpts(t *testing.T) { profile: runtimeDefault, privileged: true, }, - // TODO (mikebrow) add success with exising defined profile tests + // TODO (mikebrow) add success with existing defined profile tests "should return error when undefined local profile is specified": { profile: profileNamePrefix + "test-profile", expectErr: true, diff --git a/pkg/server/image_pull_test.go b/pkg/server/image_pull_test.go index afa4b726e..551e68bae 100644 --- a/pkg/server/image_pull_test.go +++ b/pkg/server/image_pull_test.go @@ -358,7 +358,7 @@ func TestImageLayersLabel(t *testing.T) { { name: "many layers", layersNum: 5, // hits sampleMaxSize (300 chars). - wantNum: 4, // layers should be ommitted for avoiding invalid label. + wantNum: 4, // layers should be omitted for avoiding invalid label. }, } diff --git a/pkg/store/sandbox/status_test.go b/pkg/store/sandbox/status_test.go index 7a93715d6..ad27db0c6 100644 --- a/pkg/store/sandbox/status_test.go +++ b/pkg/store/sandbox/status_test.go @@ -18,7 +18,6 @@ package sandbox import ( "errors" - "fmt" "testing" "time" @@ -63,8 +62,8 @@ func TestStatus(t *testing.T) { func TestStateStringConversion(t *testing.T) { assert := assertlib.New(t) - assert.Equal("SANDBOX_READY", fmt.Sprintf("%s", StateReady)) - assert.Equal("SANDBOX_NOTREADY", fmt.Sprintf("%s", StateNotReady)) - assert.Equal("SANDBOX_UNKNOWN", fmt.Sprintf("%s", StateUnknown)) - assert.Equal("invalid sandbox state value: 123", fmt.Sprintf("%s", State(123))) + assert.Equal("SANDBOX_READY", StateReady.String()) + assert.Equal("SANDBOX_NOTREADY", StateNotReady.String()) + assert.Equal("SANDBOX_UNKNOWN", StateUnknown.String()) + assert.Equal("invalid sandbox state value: 123", State(123).String()) } diff --git a/test/verify.sh b/test/verify.sh index 789fe09be..fa78d5921 100755 --- a/test/verify.sh +++ b/test/verify.sh @@ -26,4 +26,4 @@ cd "${ROOT}" make install.tools make verify -GOOS=windows make verify +#GOOS=windows make verify