feat: enable cri remote client to call with grpc calloptions
Signed-off-by: haoyun <yun.hao@daocloud.io>
This commit is contained in:
parent
0f27a423ef
commit
d16942cf16
@ -37,43 +37,44 @@ package cri
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/grpc"
|
||||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RuntimeVersioner contains methods for runtime name, version and API version.
|
// RuntimeVersioner contains methods for runtime name, version and API version.
|
||||||
type RuntimeVersioner interface {
|
type RuntimeVersioner interface {
|
||||||
// Version returns the runtime name, runtime version and runtime API version
|
// Version returns the runtime name, runtime version and runtime API version
|
||||||
Version(apiVersion string) (*runtimeapi.VersionResponse, error)
|
Version(apiVersion string, opts ...grpc.CallOption) (*runtimeapi.VersionResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerManager contains methods to manipulate containers managed by a
|
// ContainerManager contains methods to manipulate containers managed by a
|
||||||
// container runtime. The methods are thread-safe.
|
// container runtime. The methods are thread-safe.
|
||||||
type ContainerManager interface {
|
type ContainerManager interface {
|
||||||
// CreateContainer creates a new container in specified PodSandbox.
|
// CreateContainer creates a new container in specified PodSandbox.
|
||||||
CreateContainer(podSandboxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error)
|
CreateContainer(podSandboxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig, opts ...grpc.CallOption) (string, error)
|
||||||
// StartContainer starts the container.
|
// StartContainer starts the container.
|
||||||
StartContainer(containerID string) error
|
StartContainer(containerID string, opts ...grpc.CallOption) error
|
||||||
// StopContainer stops a running container with a grace period (i.e., timeout).
|
// StopContainer stops a running container with a grace period (i.e., timeout).
|
||||||
StopContainer(containerID string, timeout int64) error
|
StopContainer(containerID string, timeout int64, opts ...grpc.CallOption) error
|
||||||
// RemoveContainer removes the container.
|
// RemoveContainer removes the container.
|
||||||
RemoveContainer(containerID string) error
|
RemoveContainer(containerID string, opts ...grpc.CallOption) error
|
||||||
// ListContainers lists all containers by filters.
|
// ListContainers lists all containers by filters.
|
||||||
ListContainers(filter *runtimeapi.ContainerFilter) ([]*runtimeapi.Container, error)
|
ListContainers(filter *runtimeapi.ContainerFilter, opts ...grpc.CallOption) ([]*runtimeapi.Container, error)
|
||||||
// ContainerStatus returns the status of the container.
|
// ContainerStatus returns the status of the container.
|
||||||
ContainerStatus(containerID string) (*runtimeapi.ContainerStatus, error)
|
ContainerStatus(containerID string, opts ...grpc.CallOption) (*runtimeapi.ContainerStatus, error)
|
||||||
// UpdateContainerResources updates the cgroup resources for the container.
|
// UpdateContainerResources updates the cgroup resources for the container.
|
||||||
UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources) error
|
UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources, opts ...grpc.CallOption) error
|
||||||
// ExecSync executes a command in the container, and returns the stdout output.
|
// 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.
|
// If command exits with a non-zero exit code, an error is returned.
|
||||||
ExecSync(containerID string, cmd []string, timeout time.Duration) (stdout []byte, stderr []byte, err error)
|
ExecSync(containerID string, cmd []string, timeout time.Duration, opts ...grpc.CallOption) (stdout []byte, stderr []byte, err error)
|
||||||
// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.
|
// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.
|
||||||
Exec(*runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error)
|
Exec(req *runtimeapi.ExecRequest, opts ...grpc.CallOption) (*runtimeapi.ExecResponse, error)
|
||||||
// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
|
// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
|
||||||
Attach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error)
|
Attach(req *runtimeapi.AttachRequest, opts ...grpc.CallOption) (*runtimeapi.AttachResponse, error)
|
||||||
// ReopenContainerLog asks runtime to reopen the stdout/stderr log file
|
// ReopenContainerLog asks runtime to reopen the stdout/stderr log file
|
||||||
// for the container. If it returns error, new container log file MUST NOT
|
// for the container. If it returns error, new container log file MUST NOT
|
||||||
// be created.
|
// be created.
|
||||||
ReopenContainerLog(ContainerID string) error
|
ReopenContainerLog(ContainerID string, opts ...grpc.CallOption) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodSandboxManager contains methods for operating on PodSandboxes. The methods
|
// PodSandboxManager contains methods for operating on PodSandboxes. The methods
|
||||||
@ -81,19 +82,19 @@ type ContainerManager interface {
|
|||||||
type PodSandboxManager interface {
|
type PodSandboxManager interface {
|
||||||
// RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
|
// RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
|
||||||
// the sandbox is in ready state.
|
// the sandbox is in ready state.
|
||||||
RunPodSandbox(config *runtimeapi.PodSandboxConfig, runtimeHandler string) (string, error)
|
RunPodSandbox(config *runtimeapi.PodSandboxConfig, runtimeHandler string, opts ...grpc.CallOption) (string, error)
|
||||||
// StopPodSandbox stops the sandbox. If there are any running containers in the
|
// StopPodSandbox stops the sandbox. If there are any running containers in the
|
||||||
// sandbox, they should be force terminated.
|
// sandbox, they should be force terminated.
|
||||||
StopPodSandbox(podSandboxID string) error
|
StopPodSandbox(podSandboxID string, opts ...grpc.CallOption) error
|
||||||
// RemovePodSandbox removes the sandbox. If there are running containers in the
|
// RemovePodSandbox removes the sandbox. If there are running containers in the
|
||||||
// sandbox, they should be forcibly removed.
|
// sandbox, they should be forcibly removed.
|
||||||
RemovePodSandbox(podSandboxID string) error
|
RemovePodSandbox(podSandboxID string, opts ...grpc.CallOption) error
|
||||||
// PodSandboxStatus returns the Status of the PodSandbox.
|
// PodSandboxStatus returns the Status of the PodSandbox.
|
||||||
PodSandboxStatus(podSandboxID string) (*runtimeapi.PodSandboxStatus, error)
|
PodSandboxStatus(podSandboxID string, opts ...grpc.CallOption) (*runtimeapi.PodSandboxStatus, error)
|
||||||
// ListPodSandbox returns a list of Sandbox.
|
// ListPodSandbox returns a list of Sandbox.
|
||||||
ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]*runtimeapi.PodSandbox, error)
|
ListPodSandbox(filter *runtimeapi.PodSandboxFilter, opts ...grpc.CallOption) ([]*runtimeapi.PodSandbox, error)
|
||||||
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
|
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
|
||||||
PortForward(*runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error)
|
PortForward(req *runtimeapi.PortForwardRequest, opts ...grpc.CallOption) (*runtimeapi.PortForwardResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerStatsManager contains methods for retrieving the container
|
// ContainerStatsManager contains methods for retrieving the container
|
||||||
@ -101,9 +102,9 @@ type PodSandboxManager interface {
|
|||||||
type ContainerStatsManager interface {
|
type ContainerStatsManager interface {
|
||||||
// ContainerStats returns stats of the container. If the container does not
|
// ContainerStats returns stats of the container. If the container does not
|
||||||
// exist, the call returns an error.
|
// exist, the call returns an error.
|
||||||
ContainerStats(containerID string) (*runtimeapi.ContainerStats, error)
|
ContainerStats(containerID string, opts ...grpc.CallOption) (*runtimeapi.ContainerStats, error)
|
||||||
// ListContainerStats returns stats of all running containers.
|
// ListContainerStats returns stats of all running containers.
|
||||||
ListContainerStats(filter *runtimeapi.ContainerStatsFilter) ([]*runtimeapi.ContainerStats, error)
|
ListContainerStats(filter *runtimeapi.ContainerStatsFilter, opts ...grpc.CallOption) ([]*runtimeapi.ContainerStats, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RuntimeService interface should be implemented by a container runtime.
|
// RuntimeService interface should be implemented by a container runtime.
|
||||||
@ -115,9 +116,9 @@ type RuntimeService interface {
|
|||||||
ContainerStatsManager
|
ContainerStatsManager
|
||||||
|
|
||||||
// UpdateRuntimeConfig updates runtime configuration if specified
|
// UpdateRuntimeConfig updates runtime configuration if specified
|
||||||
UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig) error
|
UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig, opts ...grpc.CallOption) error
|
||||||
// Status returns the status of the runtime.
|
// Status returns the status of the runtime.
|
||||||
Status() (*runtimeapi.RuntimeStatus, error)
|
Status(opts ...grpc.CallOption) (*runtimeapi.RuntimeStatus, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageManagerService interface should be implemented by a container image
|
// ImageManagerService interface should be implemented by a container image
|
||||||
@ -125,13 +126,13 @@ type RuntimeService interface {
|
|||||||
// The methods should be thread-safe.
|
// The methods should be thread-safe.
|
||||||
type ImageManagerService interface {
|
type ImageManagerService interface {
|
||||||
// ListImages lists the existing images.
|
// ListImages lists the existing images.
|
||||||
ListImages(filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error)
|
ListImages(filter *runtimeapi.ImageFilter, opts ...grpc.CallOption) ([]*runtimeapi.Image, error)
|
||||||
// ImageStatus returns the status of the image.
|
// ImageStatus returns the status of the image.
|
||||||
ImageStatus(image *runtimeapi.ImageSpec) (*runtimeapi.Image, error)
|
ImageStatus(image *runtimeapi.ImageSpec, opts ...grpc.CallOption) (*runtimeapi.Image, error)
|
||||||
// PullImage pulls an image with the authentication config.
|
// PullImage pulls an image with the authentication config.
|
||||||
PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig) (string, error)
|
PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig, opts ...grpc.CallOption) (string, error)
|
||||||
// RemoveImage removes the image.
|
// RemoveImage removes the image.
|
||||||
RemoveImage(image *runtimeapi.ImageSpec) error
|
RemoveImage(image *runtimeapi.ImageSpec, opts ...grpc.CallOption) error
|
||||||
// ImageFsInfo returns information of the filesystem that is used to store images.
|
// ImageFsInfo returns information of the filesystem that is used to store images.
|
||||||
ImageFsInfo() ([]*runtimeapi.FilesystemUsage, error)
|
ImageFsInfo(opts ...grpc.CallOption) ([]*runtimeapi.FilesystemUsage, error)
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ func ConnectDaemons() error {
|
|||||||
}
|
}
|
||||||
// Since CRI grpc client doesn't have `WithBlock` specified, we
|
// Since CRI grpc client doesn't have `WithBlock` specified, we
|
||||||
// need to check whether it is actually connected.
|
// need to check whether it is actually connected.
|
||||||
// TODO(random-liu): Extend cri remote client to accept extra grpc options.
|
// TODO(#6069) Use grpc options to block on connect and remove for this list containers request.
|
||||||
_, err = runtimeService.ListContainers(&runtime.ContainerFilter{})
|
_, err = runtimeService.ListContainers(&runtime.ContainerFilter{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to list containers")
|
return errors.Wrap(err, "failed to list containers")
|
||||||
|
@ -77,13 +77,13 @@ func NewImageService(endpoint string, connectionTimeout time.Duration) (internal
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListImages lists available images.
|
// ListImages lists available images.
|
||||||
func (r *ImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error) {
|
func (r *ImageService) ListImages(filter *runtimeapi.ImageFilter, opts ...grpc.CallOption) ([]*runtimeapi.Image, error) {
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.imageClient.ListImages(ctx, &runtimeapi.ListImagesRequest{
|
resp, err := r.imageClient.ListImages(ctx, &runtimeapi.ListImagesRequest{
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return nil, err
|
||||||
@ -93,13 +93,13 @@ func (r *ImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runtimeapi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ImageStatus returns the status of the image.
|
// ImageStatus returns the status of the image.
|
||||||
func (r *ImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimeapi.Image, error) {
|
func (r *ImageService) ImageStatus(image *runtimeapi.ImageSpec, opts ...grpc.CallOption) (*runtimeapi.Image, error) {
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.imageClient.ImageStatus(ctx, &runtimeapi.ImageStatusRequest{
|
resp, err := r.imageClient.ImageStatus(ctx, &runtimeapi.ImageStatusRequest{
|
||||||
Image: image,
|
Image: image,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return nil, err
|
||||||
@ -117,7 +117,7 @@ func (r *ImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimeapi.Ima
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PullImage pulls an image with authentication config.
|
// PullImage pulls an image with authentication config.
|
||||||
func (r *ImageService) 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, opts ...grpc.CallOption) (string, error) {
|
||||||
ctx, cancel := getContextWithCancel()
|
ctx, cancel := getContextWithCancel()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ func (r *ImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.A
|
|||||||
Image: image,
|
Image: image,
|
||||||
Auth: auth,
|
Auth: auth,
|
||||||
SandboxConfig: podSandboxConfig,
|
SandboxConfig: podSandboxConfig,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return "", err
|
||||||
@ -141,13 +141,13 @@ func (r *ImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.A
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveImage removes the image.
|
// RemoveImage removes the image.
|
||||||
func (r *ImageService) RemoveImage(image *runtimeapi.ImageSpec) error {
|
func (r *ImageService) RemoveImage(image *runtimeapi.ImageSpec, opts ...grpc.CallOption) error {
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
_, err := r.imageClient.RemoveImage(ctx, &runtimeapi.RemoveImageRequest{
|
_, err := r.imageClient.RemoveImage(ctx, &runtimeapi.RemoveImageRequest{
|
||||||
Image: image,
|
Image: image,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return err
|
||||||
@ -157,13 +157,13 @@ func (r *ImageService) RemoveImage(image *runtimeapi.ImageSpec) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ImageFsInfo returns information of the filesystem that is used to store images.
|
// ImageFsInfo returns information of the filesystem that is used to store images.
|
||||||
func (r *ImageService) ImageFsInfo() ([]*runtimeapi.FilesystemUsage, error) {
|
func (r *ImageService) ImageFsInfo(opts ...grpc.CallOption) ([]*runtimeapi.FilesystemUsage, error) {
|
||||||
// Do not set timeout, because `ImageFsInfo` takes time.
|
// Do not set timeout, because `ImageFsInfo` takes time.
|
||||||
// TODO(random-liu): Should we assume runtime should cache the result, and set timeout here?
|
// TODO(random-liu): Should we assume runtime should cache the result, and set timeout here?
|
||||||
ctx, cancel := getContextWithCancel()
|
ctx, cancel := getContextWithCancel()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.imageClient.ImageFsInfo(ctx, &runtimeapi.ImageFsInfoRequest{})
|
resp, err := r.imageClient.ImageFsInfo(ctx, &runtimeapi.ImageFsInfoRequest{}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("ImageFsInfo from image service failed: %v", err)
|
klog.Errorf("ImageFsInfo from image service failed: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -87,7 +87,7 @@ func NewRuntimeService(endpoint string, connectionTimeout time.Duration) (intern
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Version returns the runtime name, runtime version and runtime API version.
|
// Version returns the runtime name, runtime version and runtime API version.
|
||||||
func (r *RuntimeService) Version(apiVersion string) (*runtimeapi.VersionResponse, error) {
|
func (r *RuntimeService) Version(apiVersion string, opts ...grpc.CallOption) (*runtimeapi.VersionResponse, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] Version (apiVersion=%v, timeout=%v)", apiVersion, r.timeout)
|
klog.V(10).Infof("[RuntimeService] Version (apiVersion=%v, timeout=%v)", apiVersion, r.timeout)
|
||||||
|
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
@ -95,7 +95,7 @@ func (r *RuntimeService) Version(apiVersion string) (*runtimeapi.VersionResponse
|
|||||||
|
|
||||||
typedVersion, err := r.runtimeClient.Version(ctx, &runtimeapi.VersionRequest{
|
typedVersion, err := r.runtimeClient.Version(ctx, &runtimeapi.VersionRequest{
|
||||||
Version: apiVersion,
|
Version: apiVersion,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Version from runtime service failed: %v", err)
|
klog.Errorf("Version from runtime service failed: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -112,7 +112,7 @@ func (r *RuntimeService) Version(apiVersion string) (*runtimeapi.VersionResponse
|
|||||||
|
|
||||||
// RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
|
// RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
|
||||||
// the sandbox is in ready state.
|
// the sandbox is in ready state.
|
||||||
func (r *RuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig, runtimeHandler string) (string, error) {
|
func (r *RuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig, runtimeHandler string, opts ...grpc.CallOption) (string, error) {
|
||||||
// Use 2 times longer timeout for sandbox operation (4 mins by default)
|
// Use 2 times longer timeout for sandbox operation (4 mins by default)
|
||||||
// TODO: Make the pod sandbox timeout configurable.
|
// TODO: Make the pod sandbox timeout configurable.
|
||||||
timeout := r.timeout * 2
|
timeout := r.timeout * 2
|
||||||
@ -125,7 +125,7 @@ func (r *RuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig, runt
|
|||||||
resp, err := r.runtimeClient.RunPodSandbox(ctx, &runtimeapi.RunPodSandboxRequest{
|
resp, err := r.runtimeClient.RunPodSandbox(ctx, &runtimeapi.RunPodSandboxRequest{
|
||||||
Config: config,
|
Config: config,
|
||||||
RuntimeHandler: runtimeHandler,
|
RuntimeHandler: runtimeHandler,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("RunPodSandbox from runtime service failed: %v", err)
|
klog.Errorf("RunPodSandbox from runtime service failed: %v", err)
|
||||||
return "", err
|
return "", err
|
||||||
@ -144,7 +144,7 @@ func (r *RuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig, runt
|
|||||||
|
|
||||||
// StopPodSandbox stops the sandbox. If there are any running containers in the
|
// StopPodSandbox stops the sandbox. If there are any running containers in the
|
||||||
// sandbox, they should be forced to termination.
|
// sandbox, they should be forced to termination.
|
||||||
func (r *RuntimeService) StopPodSandbox(podSandBoxID string) error {
|
func (r *RuntimeService) StopPodSandbox(podSandBoxID string, opts ...grpc.CallOption) error {
|
||||||
klog.V(10).Infof("[RuntimeService] StopPodSandbox (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] StopPodSandbox (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout)
|
||||||
|
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
@ -152,7 +152,7 @@ func (r *RuntimeService) StopPodSandbox(podSandBoxID string) error {
|
|||||||
|
|
||||||
_, err := r.runtimeClient.StopPodSandbox(ctx, &runtimeapi.StopPodSandboxRequest{
|
_, err := r.runtimeClient.StopPodSandbox(ctx, &runtimeapi.StopPodSandboxRequest{
|
||||||
PodSandboxId: podSandBoxID,
|
PodSandboxId: podSandBoxID,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("StopPodSandbox %q from runtime service failed: %v", podSandBoxID, err)
|
klog.Errorf("StopPodSandbox %q from runtime service failed: %v", podSandBoxID, err)
|
||||||
return err
|
return err
|
||||||
@ -165,14 +165,14 @@ func (r *RuntimeService) StopPodSandbox(podSandBoxID string) error {
|
|||||||
|
|
||||||
// RemovePodSandbox removes the sandbox. If there are any containers in the
|
// RemovePodSandbox removes the sandbox. If there are any containers in the
|
||||||
// sandbox, they should be forcibly removed.
|
// sandbox, they should be forcibly removed.
|
||||||
func (r *RuntimeService) RemovePodSandbox(podSandBoxID string) error {
|
func (r *RuntimeService) RemovePodSandbox(podSandBoxID string, opts ...grpc.CallOption) error {
|
||||||
klog.V(10).Infof("[RuntimeService] RemovePodSandbox (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] RemovePodSandbox (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
_, err := r.runtimeClient.RemovePodSandbox(ctx, &runtimeapi.RemovePodSandboxRequest{
|
_, err := r.runtimeClient.RemovePodSandbox(ctx, &runtimeapi.RemovePodSandboxRequest{
|
||||||
PodSandboxId: podSandBoxID,
|
PodSandboxId: podSandBoxID,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("RemovePodSandbox %q from runtime service failed: %v", podSandBoxID, err)
|
klog.Errorf("RemovePodSandbox %q from runtime service failed: %v", podSandBoxID, err)
|
||||||
return err
|
return err
|
||||||
@ -184,14 +184,14 @@ func (r *RuntimeService) RemovePodSandbox(podSandBoxID string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PodSandboxStatus returns the status of the PodSandbox.
|
// PodSandboxStatus returns the status of the PodSandbox.
|
||||||
func (r *RuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeapi.PodSandboxStatus, error) {
|
func (r *RuntimeService) PodSandboxStatus(podSandBoxID string, opts ...grpc.CallOption) (*runtimeapi.PodSandboxStatus, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] PodSandboxStatus (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] PodSandboxStatus (podSandboxID=%v, timeout=%v)", podSandBoxID, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.runtimeClient.PodSandboxStatus(ctx, &runtimeapi.PodSandboxStatusRequest{
|
resp, err := r.runtimeClient.PodSandboxStatus(ctx, &runtimeapi.PodSandboxStatusRequest{
|
||||||
PodSandboxId: podSandBoxID,
|
PodSandboxId: podSandBoxID,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -208,14 +208,14 @@ func (r *RuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeapi.PodS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListPodSandbox returns a list of PodSandboxes.
|
// ListPodSandbox returns a list of PodSandboxes.
|
||||||
func (r *RuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]*runtimeapi.PodSandbox, error) {
|
func (r *RuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter, opts ...grpc.CallOption) ([]*runtimeapi.PodSandbox, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] ListPodSandbox (filter=%v, timeout=%v)", filter, r.timeout)
|
klog.V(10).Infof("[RuntimeService] ListPodSandbox (filter=%v, timeout=%v)", filter, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.runtimeClient.ListPodSandbox(ctx, &runtimeapi.ListPodSandboxRequest{
|
resp, err := r.runtimeClient.ListPodSandbox(ctx, &runtimeapi.ListPodSandboxRequest{
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return nil, err
|
||||||
@ -227,7 +227,7 @@ func (r *RuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateContainer creates a new container in the specified PodSandbox.
|
// CreateContainer creates a new container in the specified PodSandbox.
|
||||||
func (r *RuntimeService) CreateContainer(podSandBoxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error) {
|
func (r *RuntimeService) CreateContainer(podSandBoxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig, opts ...grpc.CallOption) (string, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] CreateContainer (podSandBoxID=%v, timeout=%v)", podSandBoxID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] CreateContainer (podSandBoxID=%v, timeout=%v)", podSandBoxID, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -236,7 +236,7 @@ func (r *RuntimeService) CreateContainer(podSandBoxID string, config *runtimeapi
|
|||||||
PodSandboxId: podSandBoxID,
|
PodSandboxId: podSandBoxID,
|
||||||
Config: config,
|
Config: config,
|
||||||
SandboxConfig: sandboxConfig,
|
SandboxConfig: sandboxConfig,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return "", err
|
||||||
@ -253,14 +253,14 @@ func (r *RuntimeService) CreateContainer(podSandBoxID string, config *runtimeapi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StartContainer starts the container.
|
// StartContainer starts the container.
|
||||||
func (r *RuntimeService) StartContainer(containerID string) error {
|
func (r *RuntimeService) StartContainer(containerID string, opts ...grpc.CallOption) error {
|
||||||
klog.V(10).Infof("[RuntimeService] StartContainer (containerID=%v, timeout=%v)", containerID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] StartContainer (containerID=%v, timeout=%v)", containerID, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
_, err := r.runtimeClient.StartContainer(ctx, &runtimeapi.StartContainerRequest{
|
_, err := r.runtimeClient.StartContainer(ctx, &runtimeapi.StartContainerRequest{
|
||||||
ContainerId: containerID,
|
ContainerId: containerID,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("StartContainer %q from runtime service failed: %v", containerID, err)
|
klog.Errorf("StartContainer %q from runtime service failed: %v", containerID, err)
|
||||||
return err
|
return err
|
||||||
@ -271,7 +271,7 @@ func (r *RuntimeService) StartContainer(containerID string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StopContainer stops a running container with a grace period (i.e., timeout).
|
// StopContainer stops a running container with a grace period (i.e., timeout).
|
||||||
func (r *RuntimeService) StopContainer(containerID string, timeout int64) error {
|
func (r *RuntimeService) StopContainer(containerID string, timeout int64, opts ...grpc.CallOption) error {
|
||||||
klog.V(10).Infof("[RuntimeService] StopContainer (containerID=%v, timeout=%v)", containerID, timeout)
|
klog.V(10).Infof("[RuntimeService] StopContainer (containerID=%v, timeout=%v)", containerID, timeout)
|
||||||
// Use timeout + default timeout (2 minutes) as timeout to leave extra time
|
// Use timeout + default timeout (2 minutes) as timeout to leave extra time
|
||||||
// for SIGKILL container and request latency.
|
// for SIGKILL container and request latency.
|
||||||
@ -283,7 +283,7 @@ func (r *RuntimeService) StopContainer(containerID string, timeout int64) error
|
|||||||
_, err := r.runtimeClient.StopContainer(ctx, &runtimeapi.StopContainerRequest{
|
_, err := r.runtimeClient.StopContainer(ctx, &runtimeapi.StopContainerRequest{
|
||||||
ContainerId: containerID,
|
ContainerId: containerID,
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("StopContainer %q from runtime service failed: %v", containerID, err)
|
klog.Errorf("StopContainer %q from runtime service failed: %v", containerID, err)
|
||||||
return err
|
return err
|
||||||
@ -295,7 +295,7 @@ func (r *RuntimeService) StopContainer(containerID string, timeout int64) error
|
|||||||
|
|
||||||
// RemoveContainer removes the container. If the container is running, the container
|
// RemoveContainer removes the container. If the container is running, the container
|
||||||
// should be forced to removal.
|
// should be forced to removal.
|
||||||
func (r *RuntimeService) RemoveContainer(containerID string) error {
|
func (r *RuntimeService) RemoveContainer(containerID string, opts ...grpc.CallOption) error {
|
||||||
klog.V(10).Infof("[RuntimeService] RemoveContainer (containerID=%v, timeout=%v)", containerID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] RemoveContainer (containerID=%v, timeout=%v)", containerID, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -303,7 +303,7 @@ func (r *RuntimeService) RemoveContainer(containerID string) error {
|
|||||||
r.logReduction.ClearID(containerID)
|
r.logReduction.ClearID(containerID)
|
||||||
_, err := r.runtimeClient.RemoveContainer(ctx, &runtimeapi.RemoveContainerRequest{
|
_, err := r.runtimeClient.RemoveContainer(ctx, &runtimeapi.RemoveContainerRequest{
|
||||||
ContainerId: containerID,
|
ContainerId: containerID,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("RemoveContainer %q from runtime service failed: %v", containerID, err)
|
klog.Errorf("RemoveContainer %q from runtime service failed: %v", containerID, err)
|
||||||
return err
|
return err
|
||||||
@ -314,14 +314,14 @@ func (r *RuntimeService) RemoveContainer(containerID string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListContainers lists containers by filters.
|
// ListContainers lists containers by filters.
|
||||||
func (r *RuntimeService) ListContainers(filter *runtimeapi.ContainerFilter) ([]*runtimeapi.Container, error) {
|
func (r *RuntimeService) ListContainers(filter *runtimeapi.ContainerFilter, opts ...grpc.CallOption) ([]*runtimeapi.Container, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] ListContainers (filter=%v, timeout=%v)", filter, r.timeout)
|
klog.V(10).Infof("[RuntimeService] ListContainers (filter=%v, timeout=%v)", filter, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.runtimeClient.ListContainers(ctx, &runtimeapi.ListContainersRequest{
|
resp, err := r.runtimeClient.ListContainers(ctx, &runtimeapi.ListContainersRequest{
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return nil, err
|
||||||
@ -332,14 +332,14 @@ func (r *RuntimeService) ListContainers(filter *runtimeapi.ContainerFilter) ([]*
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ContainerStatus returns the container status.
|
// ContainerStatus returns the container status.
|
||||||
func (r *RuntimeService) ContainerStatus(containerID string) (*runtimeapi.ContainerStatus, error) {
|
func (r *RuntimeService) ContainerStatus(containerID string, opts ...grpc.CallOption) (*runtimeapi.ContainerStatus, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] ContainerStatus (containerID=%v, timeout=%v)", containerID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] ContainerStatus (containerID=%v, timeout=%v)", containerID, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.runtimeClient.ContainerStatus(ctx, &runtimeapi.ContainerStatusRequest{
|
resp, err := r.runtimeClient.ContainerStatus(ctx, &runtimeapi.ContainerStatusRequest{
|
||||||
ContainerId: containerID,
|
ContainerId: containerID,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Don't spam the log with endless messages about the same failure.
|
// Don't spam the log with endless messages about the same failure.
|
||||||
if r.logReduction.ShouldMessageBePrinted(err.Error(), containerID) {
|
if r.logReduction.ShouldMessageBePrinted(err.Error(), containerID) {
|
||||||
@ -361,7 +361,7 @@ func (r *RuntimeService) ContainerStatus(containerID string) (*runtimeapi.Contai
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateContainerResources updates a containers resource config
|
// UpdateContainerResources updates a containers resource config
|
||||||
func (r *RuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources) error {
|
func (r *RuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.LinuxContainerResources, opts ...grpc.CallOption) error {
|
||||||
klog.V(10).Infof("[RuntimeService] UpdateContainerResources (containerID=%v, timeout=%v)", containerID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] UpdateContainerResources (containerID=%v, timeout=%v)", containerID, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -369,7 +369,7 @@ func (r *RuntimeService) UpdateContainerResources(containerID string, resources
|
|||||||
_, err := r.runtimeClient.UpdateContainerResources(ctx, &runtimeapi.UpdateContainerResourcesRequest{
|
_, err := r.runtimeClient.UpdateContainerResources(ctx, &runtimeapi.UpdateContainerResourcesRequest{
|
||||||
ContainerId: containerID,
|
ContainerId: containerID,
|
||||||
Linux: resources,
|
Linux: resources,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("UpdateContainerResources %q from runtime service failed: %v", containerID, err)
|
klog.Errorf("UpdateContainerResources %q from runtime service failed: %v", containerID, err)
|
||||||
return err
|
return err
|
||||||
@ -381,7 +381,7 @@ func (r *RuntimeService) UpdateContainerResources(containerID string, resources
|
|||||||
|
|
||||||
// ExecSync executes a command in the container, and returns the stdout output.
|
// 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.
|
// If command exits with a non-zero exit code, an error is returned.
|
||||||
func (r *RuntimeService) ExecSync(containerID string, cmd []string, timeout time.Duration) (stdout []byte, stderr []byte, err error) {
|
func (r *RuntimeService) ExecSync(containerID string, cmd []string, timeout time.Duration, opts ...grpc.CallOption) (stdout []byte, stderr []byte, err error) {
|
||||||
klog.V(10).Infof("[RuntimeService] ExecSync (containerID=%v, timeout=%v)", containerID, timeout)
|
klog.V(10).Infof("[RuntimeService] ExecSync (containerID=%v, timeout=%v)", containerID, timeout)
|
||||||
// Do not set timeout when timeout is 0.
|
// Do not set timeout when timeout is 0.
|
||||||
var ctx context.Context
|
var ctx context.Context
|
||||||
@ -401,7 +401,7 @@ func (r *RuntimeService) ExecSync(containerID string, cmd []string, timeout time
|
|||||||
Cmd: cmd,
|
Cmd: cmd,
|
||||||
Timeout: timeoutSeconds,
|
Timeout: timeoutSeconds,
|
||||||
}
|
}
|
||||||
resp, err := r.runtimeClient.ExecSync(ctx, req)
|
resp, err := r.runtimeClient.ExecSync(ctx, req, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return nil, nil, err
|
||||||
@ -420,12 +420,12 @@ func (r *RuntimeService) ExecSync(containerID string, cmd []string, timeout time
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.
|
// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.
|
||||||
func (r *RuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) {
|
func (r *RuntimeService) Exec(req *runtimeapi.ExecRequest, opts ...grpc.CallOption) (*runtimeapi.ExecResponse, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] Exec (timeout=%v)", r.timeout)
|
klog.V(10).Infof("[RuntimeService] Exec (timeout=%v)", r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.runtimeClient.Exec(ctx, req)
|
resp, err := r.runtimeClient.Exec(ctx, req, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return nil, err
|
||||||
@ -442,12 +442,12 @@ func (r *RuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
|
// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
|
||||||
func (r *RuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) {
|
func (r *RuntimeService) Attach(req *runtimeapi.AttachRequest, opts ...grpc.CallOption) (*runtimeapi.AttachResponse, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] Attach (containerId=%v, timeout=%v)", req.ContainerId, r.timeout)
|
klog.V(10).Infof("[RuntimeService] Attach (containerId=%v, timeout=%v)", req.ContainerId, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.runtimeClient.Attach(ctx, req)
|
resp, err := r.runtimeClient.Attach(ctx, req, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return nil, err
|
||||||
@ -463,12 +463,12 @@ func (r *RuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.Atta
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
|
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
|
||||||
func (r *RuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
|
func (r *RuntimeService) PortForward(req *runtimeapi.PortForwardRequest, opts ...grpc.CallOption) (*runtimeapi.PortForwardResponse, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] PortForward (podSandboxID=%v, port=%v, timeout=%v)", req.PodSandboxId, req.Port, r.timeout)
|
klog.V(10).Infof("[RuntimeService] PortForward (podSandboxID=%v, port=%v, timeout=%v)", req.PodSandboxId, req.Port, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.runtimeClient.PortForward(ctx, req)
|
resp, err := r.runtimeClient.PortForward(ctx, req, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return nil, err
|
||||||
@ -487,7 +487,7 @@ func (r *RuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (*runti
|
|||||||
// UpdateRuntimeConfig updates the config of a runtime service. The only
|
// UpdateRuntimeConfig updates the config of a runtime service. The only
|
||||||
// update payload currently supported is the pod CIDR assigned to a node,
|
// update payload currently supported is the pod CIDR assigned to a node,
|
||||||
// and the runtime service just proxies it down to the network plugin.
|
// and the runtime service just proxies it down to the network plugin.
|
||||||
func (r *RuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig) error {
|
func (r *RuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig, opts ...grpc.CallOption) error {
|
||||||
klog.V(10).Infof("[RuntimeService] UpdateRuntimeConfig (runtimeConfig=%v, timeout=%v)", runtimeConfig, r.timeout)
|
klog.V(10).Infof("[RuntimeService] UpdateRuntimeConfig (runtimeConfig=%v, timeout=%v)", runtimeConfig, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -497,7 +497,7 @@ func (r *RuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeCo
|
|||||||
// really looking to surface destination unreachable.
|
// really looking to surface destination unreachable.
|
||||||
_, err := r.runtimeClient.UpdateRuntimeConfig(ctx, &runtimeapi.UpdateRuntimeConfigRequest{
|
_, err := r.runtimeClient.UpdateRuntimeConfig(ctx, &runtimeapi.UpdateRuntimeConfigRequest{
|
||||||
RuntimeConfig: runtimeConfig,
|
RuntimeConfig: runtimeConfig,
|
||||||
})
|
}, opts...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -508,12 +508,12 @@ func (r *RuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Status returns the status of the runtime.
|
// Status returns the status of the runtime.
|
||||||
func (r *RuntimeService) Status() (*runtimeapi.RuntimeStatus, error) {
|
func (r *RuntimeService) Status(opts ...grpc.CallOption) (*runtimeapi.RuntimeStatus, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] Status (timeout=%v)", r.timeout)
|
klog.V(10).Infof("[RuntimeService] Status (timeout=%v)", r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.runtimeClient.Status(ctx, &runtimeapi.StatusRequest{})
|
resp, err := r.runtimeClient.Status(ctx, &runtimeapi.StatusRequest{}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Status from runtime service failed: %v", err)
|
klog.Errorf("Status from runtime service failed: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -531,14 +531,14 @@ func (r *RuntimeService) Status() (*runtimeapi.RuntimeStatus, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ContainerStats returns the stats of the container.
|
// ContainerStats returns the stats of the container.
|
||||||
func (r *RuntimeService) ContainerStats(containerID string) (*runtimeapi.ContainerStats, error) {
|
func (r *RuntimeService) ContainerStats(containerID string, opts ...grpc.CallOption) (*runtimeapi.ContainerStats, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] ContainerStats (containerID=%v, timeout=%v)", containerID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] ContainerStats (containerID=%v, timeout=%v)", containerID, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
resp, err := r.runtimeClient.ContainerStats(ctx, &runtimeapi.ContainerStatsRequest{
|
resp, err := r.runtimeClient.ContainerStats(ctx, &runtimeapi.ContainerStatsRequest{
|
||||||
ContainerId: containerID,
|
ContainerId: containerID,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if r.logReduction.ShouldMessageBePrinted(err.Error(), containerID) {
|
if r.logReduction.ShouldMessageBePrinted(err.Error(), containerID) {
|
||||||
klog.Errorf("ContainerStats %q from runtime service failed: %v", containerID, err)
|
klog.Errorf("ContainerStats %q from runtime service failed: %v", containerID, err)
|
||||||
@ -552,7 +552,7 @@ func (r *RuntimeService) ContainerStats(containerID string) (*runtimeapi.Contain
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListContainerStats lists all container stats given the provided filter
|
// ListContainerStats lists all container stats given the provided filter
|
||||||
func (r *RuntimeService) ListContainerStats(filter *runtimeapi.ContainerStatsFilter) ([]*runtimeapi.ContainerStats, error) {
|
func (r *RuntimeService) ListContainerStats(filter *runtimeapi.ContainerStatsFilter, opts ...grpc.CallOption) ([]*runtimeapi.ContainerStats, error) {
|
||||||
klog.V(10).Infof("[RuntimeService] ListContainerStats (filter=%v)", filter)
|
klog.V(10).Infof("[RuntimeService] ListContainerStats (filter=%v)", filter)
|
||||||
// Do not set timeout, because writable layer stats collection takes time.
|
// 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?
|
// TODO(random-liu): Should we assume runtime should cache the result, and set timeout here?
|
||||||
@ -561,7 +561,7 @@ func (r *RuntimeService) ListContainerStats(filter *runtimeapi.ContainerStatsFil
|
|||||||
|
|
||||||
resp, err := r.runtimeClient.ListContainerStats(ctx, &runtimeapi.ListContainerStatsRequest{
|
resp, err := r.runtimeClient.ListContainerStats(ctx, &runtimeapi.ListContainerStatsRequest{
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
})
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.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
|
return nil, err
|
||||||
@ -572,12 +572,14 @@ func (r *RuntimeService) ListContainerStats(filter *runtimeapi.ContainerStatsFil
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReopenContainerLog reopens the container log for the given container ID
|
// ReopenContainerLog reopens the container log for the given container ID
|
||||||
func (r *RuntimeService) ReopenContainerLog(containerID string) error {
|
func (r *RuntimeService) ReopenContainerLog(containerID string, opts ...grpc.CallOption) error {
|
||||||
klog.V(10).Infof("[RuntimeService] ReopenContainerLog (containerID=%v, timeout=%v)", containerID, r.timeout)
|
klog.V(10).Infof("[RuntimeService] ReopenContainerLog (containerID=%v, timeout=%v)", containerID, r.timeout)
|
||||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
_, err := r.runtimeClient.ReopenContainerLog(ctx, &runtimeapi.ReopenContainerLogRequest{ContainerId: containerID})
|
_, err := r.runtimeClient.ReopenContainerLog(ctx, &runtimeapi.ReopenContainerLogRequest{
|
||||||
|
ContainerId: containerID,
|
||||||
|
}, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("ReopenContainerLog %q from runtime service failed: %v", containerID, err)
|
klog.Errorf("ReopenContainerLog %q from runtime service failed: %v", containerID, err)
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user