Commit ee35555c authored by k8s-merge-robot's avatar k8s-merge-robot Committed by GitHub

Merge pull request #27570 from Random-Liu/add-runtime-request-timeout-flag

Automatic merge from submit-queue Add runtime-request-timeout kubelet flag. XRef #23563. Addresses https://github.com/kubernetes/kubernetes/issues/27388#issuecomment-226570083. Add a new kubelet flag `runtime-request-timeout`, and set to 2 minutes by default. Now the flag only affects dockertools, rkt may also want to set request timeout according to the flag. @yifan-gu This PR also removed the timeout for all long running operations to avoid issues like #27588 and #26122. @yujuhong @rrati /cc @kubernetes/sig-node [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
parents 27c0d8cf ca942795
...@@ -85,6 +85,7 @@ func NewKubeletServer() *KubeletServer { ...@@ -85,6 +85,7 @@ func NewKubeletServer() *KubeletServer {
CgroupRoot: "", CgroupRoot: "",
ConfigureCBR0: false, ConfigureCBR0: false,
ContainerRuntime: "docker", ContainerRuntime: "docker",
RuntimeRequestTimeout: unversioned.Duration{Duration: 2 * time.Minute},
CPUCFSQuota: true, CPUCFSQuota: true,
DockerExecHandlerName: "native", DockerExecHandlerName: "native",
EventBurst: 10, EventBurst: 10,
...@@ -227,6 +228,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) { ...@@ -227,6 +228,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&s.CgroupRoot, "cgroup-root", s.CgroupRoot, "Optional root cgroup to use for pods. This is handled by the container runtime on a best effort basis. Default: '', which means use the container runtime default.") fs.StringVar(&s.CgroupRoot, "cgroup-root", s.CgroupRoot, "Optional root cgroup to use for pods. This is handled by the container runtime on a best effort basis. Default: '', which means use the container runtime default.")
fs.StringVar(&s.ContainerRuntime, "container-runtime", s.ContainerRuntime, "The container runtime to use. Possible values: 'docker', 'rkt'. Default: 'docker'.") fs.StringVar(&s.ContainerRuntime, "container-runtime", s.ContainerRuntime, "The container runtime to use. Possible values: 'docker', 'rkt'. Default: 'docker'.")
fs.DurationVar(&s.RuntimeRequestTimeout.Duration, "runtime-request-timeout", s.RuntimeRequestTimeout.Duration, "Timeout of all runtime requests except long running request - pull, logs, exec and attach. When timeout exceeded, kubelet will cancel the request, throw out an error and retry later. Default: 2m0s")
fs.StringVar(&s.LockFilePath, "lock-file", s.LockFilePath, "<Warning: Alpha feature> The path to file for kubelet to use as a lock file.") fs.StringVar(&s.LockFilePath, "lock-file", s.LockFilePath, "<Warning: Alpha feature> The path to file for kubelet to use as a lock file.")
fs.BoolVar(&s.ExitOnLockContention, "exit-on-lock-contention", s.ExitOnLockContention, "Whether kubelet should exit upon lock-file contention.") fs.BoolVar(&s.ExitOnLockContention, "exit-on-lock-contention", s.ExitOnLockContention, "Whether kubelet should exit upon lock-file contention.")
fs.StringVar(&s.RktPath, "rkt-path", s.RktPath, "Path of rkt binary. Leave empty to use the first rkt in $PATH. Only used if --container-runtime='rkt'.") fs.StringVar(&s.RktPath, "rkt-path", s.RktPath, "Path of rkt binary. Leave empty to use the first rkt in $PATH. Only used if --container-runtime='rkt'.")
......
...@@ -210,9 +210,10 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) { ...@@ -210,9 +210,10 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
ConfigureCBR0: s.ConfigureCBR0, ConfigureCBR0: s.ConfigureCBR0,
ContainerManager: nil, ContainerManager: nil,
ContainerRuntime: s.ContainerRuntime, ContainerRuntime: s.ContainerRuntime,
RuntimeRequestTimeout: s.RuntimeRequestTimeout.Duration,
CPUCFSQuota: s.CPUCFSQuota, CPUCFSQuota: s.CPUCFSQuota,
DiskSpacePolicy: diskSpacePolicy, DiskSpacePolicy: diskSpacePolicy,
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint), DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint, s.RuntimeRequestTimeout.Duration), // TODO(random-liu): Set RuntimeRequestTimeout for rkt.
RuntimeCgroups: s.RuntimeCgroups, RuntimeCgroups: s.RuntimeCgroups,
DockerExecHandler: dockerExecHandler, DockerExecHandler: dockerExecHandler,
EnableControllerAttachDetach: s.EnableControllerAttachDetach, EnableControllerAttachDetach: s.EnableControllerAttachDetach,
...@@ -783,6 +784,7 @@ type KubeletConfig struct { ...@@ -783,6 +784,7 @@ type KubeletConfig struct {
ConfigureCBR0 bool ConfigureCBR0 bool
ContainerManager cm.ContainerManager ContainerManager cm.ContainerManager
ContainerRuntime string ContainerRuntime string
RuntimeRequestTimeout time.Duration
CPUCFSQuota bool CPUCFSQuota bool
DiskSpacePolicy kubelet.DiskSpacePolicy DiskSpacePolicy kubelet.DiskSpacePolicy
DockerClient dockertools.DockerInterface DockerClient dockertools.DockerInterface
...@@ -923,6 +925,7 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod ...@@ -923,6 +925,7 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
kc.OSInterface, kc.OSInterface,
kc.CgroupRoot, kc.CgroupRoot,
kc.ContainerRuntime, kc.ContainerRuntime,
kc.RuntimeRequestTimeout,
kc.RktPath, kc.RktPath,
kc.RktAPIEndpoint, kc.RktAPIEndpoint,
kc.RktStage1Image, kc.RktStage1Image,
......
...@@ -184,7 +184,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) { ...@@ -184,7 +184,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) {
mockDriver = &MockExecutorDriver{} mockDriver = &MockExecutorDriver{}
registry = newFakeRegistry() registry = newFakeRegistry()
executor = New(Config{ executor = New(Config{
Docker: dockertools.ConnectToDockerOrDie("fake://"), Docker: dockertools.ConnectToDockerOrDie("fake://", 0),
NodeInfos: make(chan NodeInfo, 1), NodeInfos: make(chan NodeInfo, 1),
Registry: registry, Registry: registry,
}) })
...@@ -387,7 +387,7 @@ func TestExecutorFrameworkMessage(t *testing.T) { ...@@ -387,7 +387,7 @@ func TestExecutorFrameworkMessage(t *testing.T) {
kubeletFinished = make(chan struct{}) kubeletFinished = make(chan struct{})
registry = newFakeRegistry() registry = newFakeRegistry()
executor = New(Config{ executor = New(Config{
Docker: dockertools.ConnectToDockerOrDie("fake://"), Docker: dockertools.ConnectToDockerOrDie("fake://", 0),
NodeInfos: make(chan NodeInfo, 1), NodeInfos: make(chan NodeInfo, 1),
ShutdownAlert: func() { ShutdownAlert: func() {
close(kubeletFinished) close(kubeletFinished)
...@@ -584,7 +584,7 @@ func TestExecutorShutdown(t *testing.T) { ...@@ -584,7 +584,7 @@ func TestExecutorShutdown(t *testing.T) {
kubeletFinished = make(chan struct{}) kubeletFinished = make(chan struct{})
exitCalled = int32(0) exitCalled = int32(0)
executor = New(Config{ executor = New(Config{
Docker: dockertools.ConnectToDockerOrDie("fake://"), Docker: dockertools.ConnectToDockerOrDie("fake://", 0),
NodeInfos: make(chan NodeInfo, 1), NodeInfos: make(chan NodeInfo, 1),
ShutdownAlert: func() { ShutdownAlert: func() {
close(kubeletFinished) close(kubeletFinished)
......
...@@ -75,7 +75,7 @@ func (m *MockExecutorDriver) SendFrameworkMessage(msg string) (mesosproto.Status ...@@ -75,7 +75,7 @@ func (m *MockExecutorDriver) SendFrameworkMessage(msg string) (mesosproto.Status
func NewTestKubernetesExecutor() *Executor { func NewTestKubernetesExecutor() *Executor {
return New(Config{ return New(Config{
Docker: dockertools.ConnectToDockerOrDie("fake://"), Docker: dockertools.ConnectToDockerOrDie("fake://", 0),
Registry: newFakeRegistry(), Registry: newFakeRegistry(),
}) })
} }
......
...@@ -107,7 +107,7 @@ func (s *KubeletExecutorServer) runExecutor( ...@@ -107,7 +107,7 @@ func (s *KubeletExecutorServer) runExecutor(
exec := executor.New(executor.Config{ exec := executor.New(executor.Config{
Registry: registry, Registry: registry,
APIClient: apiclient, APIClient: apiclient,
Docker: dockertools.ConnectToDockerOrDie(s.DockerEndpoint), Docker: dockertools.ConnectToDockerOrDie(s.DockerEndpoint, 0),
SuicideTimeout: s.SuicideTimeout, SuicideTimeout: s.SuicideTimeout,
KubeletFinished: kubeletFinished, KubeletFinished: kubeletFinished,
ExitFunc: os.Exit, ExitFunc: os.Exit,
......
...@@ -399,6 +399,7 @@ root-dir ...@@ -399,6 +399,7 @@ root-dir
run-proxy run-proxy
runtime-cgroups runtime-cgroups
runtime-config runtime-config
runtime-request-timeout
save-config save-config
scheduler-config scheduler-config
scheduler-name scheduler-name
......
...@@ -273,6 +273,9 @@ func DeepCopy_componentconfig_KubeletConfiguration(in KubeletConfiguration, out ...@@ -273,6 +273,9 @@ func DeepCopy_componentconfig_KubeletConfiguration(in KubeletConfiguration, out
out.SystemCgroups = in.SystemCgroups out.SystemCgroups = in.SystemCgroups
out.CgroupRoot = in.CgroupRoot out.CgroupRoot = in.CgroupRoot
out.ContainerRuntime = in.ContainerRuntime out.ContainerRuntime = in.ContainerRuntime
if err := unversioned.DeepCopy_unversioned_Duration(in.RuntimeRequestTimeout, &out.RuntimeRequestTimeout, c); err != nil {
return err
}
out.RktPath = in.RktPath out.RktPath = in.RktPath
out.RktAPIEndpoint = in.RktAPIEndpoint out.RktAPIEndpoint = in.RktAPIEndpoint
out.RktStage1Image = in.RktStage1Image out.RktStage1Image = in.RktStage1Image
......
...@@ -263,6 +263,9 @@ type KubeletConfiguration struct { ...@@ -263,6 +263,9 @@ type KubeletConfiguration struct {
CgroupRoot string `json:"cgroupRoot,omitempty"` CgroupRoot string `json:"cgroupRoot,omitempty"`
// containerRuntime is the container runtime to use. // containerRuntime is the container runtime to use.
ContainerRuntime string `json:"containerRuntime"` ContainerRuntime string `json:"containerRuntime"`
// runtimeRequestTimeout is the timeout for all runtime requests except long running
// requests - pull, logs, exec and attach.
RuntimeRequestTimeout unversioned.Duration `json:"runtimeRequestTimeout,omitempty"`
// rktPath is the path of rkt binary. Leave empty to use the first rkt in // rktPath is the path of rkt binary. Leave empty to use the first rkt in
// $PATH. // $PATH.
RktPath string `json:"rktPath,omitempty"` RktPath string `json:"rktPath,omitempty"`
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"path" "path"
"strconv" "strconv"
"strings" "strings"
"time"
dockerref "github.com/docker/distribution/reference" dockerref "github.com/docker/distribution/reference"
"github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/jsonmessage"
...@@ -311,8 +312,11 @@ func getDockerClient(dockerEndpoint string) (*dockerapi.Client, error) { ...@@ -311,8 +312,11 @@ func getDockerClient(dockerEndpoint string) (*dockerapi.Client, error) {
// ConnectToDockerOrDie creates docker client connecting to docker daemon. // ConnectToDockerOrDie creates docker client connecting to docker daemon.
// If the endpoint passed in is "fake://", a fake docker client // If the endpoint passed in is "fake://", a fake docker client
// will be returned. The program exits if error occurs. // will be returned. The program exits if error occurs. The requestTimeout
func ConnectToDockerOrDie(dockerEndpoint string) DockerInterface { // is the timeout for docker requests. If timeout is exceeded, the request
// will be cancelled and throw out an error. If requestTimeout is 0, a default
// value will be applied.
func ConnectToDockerOrDie(dockerEndpoint string, requestTimeout time.Duration) DockerInterface {
if dockerEndpoint == "fake://" { if dockerEndpoint == "fake://" {
return NewFakeDockerClient() return NewFakeDockerClient()
} }
...@@ -320,7 +324,8 @@ func ConnectToDockerOrDie(dockerEndpoint string) DockerInterface { ...@@ -320,7 +324,8 @@ func ConnectToDockerOrDie(dockerEndpoint string) DockerInterface {
if err != nil { if err != nil {
glog.Fatalf("Couldn't connect to docker: %v", err) glog.Fatalf("Couldn't connect to docker: %v", err)
} }
return newKubeDockerClient(client) glog.Infof("Start docker client with request timeout=%v", requestTimeout)
return newKubeDockerClient(client, requestTimeout)
} }
// milliCPUToQuota converts milliCPU to CFS quota and period values // milliCPUToQuota converts milliCPU to CFS quota and period values
......
...@@ -206,6 +206,7 @@ func NewMainKubelet( ...@@ -206,6 +206,7 @@ func NewMainKubelet(
osInterface kubecontainer.OSInterface, osInterface kubecontainer.OSInterface,
cgroupRoot string, cgroupRoot string,
containerRuntime string, containerRuntime string,
runtimeRequestTimeout time.Duration,
rktPath string, rktPath string,
rktAPIEndpoint string, rktAPIEndpoint string,
rktStage1Image string, rktStage1Image string,
...@@ -451,6 +452,7 @@ func NewMainKubelet( ...@@ -451,6 +452,7 @@ func NewMainKubelet(
kubecontainer.RealOS{}, kubecontainer.RealOS{},
imageBackOff, imageBackOff,
serializeImagePulls, serializeImagePulls,
runtimeRequestTimeout,
) )
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -79,7 +79,9 @@ func (c *Config) buildGlobalOptions() []string { ...@@ -79,7 +79,9 @@ func (c *Config) buildGlobalOptions() []string {
// that the fields in the provided config will override the // that the fields in the provided config will override the
// result that get from the rkt api service. // result that get from the rkt api service.
func (r *Runtime) getConfig(cfg *Config) (*Config, error) { func (r *Runtime) getConfig(cfg *Config) (*Config, error) {
resp, err := r.apisvc.GetInfo(context.Background(), &rktapi.GetInfoRequest{}) ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
resp, err := r.apisvc.GetInfo(ctx, &rktapi.GetInfoRequest{})
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -90,7 +90,9 @@ func (r *Runtime) IsImagePresent(image kubecontainer.ImageSpec) (bool, error) { ...@@ -90,7 +90,9 @@ func (r *Runtime) IsImagePresent(image kubecontainer.ImageSpec) (bool, error) {
// ListImages lists all the available appc images on the machine by invoking 'rkt image list'. // ListImages lists all the available appc images on the machine by invoking 'rkt image list'.
func (r *Runtime) ListImages() ([]kubecontainer.Image, error) { func (r *Runtime) ListImages() ([]kubecontainer.Image, error) {
listResp, err := r.apisvc.ListImages(context.Background(), &rktapi.ListImagesRequest{}) ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
listResp, err := r.apisvc.ListImages(ctx, &rktapi.ListImagesRequest{})
if err != nil { if err != nil {
return nil, fmt.Errorf("couldn't list images: %v", err) return nil, fmt.Errorf("couldn't list images: %v", err)
} }
...@@ -155,7 +157,9 @@ func (r *Runtime) listImages(image string, detail bool) ([]*rktapi.Image, error) ...@@ -155,7 +157,9 @@ func (r *Runtime) listImages(image string, detail bool) ([]*rktapi.Image, error)
return nil, err return nil, err
} }
listResp, err := r.apisvc.ListImages(context.Background(), &rktapi.ListImagesRequest{ ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
listResp, err := r.apisvc.ListImages(ctx, &rktapi.ListImagesRequest{
Detail: detail, Detail: detail,
Filters: []*rktapi.ImageFilter{ Filters: []*rktapi.ImageFilter{
{ {
...@@ -231,7 +235,9 @@ func (r *Runtime) writeDockerAuthConfig(image string, credsSlice []credentialpro ...@@ -231,7 +235,9 @@ func (r *Runtime) writeDockerAuthConfig(image string, credsSlice []credentialpro
// ImageStats returns the image stat (total storage bytes). // ImageStats returns the image stat (total storage bytes).
func (r *Runtime) ImageStats() (*kubecontainer.ImageStats, error) { func (r *Runtime) ImageStats() (*kubecontainer.ImageStats, error) {
var imageStat kubecontainer.ImageStats var imageStat kubecontainer.ImageStats
listResp, err := r.apisvc.ListImages(context.Background(), &rktapi.ListImagesRequest{}) ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
listResp, err := r.apisvc.ListImages(ctx, &rktapi.ListImagesRequest{})
if err != nil { if err != nil {
return nil, fmt.Errorf("couldn't list images: %v", err) return nil, fmt.Errorf("couldn't list images: %v", err)
} }
......
...@@ -128,6 +128,9 @@ const ( ...@@ -128,6 +128,9 @@ const (
// under the CNI directory directly. // under the CNI directory directly.
// See https://github.com/coreos/rkt/pull/2312#issuecomment-200068370. // See https://github.com/coreos/rkt/pull/2312#issuecomment-200068370.
defaultNetworkName = "rkt.kubernetes.io" defaultNetworkName = "rkt.kubernetes.io"
// defaultRequestTimeout is the default timeout of rkt requests.
defaultRequestTimeout = 2 * time.Minute
) )
// Runtime implements the Containerruntime for rkt. The implementation // Runtime implements the Containerruntime for rkt. The implementation
...@@ -166,6 +169,9 @@ type Runtime struct { ...@@ -166,6 +169,9 @@ type Runtime struct {
nsenterPath string nsenterPath string
versions versions versions versions
// requestTimeout is the timeout of rkt requests.
requestTimeout time.Duration
} }
var _ kubecontainer.Runtime = &Runtime{} var _ kubecontainer.Runtime = &Runtime{}
...@@ -200,6 +206,7 @@ func New( ...@@ -200,6 +206,7 @@ func New(
os kubecontainer.OSInterface, os kubecontainer.OSInterface,
imageBackOff *flowcontrol.Backoff, imageBackOff *flowcontrol.Backoff,
serializeImagePulls bool, serializeImagePulls bool,
requestTimeout time.Duration,
) (*Runtime, error) { ) (*Runtime, error) {
// Create dbus connection. // Create dbus connection.
systemd, err := newSystemd() systemd, err := newSystemd()
...@@ -233,6 +240,10 @@ func New( ...@@ -233,6 +240,10 @@ func New(
return nil, fmt.Errorf("cannot find nsenter binary: %v", err) return nil, fmt.Errorf("cannot find nsenter binary: %v", err)
} }
if requestTimeout == 0 {
requestTimeout = defaultRequestTimeout
}
rkt := &Runtime{ rkt := &Runtime{
os: kubecontainer.RealOS{}, os: kubecontainer.RealOS{},
systemd: systemd, systemd: systemd,
...@@ -249,6 +260,7 @@ func New( ...@@ -249,6 +260,7 @@ func New(
execer: execer, execer: execer,
touchPath: touchPath, touchPath: touchPath,
nsenterPath: nsenterPath, nsenterPath: nsenterPath,
requestTimeout: requestTimeout,
} }
rkt.config, err = rkt.getConfig(rkt.config) rkt.config, err = rkt.getConfig(rkt.config)
...@@ -585,7 +597,9 @@ func setApp(imgManifest *appcschema.ImageManifest, c *api.Container, opts *kubec ...@@ -585,7 +597,9 @@ func setApp(imgManifest *appcschema.ImageManifest, c *api.Container, opts *kubec
func (r *Runtime) makePodManifest(pod *api.Pod, podIP string, pullSecrets []api.Secret) (*appcschema.PodManifest, error) { func (r *Runtime) makePodManifest(pod *api.Pod, podIP string, pullSecrets []api.Secret) (*appcschema.PodManifest, error) {
manifest := appcschema.BlankPodManifest() manifest := appcschema.BlankPodManifest()
listResp, err := r.apisvc.ListPods(context.Background(), &rktapi.ListPodsRequest{ ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
listResp, err := r.apisvc.ListPods(ctx, &rktapi.ListPodsRequest{
Detail: true, Detail: true,
Filters: kubernetesPodFilters(pod.UID), Filters: kubernetesPodFilters(pod.UID),
}) })
...@@ -1349,7 +1363,9 @@ func (r *Runtime) runPostStartHook(containerID kubecontainer.ContainerID, pod *a ...@@ -1349,7 +1363,9 @@ func (r *Runtime) runPostStartHook(containerID kubecontainer.ContainerID, pod *a
} }
isContainerRunning := func() (done bool, err error) { isContainerRunning := func() (done bool, err error) {
resp, err := r.apisvc.InspectPod(context.Background(), &rktapi.InspectPodRequest{Id: cid.uuid}) ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
resp, err := r.apisvc.InspectPod(ctx, &rktapi.InspectPodRequest{Id: cid.uuid})
if err != nil { if err != nil {
return false, fmt.Errorf("failed to inspect rkt pod %q for pod %q", cid.uuid, format.Pod(pod)) return false, fmt.Errorf("failed to inspect rkt pod %q for pod %q", cid.uuid, format.Pod(pod))
} }
...@@ -1520,7 +1536,9 @@ func (r *Runtime) GetPods(all bool) ([]*kubecontainer.Pod, error) { ...@@ -1520,7 +1536,9 @@ func (r *Runtime) GetPods(all bool) ([]*kubecontainer.Pod, error) {
if !all { if !all {
listReq.Filters[0].States = []rktapi.PodState{rktapi.PodState_POD_STATE_RUNNING} listReq.Filters[0].States = []rktapi.PodState{rktapi.PodState_POD_STATE_RUNNING}
} }
listResp, err := r.apisvc.ListPods(context.Background(), listReq) ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
listResp, err := r.apisvc.ListPods(ctx, listReq)
if err != nil { if err != nil {
return nil, fmt.Errorf("couldn't list pods: %v", err) return nil, fmt.Errorf("couldn't list pods: %v", err)
} }
...@@ -1829,7 +1847,9 @@ func (r *Runtime) GarbageCollect(gcPolicy kubecontainer.ContainerGCPolicy, allSo ...@@ -1829,7 +1847,9 @@ func (r *Runtime) GarbageCollect(gcPolicy kubecontainer.ContainerGCPolicy, allSo
return err return err
} }
resp, err := r.apisvc.ListPods(context.Background(), &rktapi.ListPodsRequest{Filters: kubernetesPodsFilters()}) ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
resp, err := r.apisvc.ListPods(ctx, &rktapi.ListPodsRequest{Filters: kubernetesPodsFilters()})
if err != nil { if err != nil {
glog.Errorf("rkt: Failed to list pods: %v", err) glog.Errorf("rkt: Failed to list pods: %v", err)
return err return err
...@@ -2047,7 +2067,9 @@ func (r *Runtime) ExecInContainer(containerID kubecontainer.ContainerID, cmd []s ...@@ -2047,7 +2067,9 @@ func (r *Runtime) ExecInContainer(containerID kubecontainer.ContainerID, cmd []s
func (r *Runtime) PortForward(pod *kubecontainer.Pod, port uint16, stream io.ReadWriteCloser) error { func (r *Runtime) PortForward(pod *kubecontainer.Pod, port uint16, stream io.ReadWriteCloser) error {
glog.V(4).Infof("Rkt port forwarding in container.") glog.V(4).Infof("Rkt port forwarding in container.")
listResp, err := r.apisvc.ListPods(context.Background(), &rktapi.ListPodsRequest{ ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
listResp, err := r.apisvc.ListPods(ctx, &rktapi.ListPodsRequest{
Detail: true, Detail: true,
Filters: runningKubernetesPodFilters(pod.ID), Filters: runningKubernetesPodFilters(pod.ID),
}) })
...@@ -2197,7 +2219,9 @@ func (r *Runtime) GetPodStatus(uid kubetypes.UID, name, namespace string) (*kube ...@@ -2197,7 +2219,9 @@ func (r *Runtime) GetPodStatus(uid kubetypes.UID, name, namespace string) (*kube
Namespace: namespace, Namespace: namespace,
} }
listResp, err := r.apisvc.ListPods(context.Background(), &rktapi.ListPodsRequest{ ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
listResp, err := r.apisvc.ListPods(ctx, &rktapi.ListPodsRequest{
Detail: true, Detail: true,
Filters: kubernetesPodFilters(uid), Filters: kubernetesPodFilters(uid),
}) })
......
...@@ -73,9 +73,11 @@ func (r *Runtime) getVersions() error { ...@@ -73,9 +73,11 @@ func (r *Runtime) getVersions() error {
return err return err
} }
ctx, cancel := context.WithTimeout(context.Background(), r.requestTimeout)
defer cancel()
// Example for the version strings returned by GetInfo(): // Example for the version strings returned by GetInfo():
// RktVersion:"0.10.0+gitb7349b1" AppcVersion:"0.7.1" ApiVersion:"1.0.0-alpha" // RktVersion:"0.10.0+gitb7349b1" AppcVersion:"0.7.1" ApiVersion:"1.0.0-alpha"
resp, err := r.apisvc.GetInfo(context.Background(), &rktapi.GetInfoRequest{}) resp, err := r.apisvc.GetInfo(ctx, &rktapi.GetInfoRequest{})
if err != nil { if err != nil {
return err return err
} }
......
...@@ -40,7 +40,7 @@ func NewConformanceImage(containerRuntime string, image string) (ci ConformanceI ...@@ -40,7 +40,7 @@ func NewConformanceImage(containerRuntime string, image string) (ci ConformanceI
//TODO: do not expose kubelet implementation details after we refactor the runtime API. //TODO: do not expose kubelet implementation details after we refactor the runtime API.
func dockerRuntime() kubecontainer.Runtime { func dockerRuntime() kubecontainer.Runtime {
dockerClient := dockertools.ConnectToDockerOrDie("") dockerClient := dockertools.ConnectToDockerOrDie("", 0)
pm := kubepod.NewBasicPodManager(nil) pm := kubepod.NewBasicPodManager(nil)
dm := dockertools.NewDockerManager( dm := dockertools.NewDockerManager(
dockerClient, dockerClient,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment