Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
bf2ced83
Commit
bf2ced83
authored
Jun 29, 2017
by
Yang Guo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates Docker Engine API
parent
f818cbea
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
138 additions
and
141 deletions
+138
-141
BUILD
pkg/credentialprovider/BUILD
+2
-2
keyring.go
pkg/credentialprovider/keyring.go
+1
-1
keyring_test.go
pkg/credentialprovider/keyring_test.go
+1
-1
provider.go
pkg/credentialprovider/provider.go
+1
-1
BUILD
pkg/kubelet/dockershim/BUILD
+6
-6
convert.go
pkg/kubelet/dockershim/convert.go
+2
-2
convert_test.go
pkg/kubelet/dockershim/convert_test.go
+1
-1
docker_container.go
pkg/kubelet/dockershim/docker_container.go
+7
-7
docker_container_test.go
pkg/kubelet/dockershim/docker_container_test.go
+2
-2
docker_image.go
pkg/kubelet/dockershim/docker_image.go
+2
-2
docker_image_test.go
pkg/kubelet/dockershim/docker_image_test.go
+1
-1
docker_legacy.go
pkg/kubelet/dockershim/docker_legacy.go
+6
-6
docker_legacy_test.go
pkg/kubelet/dockershim/docker_legacy_test.go
+1
-1
docker_sandbox.go
pkg/kubelet/dockershim/docker_sandbox.go
+13
-10
docker_service.go
pkg/kubelet/dockershim/docker_service.go
+1
-1
docker_service_test.go
pkg/kubelet/dockershim/docker_service_test.go
+1
-1
docker_streaming.go
pkg/kubelet/dockershim/docker_streaming.go
+2
-2
exec.go
pkg/kubelet/dockershim/exec.go
+2
-2
helpers.go
pkg/kubelet/dockershim/helpers.go
+6
-5
helpers_linux.go
pkg/kubelet/dockershim/helpers_linux.go
+2
-2
helpers_test.go
pkg/kubelet/dockershim/helpers_test.go
+3
-3
helpers_unsupported.go
pkg/kubelet/dockershim/helpers_unsupported.go
+1
-1
helpers_windows.go
pkg/kubelet/dockershim/helpers_windows.go
+3
-3
BUILD
pkg/kubelet/dockershim/libdocker/BUILD
+4
-4
client.go
pkg/kubelet/dockershim/libdocker/client.go
+9
-8
fake_client.go
pkg/kubelet/dockershim/libdocker/fake_client.go
+23
-23
helpers.go
pkg/kubelet/dockershim/libdocker/helpers.go
+1
-1
helpers_test.go
pkg/kubelet/dockershim/libdocker/helpers_test.go
+1
-1
instrumented_client.go
pkg/kubelet/dockershim/libdocker/instrumented_client.go
+8
-7
kube_docker_client.go
pkg/kubelet/dockershim/libdocker/kube_docker_client.go
+14
-23
legacy_test.go
pkg/kubelet/dockershim/libdocker/legacy_test.go
+1
-1
security_context.go
pkg/kubelet/dockershim/security_context.go
+1
-1
security_context_test.go
pkg/kubelet/dockershim/security_context_test.go
+1
-1
BUILD
pkg/kubelet/rkt/BUILD
+1
-1
image.go
pkg/kubelet/rkt/image.go
+1
-1
BUILD
test/e2e_node/system/BUILD
+3
-3
docker_validator.go
test/e2e_node/system/docker_validator.go
+2
-2
docker_validator_test.go
test/e2e_node/system/docker_validator_test.go
+1
-1
No files found.
pkg/credentialprovider/BUILD
View file @
bf2ced83
...
@@ -19,7 +19,7 @@ go_library(
...
@@ -19,7 +19,7 @@ go_library(
],
],
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//vendor/github.com/docker/
engine-
api/types:go_default_library",
"//vendor/github.com/docker/
docker/
api/types:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
...
@@ -35,7 +35,7 @@ go_test(
...
@@ -35,7 +35,7 @@ go_test(
],
],
library = ":go_default_library",
library = ":go_default_library",
tags = ["automanaged"],
tags = ["automanaged"],
deps = ["//vendor/github.com/docker/
engine-
api/types:go_default_library"],
deps = ["//vendor/github.com/docker/
docker/
api/types:go_default_library"],
)
)
filegroup(
filegroup(
...
...
pkg/credentialprovider/keyring.go
View file @
bf2ced83
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
)
)
...
...
pkg/credentialprovider/keyring_test.go
View file @
bf2ced83
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"reflect"
"reflect"
"testing"
"testing"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
)
)
func
TestUrlsMatch
(
t
*
testing
.
T
)
{
func
TestUrlsMatch
(
t
*
testing
.
T
)
{
...
...
pkg/credentialprovider/provider.go
View file @
bf2ced83
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"sync"
"sync"
"time"
"time"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
...
pkg/kubelet/dockershim/BUILD
View file @
bf2ced83
...
@@ -55,11 +55,11 @@ go_library(
...
@@ -55,11 +55,11 @@ go_library(
"//pkg/util/hash:go_default_library",
"//pkg/util/hash:go_default_library",
"//pkg/util/term:go_default_library",
"//pkg/util/term:go_default_library",
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/github.com/docker/docker/api/types:go_default_library",
"//vendor/github.com/docker/docker/api/types/container:go_default_library",
"//vendor/github.com/docker/docker/api/types/filters:go_default_library",
"//vendor/github.com/docker/docker/api/types/strslice:go_default_library",
"//vendor/github.com/docker/docker/pkg/jsonmessage:go_default_library",
"//vendor/github.com/docker/docker/pkg/jsonmessage:go_default_library",
"//vendor/github.com/docker/engine-api/types:go_default_library",
"//vendor/github.com/docker/engine-api/types/container:go_default_library",
"//vendor/github.com/docker/engine-api/types/filters:go_default_library",
"//vendor/github.com/docker/engine-api/types/strslice:go_default_library",
"//vendor/github.com/docker/go-connections/nat:go_default_library",
"//vendor/github.com/docker/go-connections/nat:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
...
@@ -107,9 +107,9 @@ go_test(
...
@@ -107,9 +107,9 @@ go_test(
"//pkg/kubelet/util/cache:go_default_library",
"//pkg/kubelet/util/cache:go_default_library",
"//pkg/security/apparmor:go_default_library",
"//pkg/security/apparmor:go_default_library",
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/github.com/docker/docker/api/types:go_default_library",
"//vendor/github.com/docker/docker/api/types/container:go_default_library",
"//vendor/github.com/docker/docker/pkg/jsonmessage:go_default_library",
"//vendor/github.com/docker/docker/pkg/jsonmessage:go_default_library",
"//vendor/github.com/docker/engine-api/types:go_default_library",
"//vendor/github.com/docker/engine-api/types/container:go_default_library",
"//vendor/github.com/docker/go-connections/nat:go_default_library",
"//vendor/github.com/docker/go-connections/nat:go_default_library",
"//vendor/github.com/golang/mock/gomock:go_default_library",
"//vendor/github.com/golang/mock/gomock:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
...
...
pkg/kubelet/dockershim/convert.go
View file @
bf2ced83
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"strings"
"strings"
"time"
"time"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
"k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker"
"k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker"
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
// This file contains helper functions to convert docker API types to runtime
// This file contains helper functions to convert docker API types to runtime
// API types, or vice versa.
// API types, or vice versa.
func
imageToRuntimeAPIImage
(
image
*
dockertypes
.
Image
)
(
*
runtimeapi
.
Image
,
error
)
{
func
imageToRuntimeAPIImage
(
image
*
dockertypes
.
Image
Summary
)
(
*
runtimeapi
.
Image
,
error
)
{
if
image
==
nil
{
if
image
==
nil
{
return
nil
,
fmt
.
Errorf
(
"unable to convert a nil pointer to a runtime API image"
)
return
nil
,
fmt
.
Errorf
(
"unable to convert a nil pointer to a runtime API image"
)
}
}
...
...
pkg/kubelet/dockershim/convert_test.go
View file @
bf2ced83
...
@@ -19,7 +19,7 @@ package dockershim
...
@@ -19,7 +19,7 @@ package dockershim
import
(
import
(
"testing"
"testing"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
...
...
pkg/kubelet/dockershim/docker_container.go
View file @
bf2ced83
...
@@ -22,10 +22,10 @@ import (
...
@@ -22,10 +22,10 @@ import (
"path/filepath"
"path/filepath"
"time"
"time"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
dockercontainer
"github.com/docker/
engine-
api/types/container"
dockercontainer
"github.com/docker/
docker/
api/types/container"
dockerfilters
"github.com/docker/
engine-
api/types/filters"
dockerfilters
"github.com/docker/
docker/
api/types/filters"
dockerstrslice
"github.com/docker/
engine-
api/types/strslice"
dockerstrslice
"github.com/docker/
docker/
api/types/strslice"
"github.com/golang/glog"
"github.com/golang/glog"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
...
@@ -36,8 +36,8 @@ import (
...
@@ -36,8 +36,8 @@ import (
func
(
ds
*
dockerService
)
ListContainers
(
filter
*
runtimeapi
.
ContainerFilter
)
([]
*
runtimeapi
.
Container
,
error
)
{
func
(
ds
*
dockerService
)
ListContainers
(
filter
*
runtimeapi
.
ContainerFilter
)
([]
*
runtimeapi
.
Container
,
error
)
{
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
}
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
}
opts
.
Filter
=
dockerfilters
.
NewArgs
()
opts
.
Filter
s
=
dockerfilters
.
NewArgs
()
f
:=
newDockerFilter
(
&
opts
.
Filter
)
f
:=
newDockerFilter
(
&
opts
.
Filter
s
)
// Add filter to get *only* (non-sandbox) containers.
// Add filter to get *only* (non-sandbox) containers.
f
.
AddLabel
(
containerTypeLabelKey
,
containerTypeLabelContainer
)
f
.
AddLabel
(
containerTypeLabelKey
,
containerTypeLabelContainer
)
...
@@ -249,7 +249,7 @@ func (ds *dockerService) StartContainer(containerID string) error {
...
@@ -249,7 +249,7 @@ func (ds *dockerService) 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
(
ds
*
dockerService
)
StopContainer
(
containerID
string
,
timeout
int64
)
error
{
func
(
ds
*
dockerService
)
StopContainer
(
containerID
string
,
timeout
int64
)
error
{
return
ds
.
client
.
StopContainer
(
containerID
,
int
(
timeout
)
)
return
ds
.
client
.
StopContainer
(
containerID
,
time
.
Duration
(
timeout
)
*
time
.
Second
)
}
}
// RemoveContainer removes the container.
// RemoveContainer removes the container.
...
...
pkg/kubelet/dockershim/docker_container_test.go
View file @
bf2ced83
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"testing"
"testing"
"time"
"time"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
@@ -131,7 +131,7 @@ func TestContainerStatus(t *testing.T) {
...
@@ -131,7 +131,7 @@ func TestContainerStatus(t *testing.T) {
Annotations
:
config
.
Annotations
,
Annotations
:
config
.
Annotations
,
}
}
fDocker
.
InjectImages
([]
dockertypes
.
Image
{{
ID
:
imageName
}})
fDocker
.
InjectImages
([]
dockertypes
.
Image
Summary
{{
ID
:
imageName
}})
// Create the container.
// Create the container.
fClock
.
SetTime
(
time
.
Now
()
.
Add
(
-
1
*
time
.
Hour
))
fClock
.
SetTime
(
time
.
Now
()
.
Add
(
-
1
*
time
.
Hour
))
...
...
pkg/kubelet/dockershim/docker_image.go
View file @
bf2ced83
...
@@ -20,8 +20,8 @@ import (
...
@@ -20,8 +20,8 @@ import (
"fmt"
"fmt"
"net/http"
"net/http"
dockertypes
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/docker/pkg/jsonmessage"
dockertypes
"github.com/docker/engine-api/types"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
"k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker"
"k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker"
...
@@ -34,7 +34,7 @@ func (ds *dockerService) ListImages(filter *runtimeapi.ImageFilter) ([]*runtimea
...
@@ -34,7 +34,7 @@ func (ds *dockerService) ListImages(filter *runtimeapi.ImageFilter) ([]*runtimea
opts
:=
dockertypes
.
ImageListOptions
{}
opts
:=
dockertypes
.
ImageListOptions
{}
if
filter
!=
nil
{
if
filter
!=
nil
{
if
imgSpec
:=
filter
.
GetImage
();
imgSpec
!=
nil
{
if
imgSpec
:=
filter
.
GetImage
();
imgSpec
!=
nil
{
opts
.
MatchName
=
imgSpec
.
Image
opts
.
Filters
.
Add
(
"reference"
,
imgSpec
.
Image
)
}
}
}
}
...
...
pkg/kubelet/dockershim/docker_image_test.go
View file @
bf2ced83
...
@@ -20,8 +20,8 @@ import (
...
@@ -20,8 +20,8 @@ import (
"fmt"
"fmt"
"testing"
"testing"
dockertypes
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/docker/pkg/jsonmessage"
dockertypes
"github.com/docker/engine-api/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
...
...
pkg/kubelet/dockershim/docker_legacy.go
View file @
bf2ced83
...
@@ -22,8 +22,8 @@ import (
...
@@ -22,8 +22,8 @@ import (
"sync/atomic"
"sync/atomic"
"time"
"time"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
dockerfilters
"github.com/docker/
engine-
api/types/filters"
dockerfilters
"github.com/docker/
docker/
api/types/filters"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
...
@@ -155,9 +155,9 @@ func (ds *dockerService) checkLegacyCleanup() (bool, error) {
...
@@ -155,9 +155,9 @@ func (ds *dockerService) checkLegacyCleanup() (bool, error) {
// ListLegacyPodSandbox only lists all legacy pod sandboxes.
// ListLegacyPodSandbox only lists all legacy pod sandboxes.
func
(
ds
*
dockerService
)
ListLegacyPodSandbox
(
filter
*
runtimeapi
.
PodSandboxFilter
)
([]
*
runtimeapi
.
PodSandbox
,
error
)
{
func
(
ds
*
dockerService
)
ListLegacyPodSandbox
(
filter
*
runtimeapi
.
PodSandboxFilter
)
([]
*
runtimeapi
.
PodSandbox
,
error
)
{
// By default, list all containers whether they are running or not.
// By default, list all containers whether they are running or not.
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
,
Filter
:
dockerfilters
.
NewArgs
()}
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
,
Filter
s
:
dockerfilters
.
NewArgs
()}
filterOutReadySandboxes
:=
false
filterOutReadySandboxes
:=
false
f
:=
newDockerFilter
(
&
opts
.
Filter
)
f
:=
newDockerFilter
(
&
opts
.
Filter
s
)
if
filter
!=
nil
{
if
filter
!=
nil
{
if
filter
.
Id
!=
""
{
if
filter
.
Id
!=
""
{
f
.
Add
(
"id"
,
filter
.
Id
)
f
.
Add
(
"id"
,
filter
.
Id
)
...
@@ -218,8 +218,8 @@ func (ds *dockerService) ListLegacyPodSandbox(filter *runtimeapi.PodSandboxFilte
...
@@ -218,8 +218,8 @@ func (ds *dockerService) ListLegacyPodSandbox(filter *runtimeapi.PodSandboxFilte
// ListLegacyPodSandbox only lists all legacy containers.
// ListLegacyPodSandbox only lists all legacy containers.
func
(
ds
*
dockerService
)
ListLegacyContainers
(
filter
*
runtimeapi
.
ContainerFilter
)
([]
*
runtimeapi
.
Container
,
error
)
{
func
(
ds
*
dockerService
)
ListLegacyContainers
(
filter
*
runtimeapi
.
ContainerFilter
)
([]
*
runtimeapi
.
Container
,
error
)
{
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
,
Filter
:
dockerfilters
.
NewArgs
()}
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
,
Filter
s
:
dockerfilters
.
NewArgs
()}
f
:=
newDockerFilter
(
&
opts
.
Filter
)
f
:=
newDockerFilter
(
&
opts
.
Filter
s
)
if
filter
!=
nil
{
if
filter
!=
nil
{
if
filter
.
Id
!=
""
{
if
filter
.
Id
!=
""
{
...
...
pkg/kubelet/dockershim/docker_legacy_test.go
View file @
bf2ced83
...
@@ -19,7 +19,7 @@ package dockershim
...
@@ -19,7 +19,7 @@ package dockershim
import
(
import
(
"testing"
"testing"
dockercontainer
"github.com/docker/
engine-
api/types/container"
dockercontainer
"github.com/docker/
docker/
api/types/container"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
...
pkg/kubelet/dockershim/docker_sandbox.go
View file @
bf2ced83
...
@@ -20,10 +20,11 @@ import (
...
@@ -20,10 +20,11 @@ import (
"fmt"
"fmt"
"os"
"os"
"strings"
"strings"
"time"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
dockercontainer
"github.com/docker/
engine-
api/types/container"
dockercontainer
"github.com/docker/
docker/
api/types/container"
dockerfilters
"github.com/docker/
engine-
api/types/filters"
dockerfilters
"github.com/docker/
docker/
api/types/filters"
"github.com/golang/glog"
"github.com/golang/glog"
utilerrors
"k8s.io/apimachinery/pkg/util/errors"
utilerrors
"k8s.io/apimachinery/pkg/util/errors"
...
@@ -41,13 +42,15 @@ const (
...
@@ -41,13 +42,15 @@ const (
// Various default sandbox resources requests/limits.
// Various default sandbox resources requests/limits.
defaultSandboxCPUshares
int64
=
2
defaultSandboxCPUshares
int64
=
2
// Termination grace period
defaultSandboxGracePeriod
int
=
10
// Name of the underlying container runtime
// Name of the underlying container runtime
runtimeName
=
"docker"
runtimeName
=
"docker"
)
)
var
(
// Termination grace period
defaultSandboxGracePeriod
=
time
.
Duration
(
10
)
*
time
.
Second
)
// Returns whether the sandbox network is ready, and whether the sandbox is known
// Returns whether the sandbox network is ready, and whether the sandbox is known
func
(
ds
*
dockerService
)
getNetworkReady
(
podSandboxID
string
)
(
bool
,
bool
)
{
func
(
ds
*
dockerService
)
getNetworkReady
(
podSandboxID
string
)
(
bool
,
bool
)
{
ds
.
networkReadyLock
.
Lock
()
ds
.
networkReadyLock
.
Lock
()
...
@@ -250,8 +253,8 @@ func (ds *dockerService) RemovePodSandbox(podSandboxID string) error {
...
@@ -250,8 +253,8 @@ func (ds *dockerService) RemovePodSandbox(podSandboxID string) error {
var
errs
[]
error
var
errs
[]
error
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
}
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
}
opts
.
Filter
=
dockerfilters
.
NewArgs
()
opts
.
Filter
s
=
dockerfilters
.
NewArgs
()
f
:=
newDockerFilter
(
&
opts
.
Filter
)
f
:=
newDockerFilter
(
&
opts
.
Filter
s
)
f
.
AddLabel
(
sandboxIDLabelKey
,
podSandboxID
)
f
.
AddLabel
(
sandboxIDLabelKey
,
podSandboxID
)
containers
,
err
:=
ds
.
client
.
ListContainers
(
opts
)
containers
,
err
:=
ds
.
client
.
ListContainers
(
opts
)
...
@@ -414,8 +417,8 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]
...
@@ -414,8 +417,8 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
}
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
}
filterOutReadySandboxes
:=
false
filterOutReadySandboxes
:=
false
opts
.
Filter
=
dockerfilters
.
NewArgs
()
opts
.
Filter
s
=
dockerfilters
.
NewArgs
()
f
:=
newDockerFilter
(
&
opts
.
Filter
)
f
:=
newDockerFilter
(
&
opts
.
Filter
s
)
// Add filter to select only sandbox containers.
// Add filter to select only sandbox containers.
f
.
AddLabel
(
containerTypeLabelKey
,
containerTypeLabelSandbox
)
f
.
AddLabel
(
containerTypeLabelKey
,
containerTypeLabelSandbox
)
...
...
pkg/kubelet/dockershim/docker_service.go
View file @
bf2ced83
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"time"
"time"
"github.com/blang/semver"
"github.com/blang/semver"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
...
...
pkg/kubelet/dockershim/docker_service_test.go
View file @
bf2ced83
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"time"
"time"
"github.com/blang/semver"
"github.com/blang/semver"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/golang/mock/gomock"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
...
pkg/kubelet/dockershim/docker_streaming.go
View file @
bf2ced83
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"strings"
"strings"
"time"
"time"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -140,7 +140,7 @@ func attachContainer(client libdocker.Interface, containerID string, stdin io.Re
...
@@ -140,7 +140,7 @@ func attachContainer(client libdocker.Interface, containerID string, stdin io.Re
// Have to start this before the call to client.AttachToContainer because client.AttachToContainer is a blocking
// Have to start this before the call to client.AttachToContainer because client.AttachToContainer is a blocking
// call :-( Otherwise, resize events don't get processed and the terminal never resizes.
// call :-( Otherwise, resize events don't get processed and the terminal never resizes.
kubecontainer
.
HandleResizing
(
resize
,
func
(
size
remotecommand
.
TerminalSize
)
{
kubecontainer
.
HandleResizing
(
resize
,
func
(
size
remotecommand
.
TerminalSize
)
{
client
.
ResizeContainerTTY
(
containerID
,
int
(
size
.
Height
),
int
(
size
.
Width
))
client
.
ResizeContainerTTY
(
containerID
,
uint
(
size
.
Height
),
u
int
(
size
.
Width
))
})
})
// TODO(random-liu): Do we really use the *Logs* field here?
// TODO(random-liu): Do we really use the *Logs* field here?
...
...
pkg/kubelet/dockershim/exec.go
View file @
bf2ced83
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"os/exec"
"os/exec"
"time"
"time"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/client-go/tools/remotecommand"
"k8s.io/client-go/tools/remotecommand"
...
@@ -150,7 +150,7 @@ func (*NativeExecHandler) ExecInContainer(client libdocker.Interface, container
...
@@ -150,7 +150,7 @@ func (*NativeExecHandler) ExecInContainer(client libdocker.Interface, container
// Have to start this before the call to client.StartExec because client.StartExec is a blocking
// Have to start this before the call to client.StartExec because client.StartExec is a blocking
// call :-( Otherwise, resize events don't get processed and the terminal never resizes.
// call :-( Otherwise, resize events don't get processed and the terminal never resizes.
kubecontainer
.
HandleResizing
(
resize
,
func
(
size
remotecommand
.
TerminalSize
)
{
kubecontainer
.
HandleResizing
(
resize
,
func
(
size
remotecommand
.
TerminalSize
)
{
client
.
ResizeExecTTY
(
execObj
.
ID
,
int
(
size
.
Height
),
int
(
size
.
Width
))
client
.
ResizeExecTTY
(
execObj
.
ID
,
uint
(
size
.
Height
),
u
int
(
size
.
Width
))
})
})
startOpts
:=
dockertypes
.
ExecStartCheck
{
Detach
:
false
,
Tty
:
tty
}
startOpts
:=
dockertypes
.
ExecStartCheck
{
Detach
:
false
,
Tty
:
tty
}
...
...
pkg/kubelet/dockershim/helpers.go
View file @
bf2ced83
...
@@ -25,8 +25,9 @@ import (
...
@@ -25,8 +25,9 @@ import (
"strings"
"strings"
"github.com/blang/semver"
"github.com/blang/semver"
dockertypes
"github.com/docker/engine-api/types"
dockertypes
"github.com/docker/docker/api/types"
dockerfilters
"github.com/docker/engine-api/types/filters"
dockercontainer
"github.com/docker/docker/api/types/container"
dockerfilters
"github.com/docker/docker/api/types/filters"
dockernat
"github.com/docker/go-connections/nat"
dockernat
"github.com/docker/go-connections/nat"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -152,8 +153,8 @@ func generateMountBindings(mounts []*runtimeapi.Mount) []string {
...
@@ -152,8 +153,8 @@ func generateMountBindings(mounts []*runtimeapi.Mount) []string {
return
result
return
result
}
}
func
makePortsAndBindings
(
pm
[]
*
runtimeapi
.
PortMapping
)
(
map
[
dockernat
.
Port
]
struct
{}
,
map
[
dockernat
.
Port
][]
dockernat
.
PortBinding
)
{
func
makePortsAndBindings
(
pm
[]
*
runtimeapi
.
PortMapping
)
(
dockernat
.
PortSet
,
map
[
dockernat
.
Port
][]
dockernat
.
PortBinding
)
{
exposedPorts
:=
map
[
dockernat
.
Port
]
struct
{}
{}
exposedPorts
:=
dockernat
.
PortSet
{}
portBindings
:=
map
[
dockernat
.
Port
][]
dockernat
.
PortBinding
{}
portBindings
:=
map
[
dockernat
.
Port
][]
dockernat
.
PortBinding
{}
for
_
,
port
:=
range
pm
{
for
_
,
port
:=
range
pm
{
exteriorPort
:=
port
.
HostPort
exteriorPort
:=
port
.
HostPort
...
@@ -280,7 +281,7 @@ func getUserFromImageUser(imageUser string) (*int64, string) {
...
@@ -280,7 +281,7 @@ func getUserFromImageUser(imageUser string) (*int64, string) {
// In that case we have to create the container with a randomized name.
// In that case we have to create the container with a randomized name.
// TODO(random-liu): Remove this work around after docker 1.11 is deprecated.
// TODO(random-liu): Remove this work around after docker 1.11 is deprecated.
// TODO(#33189): Monitor the tests to see if the fix is sufficient.
// TODO(#33189): Monitor the tests to see if the fix is sufficient.
func
recoverFromCreationConflictIfNeeded
(
client
libdocker
.
Interface
,
createConfig
dockertypes
.
ContainerCreateConfig
,
err
error
)
(
*
docker
types
.
ContainerCreateResponse
,
error
)
{
func
recoverFromCreationConflictIfNeeded
(
client
libdocker
.
Interface
,
createConfig
dockertypes
.
ContainerCreateConfig
,
err
error
)
(
*
docker
container
.
ContainerCreateCreatedBody
,
error
)
{
matches
:=
conflictRE
.
FindStringSubmatch
(
err
.
Error
())
matches
:=
conflictRE
.
FindStringSubmatch
(
err
.
Error
())
if
len
(
matches
)
!=
2
{
if
len
(
matches
)
!=
2
{
return
nil
,
err
return
nil
,
err
...
...
pkg/kubelet/dockershim/helpers_linux.go
View file @
bf2ced83
...
@@ -28,8 +28,8 @@ import (
...
@@ -28,8 +28,8 @@ import (
"strings"
"strings"
"github.com/blang/semver"
"github.com/blang/semver"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
dockercontainer
"github.com/docker/
engine-
api/types/container"
dockercontainer
"github.com/docker/
docker/
api/types/container"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
)
)
...
...
pkg/kubelet/dockershim/helpers_test.go
View file @
bf2ced83
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"testing"
"testing"
"github.com/blang/semver"
"github.com/blang/semver"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
dockernat
"github.com/docker/go-connections/nat"
dockernat
"github.com/docker/go-connections/nat"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
@@ -218,7 +218,7 @@ func TestEnsureSandboxImageExists(t *testing.T) {
...
@@ -218,7 +218,7 @@ func TestEnsureSandboxImageExists(t *testing.T) {
t
.
Logf
(
"TestCase: %q"
,
desc
)
t
.
Logf
(
"TestCase: %q"
,
desc
)
_
,
fakeDocker
,
_
:=
newTestDockerService
()
_
,
fakeDocker
,
_
:=
newTestDockerService
()
if
test
.
injectImage
{
if
test
.
injectImage
{
images
:=
[]
dockertypes
.
Image
{{
ID
:
sandboxImage
}}
images
:=
[]
dockertypes
.
Image
Summary
{{
ID
:
sandboxImage
}}
fakeDocker
.
InjectImages
(
images
)
fakeDocker
.
InjectImages
(
images
)
if
test
.
imgNeedsAuth
{
if
test
.
imgNeedsAuth
{
fakeDocker
.
MakeImagesPrivate
(
images
,
authConfig
)
fakeDocker
.
MakeImagesPrivate
(
images
,
authConfig
)
...
@@ -243,7 +243,7 @@ func TestEnsureSandboxImageExists(t *testing.T) {
...
@@ -243,7 +243,7 @@ func TestEnsureSandboxImageExists(t *testing.T) {
func
TestMakePortsAndBindings
(
t
*
testing
.
T
)
{
func
TestMakePortsAndBindings
(
t
*
testing
.
T
)
{
for
desc
,
test
:=
range
map
[
string
]
struct
{
for
desc
,
test
:=
range
map
[
string
]
struct
{
pm
[]
*
runtimeapi
.
PortMapping
pm
[]
*
runtimeapi
.
PortMapping
exposedPorts
map
[
dockernat
.
Port
]
struct
{}
exposedPorts
dockernat
.
PortSet
portmappings
map
[
dockernat
.
Port
][]
dockernat
.
PortBinding
portmappings
map
[
dockernat
.
Port
][]
dockernat
.
PortBinding
}{
}{
"no port mapping"
:
{
"no port mapping"
:
{
...
...
pkg/kubelet/dockershim/helpers_unsupported.go
View file @
bf2ced83
...
@@ -20,7 +20,7 @@ package dockershim
...
@@ -20,7 +20,7 @@ package dockershim
import
(
import
(
"github.com/blang/semver"
"github.com/blang/semver"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/golang/glog"
"github.com/golang/glog"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
)
)
...
...
pkg/kubelet/dockershim/helpers_windows.go
View file @
bf2ced83
...
@@ -22,9 +22,9 @@ import (
...
@@ -22,9 +22,9 @@ import (
"os"
"os"
"github.com/blang/semver"
"github.com/blang/semver"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
dockercontainer
"github.com/docker/
engine-
api/types/container"
dockercontainer
"github.com/docker/
docker/
api/types/container"
dockerfilters
"github.com/docker/
engine-
api/types/filters"
dockerfilters
"github.com/docker/
docker/
api/types/filters"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
...
...
pkg/kubelet/dockershim/libdocker/BUILD
View file @
bf2ced83
...
@@ -19,7 +19,7 @@ go_test(
...
@@ -19,7 +19,7 @@ go_test(
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//pkg/util/hash:go_default_library",
"//pkg/util/hash:go_default_library",
"//vendor/github.com/docker/
engine-
api/types:go_default_library",
"//vendor/github.com/docker/
docker/
api/types:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
...
@@ -42,11 +42,11 @@ go_library(
...
@@ -42,11 +42,11 @@ go_library(
"//pkg/kubelet/metrics:go_default_library",
"//pkg/kubelet/metrics:go_default_library",
"//vendor/github.com/docker/distribution/digest:go_default_library",
"//vendor/github.com/docker/distribution/digest:go_default_library",
"//vendor/github.com/docker/distribution/reference:go_default_library",
"//vendor/github.com/docker/distribution/reference:go_default_library",
"//vendor/github.com/docker/docker/api/types:go_default_library",
"//vendor/github.com/docker/docker/api/types/container:go_default_library",
"//vendor/github.com/docker/docker/client:go_default_library",
"//vendor/github.com/docker/docker/pkg/jsonmessage:go_default_library",
"//vendor/github.com/docker/docker/pkg/jsonmessage:go_default_library",
"//vendor/github.com/docker/docker/pkg/stdcopy:go_default_library",
"//vendor/github.com/docker/docker/pkg/stdcopy:go_default_library",
"//vendor/github.com/docker/engine-api/client:go_default_library",
"//vendor/github.com/docker/engine-api/types:go_default_library",
"//vendor/github.com/docker/engine-api/types/container:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
...
...
pkg/kubelet/dockershim/libdocker/client.go
View file @
bf2ced83
...
@@ -20,8 +20,9 @@ import (
...
@@ -20,8 +20,9 @@ import (
"strings"
"strings"
"time"
"time"
dockerapi
"github.com/docker/engine-api/client"
dockertypes
"github.com/docker/docker/api/types"
dockertypes
"github.com/docker/engine-api/types"
dockercontainer
"github.com/docker/docker/api/types/container"
dockerapi
"github.com/docker/docker/client"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -44,25 +45,25 @@ const (
...
@@ -44,25 +45,25 @@ const (
type
Interface
interface
{
type
Interface
interface
{
ListContainers
(
options
dockertypes
.
ContainerListOptions
)
([]
dockertypes
.
Container
,
error
)
ListContainers
(
options
dockertypes
.
ContainerListOptions
)
([]
dockertypes
.
Container
,
error
)
InspectContainer
(
id
string
)
(
*
dockertypes
.
ContainerJSON
,
error
)
InspectContainer
(
id
string
)
(
*
dockertypes
.
ContainerJSON
,
error
)
CreateContainer
(
dockertypes
.
ContainerCreateConfig
)
(
*
docker
types
.
ContainerCreateResponse
,
error
)
CreateContainer
(
dockertypes
.
ContainerCreateConfig
)
(
*
docker
container
.
ContainerCreateCreatedBody
,
error
)
StartContainer
(
id
string
)
error
StartContainer
(
id
string
)
error
StopContainer
(
id
string
,
timeout
int
)
error
StopContainer
(
id
string
,
timeout
time
.
Duration
)
error
RemoveContainer
(
id
string
,
opts
dockertypes
.
ContainerRemoveOptions
)
error
RemoveContainer
(
id
string
,
opts
dockertypes
.
ContainerRemoveOptions
)
error
InspectImageByRef
(
imageRef
string
)
(
*
dockertypes
.
ImageInspect
,
error
)
InspectImageByRef
(
imageRef
string
)
(
*
dockertypes
.
ImageInspect
,
error
)
InspectImageByID
(
imageID
string
)
(
*
dockertypes
.
ImageInspect
,
error
)
InspectImageByID
(
imageID
string
)
(
*
dockertypes
.
ImageInspect
,
error
)
ListImages
(
opts
dockertypes
.
ImageListOptions
)
([]
dockertypes
.
Image
,
error
)
ListImages
(
opts
dockertypes
.
ImageListOptions
)
([]
dockertypes
.
Image
Summary
,
error
)
PullImage
(
image
string
,
auth
dockertypes
.
AuthConfig
,
opts
dockertypes
.
ImagePullOptions
)
error
PullImage
(
image
string
,
auth
dockertypes
.
AuthConfig
,
opts
dockertypes
.
ImagePullOptions
)
error
RemoveImage
(
image
string
,
opts
dockertypes
.
ImageRemoveOptions
)
([]
dockertypes
.
ImageDelete
,
error
)
RemoveImage
(
image
string
,
opts
dockertypes
.
ImageRemoveOptions
)
([]
dockertypes
.
ImageDelete
,
error
)
ImageHistory
(
id
string
)
([]
dockertypes
.
ImageHistory
,
error
)
ImageHistory
(
id
string
)
([]
dockertypes
.
ImageHistory
,
error
)
Logs
(
string
,
dockertypes
.
ContainerLogsOptions
,
StreamOptions
)
error
Logs
(
string
,
dockertypes
.
ContainerLogsOptions
,
StreamOptions
)
error
Version
()
(
*
dockertypes
.
Version
,
error
)
Version
()
(
*
dockertypes
.
Version
,
error
)
Info
()
(
*
dockertypes
.
Info
,
error
)
Info
()
(
*
dockertypes
.
Info
,
error
)
CreateExec
(
string
,
dockertypes
.
ExecConfig
)
(
*
dockertypes
.
ContainerExecCreate
Response
,
error
)
CreateExec
(
string
,
dockertypes
.
ExecConfig
)
(
*
dockertypes
.
ID
Response
,
error
)
StartExec
(
string
,
dockertypes
.
ExecStartCheck
,
StreamOptions
)
error
StartExec
(
string
,
dockertypes
.
ExecStartCheck
,
StreamOptions
)
error
InspectExec
(
id
string
)
(
*
dockertypes
.
ContainerExecInspect
,
error
)
InspectExec
(
id
string
)
(
*
dockertypes
.
ContainerExecInspect
,
error
)
AttachToContainer
(
string
,
dockertypes
.
ContainerAttachOptions
,
StreamOptions
)
error
AttachToContainer
(
string
,
dockertypes
.
ContainerAttachOptions
,
StreamOptions
)
error
ResizeContainerTTY
(
id
string
,
height
,
width
int
)
error
ResizeContainerTTY
(
id
string
,
height
,
width
u
int
)
error
ResizeExecTTY
(
id
string
,
height
,
width
int
)
error
ResizeExecTTY
(
id
string
,
height
,
width
u
int
)
error
}
}
// Get a *dockerapi.Client, either using the endpoint passed in, or using
// Get a *dockerapi.Client, either using the endpoint passed in, or using
...
...
pkg/kubelet/dockershim/libdocker/fake_client.go
View file @
bf2ced83
...
@@ -29,8 +29,8 @@ import (
...
@@ -29,8 +29,8 @@ import (
"sync"
"sync"
"time"
"time"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
dockercontainer
"github.com/docker/
engine-
api/types/container"
dockercontainer
"github.com/docker/
docker/
api/types/container"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/clock"
...
@@ -54,7 +54,7 @@ type FakeDockerClient struct {
...
@@ -54,7 +54,7 @@ type FakeDockerClient struct {
ExitedContainerList
[]
dockertypes
.
Container
ExitedContainerList
[]
dockertypes
.
Container
ContainerMap
map
[
string
]
*
dockertypes
.
ContainerJSON
ContainerMap
map
[
string
]
*
dockertypes
.
ContainerJSON
ImageInspects
map
[
string
]
*
dockertypes
.
ImageInspect
ImageInspects
map
[
string
]
*
dockertypes
.
ImageInspect
Images
[]
dockertypes
.
Image
Images
[]
dockertypes
.
Image
Summary
ImageIDsNeedingAuth
map
[
string
]
dockertypes
.
AuthConfig
ImageIDsNeedingAuth
map
[
string
]
dockertypes
.
AuthConfig
Errors
map
[
string
]
error
Errors
map
[
string
]
error
called
[]
calledDetail
called
[]
calledDetail
...
@@ -391,8 +391,8 @@ func (f *FakeDockerClient) ListContainers(options dockertypes.ContainerListOptio
...
@@ -391,8 +391,8 @@ func (f *FakeDockerClient) ListContainers(options dockertypes.ContainerListOptio
// TODO(random-liu): Is a fully sorted array needed?
// TODO(random-liu): Is a fully sorted array needed?
containerList
=
append
(
containerList
,
f
.
ExitedContainerList
...
)
containerList
=
append
(
containerList
,
f
.
ExitedContainerList
...
)
}
}
// Filter containers with id, only support 1 id.
// Filter
s
containers with id, only support 1 id.
idFilters
:=
options
.
Filter
.
Get
(
"id"
)
idFilters
:=
options
.
Filter
s
.
Get
(
"id"
)
if
len
(
idFilters
)
!=
0
{
if
len
(
idFilters
)
!=
0
{
var
filtered
[]
dockertypes
.
Container
var
filtered
[]
dockertypes
.
Container
for
_
,
container
:=
range
containerList
{
for
_
,
container
:=
range
containerList
{
...
@@ -405,8 +405,8 @@ func (f *FakeDockerClient) ListContainers(options dockertypes.ContainerListOptio
...
@@ -405,8 +405,8 @@ func (f *FakeDockerClient) ListContainers(options dockertypes.ContainerListOptio
}
}
containerList
=
filtered
containerList
=
filtered
}
}
// Filter containers with status, only support 1 status.
// Filter
s
containers with status, only support 1 status.
statusFilters
:=
options
.
Filter
.
Get
(
"status"
)
statusFilters
:=
options
.
Filter
s
.
Get
(
"status"
)
if
len
(
statusFilters
)
==
1
{
if
len
(
statusFilters
)
==
1
{
var
filtered
[]
dockertypes
.
Container
var
filtered
[]
dockertypes
.
Container
for
_
,
container
:=
range
containerList
{
for
_
,
container
:=
range
containerList
{
...
@@ -419,8 +419,8 @@ func (f *FakeDockerClient) ListContainers(options dockertypes.ContainerListOptio
...
@@ -419,8 +419,8 @@ func (f *FakeDockerClient) ListContainers(options dockertypes.ContainerListOptio
}
}
containerList
=
filtered
containerList
=
filtered
}
}
// Filter containers with label filter.
// Filter
s
containers with label filter.
labelFilters
:=
options
.
Filter
.
Get
(
"label"
)
labelFilters
:=
options
.
Filter
s
.
Get
(
"label"
)
if
len
(
labelFilters
)
!=
0
{
if
len
(
labelFilters
)
!=
0
{
var
filtered
[]
dockertypes
.
Container
var
filtered
[]
dockertypes
.
Container
for
_
,
container
:=
range
containerList
{
for
_
,
container
:=
range
containerList
{
...
@@ -514,7 +514,7 @@ func GetFakeContainerID(name string) string {
...
@@ -514,7 +514,7 @@ func GetFakeContainerID(name string) string {
// CreateContainer is a test-spy implementation of Interface.CreateContainer.
// CreateContainer is a test-spy implementation of Interface.CreateContainer.
// It adds an entry "create" to the internal method call record.
// It adds an entry "create" to the internal method call record.
func
(
f
*
FakeDockerClient
)
CreateContainer
(
c
dockertypes
.
ContainerCreateConfig
)
(
*
docker
types
.
ContainerCreateResponse
,
error
)
{
func
(
f
*
FakeDockerClient
)
CreateContainer
(
c
dockertypes
.
ContainerCreateConfig
)
(
*
docker
container
.
ContainerCreateCreatedBody
,
error
)
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
f
.
appendCalled
(
calledDetail
{
name
:
"create"
})
f
.
appendCalled
(
calledDetail
{
name
:
"create"
})
...
@@ -536,7 +536,7 @@ func (f *FakeDockerClient) CreateContainer(c dockertypes.ContainerCreateConfig)
...
@@ -536,7 +536,7 @@ func (f *FakeDockerClient) CreateContainer(c dockertypes.ContainerCreateConfig)
f
.
normalSleep
(
100
,
25
,
25
)
f
.
normalSleep
(
100
,
25
,
25
)
return
&
docker
types
.
ContainerCreateResponse
{
ID
:
id
},
nil
return
&
docker
container
.
ContainerCreateCreatedBody
{
ID
:
id
},
nil
}
}
// StartContainer is a test-spy implementation of Interface.StartContainer.
// StartContainer is a test-spy implementation of Interface.StartContainer.
...
@@ -566,7 +566,7 @@ func (f *FakeDockerClient) StartContainer(id string) error {
...
@@ -566,7 +566,7 @@ func (f *FakeDockerClient) StartContainer(id string) error {
// StopContainer is a test-spy implementation of Interface.StopContainer.
// StopContainer is a test-spy implementation of Interface.StopContainer.
// It adds an entry "stop" to the internal method call record.
// It adds an entry "stop" to the internal method call record.
func
(
f
*
FakeDockerClient
)
StopContainer
(
id
string
,
timeout
int
)
error
{
func
(
f
*
FakeDockerClient
)
StopContainer
(
id
string
,
timeout
time
.
Duration
)
error
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
f
.
appendCalled
(
calledDetail
{
name
:
"stop"
})
f
.
appendCalled
(
calledDetail
{
name
:
"stop"
})
...
@@ -675,12 +675,12 @@ func (f *FakeDockerClient) Info() (*dockertypes.Info, error) {
...
@@ -675,12 +675,12 @@ func (f *FakeDockerClient) Info() (*dockertypes.Info, error) {
return
&
f
.
Information
,
nil
return
&
f
.
Information
,
nil
}
}
func
(
f
*
FakeDockerClient
)
CreateExec
(
id
string
,
opts
dockertypes
.
ExecConfig
)
(
*
dockertypes
.
ContainerExecCreate
Response
,
error
)
{
func
(
f
*
FakeDockerClient
)
CreateExec
(
id
string
,
opts
dockertypes
.
ExecConfig
)
(
*
dockertypes
.
ID
Response
,
error
)
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
f
.
execCmd
=
opts
.
Cmd
f
.
execCmd
=
opts
.
Cmd
f
.
appendCalled
(
calledDetail
{
name
:
"create_exec"
})
f
.
appendCalled
(
calledDetail
{
name
:
"create_exec"
})
return
&
dockertypes
.
ContainerExecCreate
Response
{
ID
:
"12345678"
},
nil
return
&
dockertypes
.
ID
Response
{
ID
:
"12345678"
},
nil
}
}
func
(
f
*
FakeDockerClient
)
StartExec
(
startExec
string
,
opts
dockertypes
.
ExecStartCheck
,
sopts
StreamOptions
)
error
{
func
(
f
*
FakeDockerClient
)
StartExec
(
startExec
string
,
opts
dockertypes
.
ExecStartCheck
,
sopts
StreamOptions
)
error
{
...
@@ -701,7 +701,7 @@ func (f *FakeDockerClient) InspectExec(id string) (*dockertypes.ContainerExecIns
...
@@ -701,7 +701,7 @@ func (f *FakeDockerClient) InspectExec(id string) (*dockertypes.ContainerExecIns
return
f
.
ExecInspect
,
f
.
popError
(
"inspect_exec"
)
return
f
.
ExecInspect
,
f
.
popError
(
"inspect_exec"
)
}
}
func
(
f
*
FakeDockerClient
)
ListImages
(
opts
dockertypes
.
ImageListOptions
)
([]
dockertypes
.
Image
,
error
)
{
func
(
f
*
FakeDockerClient
)
ListImages
(
opts
dockertypes
.
ImageListOptions
)
([]
dockertypes
.
Image
Summary
,
error
)
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
f
.
appendCalled
(
calledDetail
{
name
:
"list_images"
})
f
.
appendCalled
(
calledDetail
{
name
:
"list_images"
})
...
@@ -725,7 +725,7 @@ func (f *FakeDockerClient) RemoveImage(image string, opts dockertypes.ImageRemov
...
@@ -725,7 +725,7 @@ func (f *FakeDockerClient) RemoveImage(image string, opts dockertypes.ImageRemov
return
[]
dockertypes
.
ImageDelete
{{
Deleted
:
image
}},
err
return
[]
dockertypes
.
ImageDelete
{{
Deleted
:
image
}},
err
}
}
func
(
f
*
FakeDockerClient
)
InjectImages
(
images
[]
dockertypes
.
Image
)
{
func
(
f
*
FakeDockerClient
)
InjectImages
(
images
[]
dockertypes
.
Image
Summary
)
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
f
.
Images
=
append
(
f
.
Images
,
images
...
)
f
.
Images
=
append
(
f
.
Images
,
images
...
)
...
@@ -734,7 +734,7 @@ func (f *FakeDockerClient) InjectImages(images []dockertypes.Image) {
...
@@ -734,7 +734,7 @@ func (f *FakeDockerClient) InjectImages(images []dockertypes.Image) {
}
}
}
}
func
(
f
*
FakeDockerClient
)
MakeImagesPrivate
(
images
[]
dockertypes
.
Image
,
auth
dockertypes
.
AuthConfig
)
{
func
(
f
*
FakeDockerClient
)
MakeImagesPrivate
(
images
[]
dockertypes
.
Image
Summary
,
auth
dockertypes
.
AuthConfig
)
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
for
_
,
i
:=
range
images
{
for
_
,
i
:=
range
images
{
...
@@ -745,7 +745,7 @@ func (f *FakeDockerClient) MakeImagesPrivate(images []dockertypes.Image, auth do
...
@@ -745,7 +745,7 @@ func (f *FakeDockerClient) MakeImagesPrivate(images []dockertypes.Image, auth do
func
(
f
*
FakeDockerClient
)
ResetImages
()
{
func
(
f
*
FakeDockerClient
)
ResetImages
()
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
f
.
Images
=
[]
dockertypes
.
Image
{}
f
.
Images
=
[]
dockertypes
.
Image
Summary
{}
f
.
ImageInspects
=
make
(
map
[
string
]
*
dockertypes
.
ImageInspect
)
f
.
ImageInspects
=
make
(
map
[
string
]
*
dockertypes
.
ImageInspect
)
f
.
ImageIDsNeedingAuth
=
make
(
map
[
string
]
dockertypes
.
AuthConfig
)
f
.
ImageIDsNeedingAuth
=
make
(
map
[
string
]
dockertypes
.
AuthConfig
)
}
}
...
@@ -767,14 +767,14 @@ func (f *FakeDockerClient) updateContainerStatus(id, status string) {
...
@@ -767,14 +767,14 @@ func (f *FakeDockerClient) updateContainerStatus(id, status string) {
}
}
}
}
func
(
f
*
FakeDockerClient
)
ResizeExecTTY
(
id
string
,
height
,
width
int
)
error
{
func
(
f
*
FakeDockerClient
)
ResizeExecTTY
(
id
string
,
height
,
width
u
int
)
error
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
f
.
appendCalled
(
calledDetail
{
name
:
"resize_exec"
})
f
.
appendCalled
(
calledDetail
{
name
:
"resize_exec"
})
return
nil
return
nil
}
}
func
(
f
*
FakeDockerClient
)
ResizeContainerTTY
(
id
string
,
height
,
width
int
)
error
{
func
(
f
*
FakeDockerClient
)
ResizeContainerTTY
(
id
string
,
height
,
width
u
int
)
error
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
f
.
appendCalled
(
calledDetail
{
name
:
"resize_container"
})
f
.
appendCalled
(
calledDetail
{
name
:
"resize_container"
})
...
@@ -792,7 +792,7 @@ func createImageInspectFromRef(ref string) *dockertypes.ImageInspect {
...
@@ -792,7 +792,7 @@ func createImageInspectFromRef(ref string) *dockertypes.ImageInspect {
}
}
}
}
func
createImageInspectFromImage
(
image
dockertypes
.
Image
)
*
dockertypes
.
ImageInspect
{
func
createImageInspectFromImage
(
image
dockertypes
.
Image
Summary
)
*
dockertypes
.
ImageInspect
{
return
&
dockertypes
.
ImageInspect
{
return
&
dockertypes
.
ImageInspect
{
ID
:
image
.
ID
,
ID
:
image
.
ID
,
RepoTags
:
image
.
RepoTags
,
RepoTags
:
image
.
RepoTags
,
...
@@ -803,8 +803,8 @@ func createImageInspectFromImage(image dockertypes.Image) *dockertypes.ImageInsp
...
@@ -803,8 +803,8 @@ func createImageInspectFromImage(image dockertypes.Image) *dockertypes.ImageInsp
}
}
}
}
func
createImageFromImageInspect
(
inspect
dockertypes
.
ImageInspect
)
*
dockertypes
.
Image
{
func
createImageFromImageInspect
(
inspect
dockertypes
.
ImageInspect
)
*
dockertypes
.
Image
Summary
{
return
&
dockertypes
.
Image
{
return
&
dockertypes
.
Image
Summary
{
ID
:
inspect
.
ID
,
ID
:
inspect
.
ID
,
RepoTags
:
inspect
.
RepoTags
,
RepoTags
:
inspect
.
RepoTags
,
// Image size is required to be non-zero for CRI integration.
// Image size is required to be non-zero for CRI integration.
...
...
pkg/kubelet/dockershim/libdocker/helpers.go
View file @
bf2ced83
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
dockerdigest
"github.com/docker/distribution/digest"
dockerdigest
"github.com/docker/distribution/digest"
dockerref
"github.com/docker/distribution/reference"
dockerref
"github.com/docker/distribution/reference"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
...
pkg/kubelet/dockershim/libdocker/helpers_test.go
View file @
bf2ced83
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"fmt"
"fmt"
"testing"
"testing"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
)
)
...
...
pkg/kubelet/dockershim/libdocker/instrumented_client.go
View file @
bf2ced83
...
@@ -19,7 +19,8 @@ package libdocker
...
@@ -19,7 +19,8 @@ package libdocker
import
(
import
(
"time"
"time"
dockertypes
"github.com/docker/engine-api/types"
dockertypes
"github.com/docker/docker/api/types"
dockercontainer
"github.com/docker/docker/api/types/container"
"k8s.io/kubernetes/pkg/kubelet/metrics"
"k8s.io/kubernetes/pkg/kubelet/metrics"
)
)
...
@@ -71,7 +72,7 @@ func (in instrumentedInterface) InspectContainer(id string) (*dockertypes.Contai
...
@@ -71,7 +72,7 @@ func (in instrumentedInterface) InspectContainer(id string) (*dockertypes.Contai
return
out
,
err
return
out
,
err
}
}
func
(
in
instrumentedInterface
)
CreateContainer
(
opts
dockertypes
.
ContainerCreateConfig
)
(
*
docker
types
.
ContainerCreateResponse
,
error
)
{
func
(
in
instrumentedInterface
)
CreateContainer
(
opts
dockertypes
.
ContainerCreateConfig
)
(
*
docker
container
.
ContainerCreateCreatedBody
,
error
)
{
const
operation
=
"create_container"
const
operation
=
"create_container"
defer
recordOperation
(
operation
,
time
.
Now
())
defer
recordOperation
(
operation
,
time
.
Now
())
...
@@ -89,7 +90,7 @@ func (in instrumentedInterface) StartContainer(id string) error {
...
@@ -89,7 +90,7 @@ func (in instrumentedInterface) StartContainer(id string) error {
return
err
return
err
}
}
func
(
in
instrumentedInterface
)
StopContainer
(
id
string
,
timeout
int
)
error
{
func
(
in
instrumentedInterface
)
StopContainer
(
id
string
,
timeout
time
.
Duration
)
error
{
const
operation
=
"stop_container"
const
operation
=
"stop_container"
defer
recordOperation
(
operation
,
time
.
Now
())
defer
recordOperation
(
operation
,
time
.
Now
())
...
@@ -125,7 +126,7 @@ func (in instrumentedInterface) InspectImageByID(image string) (*dockertypes.Ima
...
@@ -125,7 +126,7 @@ func (in instrumentedInterface) InspectImageByID(image string) (*dockertypes.Ima
return
out
,
err
return
out
,
err
}
}
func
(
in
instrumentedInterface
)
ListImages
(
opts
dockertypes
.
ImageListOptions
)
([]
dockertypes
.
Image
,
error
)
{
func
(
in
instrumentedInterface
)
ListImages
(
opts
dockertypes
.
ImageListOptions
)
([]
dockertypes
.
Image
Summary
,
error
)
{
const
operation
=
"list_images"
const
operation
=
"list_images"
defer
recordOperation
(
operation
,
time
.
Now
())
defer
recordOperation
(
operation
,
time
.
Now
())
...
@@ -178,7 +179,7 @@ func (in instrumentedInterface) Info() (*dockertypes.Info, error) {
...
@@ -178,7 +179,7 @@ func (in instrumentedInterface) Info() (*dockertypes.Info, error) {
return
out
,
err
return
out
,
err
}
}
func
(
in
instrumentedInterface
)
CreateExec
(
id
string
,
opts
dockertypes
.
ExecConfig
)
(
*
dockertypes
.
ContainerExecCreate
Response
,
error
)
{
func
(
in
instrumentedInterface
)
CreateExec
(
id
string
,
opts
dockertypes
.
ExecConfig
)
(
*
dockertypes
.
ID
Response
,
error
)
{
const
operation
=
"create_exec"
const
operation
=
"create_exec"
defer
recordOperation
(
operation
,
time
.
Now
())
defer
recordOperation
(
operation
,
time
.
Now
())
...
@@ -223,7 +224,7 @@ func (in instrumentedInterface) ImageHistory(id string) ([]dockertypes.ImageHist
...
@@ -223,7 +224,7 @@ func (in instrumentedInterface) ImageHistory(id string) ([]dockertypes.ImageHist
return
out
,
err
return
out
,
err
}
}
func
(
in
instrumentedInterface
)
ResizeExecTTY
(
id
string
,
height
,
width
int
)
error
{
func
(
in
instrumentedInterface
)
ResizeExecTTY
(
id
string
,
height
,
width
u
int
)
error
{
const
operation
=
"resize_exec"
const
operation
=
"resize_exec"
defer
recordOperation
(
operation
,
time
.
Now
())
defer
recordOperation
(
operation
,
time
.
Now
())
...
@@ -232,7 +233,7 @@ func (in instrumentedInterface) ResizeExecTTY(id string, height, width int) erro
...
@@ -232,7 +233,7 @@ func (in instrumentedInterface) ResizeExecTTY(id string, height, width int) erro
return
err
return
err
}
}
func
(
in
instrumentedInterface
)
ResizeContainerTTY
(
id
string
,
height
,
width
int
)
error
{
func
(
in
instrumentedInterface
)
ResizeContainerTTY
(
id
string
,
height
,
width
u
int
)
error
{
const
operation
=
"resize_container"
const
operation
=
"resize_container"
defer
recordOperation
(
operation
,
time
.
Now
())
defer
recordOperation
(
operation
,
time
.
Now
())
...
...
pkg/kubelet/dockershim/libdocker/kube_docker_client.go
View file @
bf2ced83
...
@@ -29,26 +29,17 @@ import (
...
@@ -29,26 +29,17 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
dockertypes
"github.com/docker/docker/api/types"
dockercontainer
"github.com/docker/docker/api/types/container"
dockerapi
"github.com/docker/docker/client"
dockermessage
"github.com/docker/docker/pkg/jsonmessage"
dockermessage
"github.com/docker/docker/pkg/jsonmessage"
dockerstdcopy
"github.com/docker/docker/pkg/stdcopy"
dockerstdcopy
"github.com/docker/docker/pkg/stdcopy"
dockerapi
"github.com/docker/engine-api/client"
dockertypes
"github.com/docker/engine-api/types"
"golang.org/x/net/context"
"golang.org/x/net/context"
)
)
// kubeDockerClient is a wrapped layer of docker client for kubelet internal use. This layer is added to:
// kubeDockerClient is a wrapped layer of docker client for kubelet internal use. This layer is added to:
// 1) Redirect stream for exec and attach operations.
// 1) Redirect stream for exec and attach operations.
// 2) Wrap the context in this layer to make the Interface cleaner.
// 2) Wrap the context in this layer to make the Interface cleaner.
// 3) Stabilize the Interface. The engine-api is still under active development, the interface
// is not stabilized yet. However, the Interface is used in many files in Kubernetes, we may
// not want to change the interface frequently. With this layer, we can port the engine api to the
// Interface to avoid changing Interface as much as possible.
// (See
// * https://github.com/docker/engine-api/issues/89
// * https://github.com/docker/engine-api/issues/137
// * https://github.com/docker/engine-api/pull/140)
// TODO(random-liu): Swith to new docker interface by refactoring the functions in the old Interface
// one by one.
type
kubeDockerClient
struct
{
type
kubeDockerClient
struct
{
// timeout is the timeout of short running docker operations.
// timeout is the timeout of short running docker operations.
timeout
time
.
Duration
timeout
time
.
Duration
...
@@ -131,7 +122,7 @@ func (d *kubeDockerClient) InspectContainer(id string) (*dockertypes.ContainerJS
...
@@ -131,7 +122,7 @@ func (d *kubeDockerClient) InspectContainer(id string) (*dockertypes.ContainerJS
return
&
containerJSON
,
nil
return
&
containerJSON
,
nil
}
}
func
(
d
*
kubeDockerClient
)
CreateContainer
(
opts
dockertypes
.
ContainerCreateConfig
)
(
*
docker
types
.
ContainerCreateResponse
,
error
)
{
func
(
d
*
kubeDockerClient
)
CreateContainer
(
opts
dockertypes
.
ContainerCreateConfig
)
(
*
docker
container
.
ContainerCreateCreatedBody
,
error
)
{
ctx
,
cancel
:=
d
.
getTimeoutContext
()
ctx
,
cancel
:=
d
.
getTimeoutContext
()
defer
cancel
()
defer
cancel
()
// we provide an explicit default shm size as to not depend on docker daemon.
// we provide an explicit default shm size as to not depend on docker daemon.
...
@@ -152,18 +143,18 @@ func (d *kubeDockerClient) CreateContainer(opts dockertypes.ContainerCreateConfi
...
@@ -152,18 +143,18 @@ func (d *kubeDockerClient) CreateContainer(opts dockertypes.ContainerCreateConfi
func
(
d
*
kubeDockerClient
)
StartContainer
(
id
string
)
error
{
func
(
d
*
kubeDockerClient
)
StartContainer
(
id
string
)
error
{
ctx
,
cancel
:=
d
.
getTimeoutContext
()
ctx
,
cancel
:=
d
.
getTimeoutContext
()
defer
cancel
()
defer
cancel
()
err
:=
d
.
client
.
ContainerStart
(
ctx
,
id
)
err
:=
d
.
client
.
ContainerStart
(
ctx
,
id
,
dockertypes
.
ContainerStartOptions
{}
)
if
ctxErr
:=
contextError
(
ctx
);
ctxErr
!=
nil
{
if
ctxErr
:=
contextError
(
ctx
);
ctxErr
!=
nil
{
return
ctxErr
return
ctxErr
}
}
return
err
return
err
}
}
// Stopping an already stopped container will not cause an error in
engine-v1
.
// Stopping an already stopped container will not cause an error in
dockerapi
.
func
(
d
*
kubeDockerClient
)
StopContainer
(
id
string
,
timeout
int
)
error
{
func
(
d
*
kubeDockerClient
)
StopContainer
(
id
string
,
timeout
time
.
Duration
)
error
{
ctx
,
cancel
:=
d
.
getCustomTimeoutContext
(
time
.
Duration
(
timeout
)
*
time
.
Second
)
ctx
,
cancel
:=
d
.
getCustomTimeoutContext
(
time
out
)
defer
cancel
()
defer
cancel
()
err
:=
d
.
client
.
ContainerStop
(
ctx
,
id
,
timeout
)
err
:=
d
.
client
.
ContainerStop
(
ctx
,
id
,
&
timeout
)
if
ctxErr
:=
contextError
(
ctx
);
ctxErr
!=
nil
{
if
ctxErr
:=
contextError
(
ctx
);
ctxErr
!=
nil
{
return
ctxErr
return
ctxErr
}
}
...
@@ -183,7 +174,7 @@ func (d *kubeDockerClient) RemoveContainer(id string, opts dockertypes.Container
...
@@ -183,7 +174,7 @@ func (d *kubeDockerClient) RemoveContainer(id string, opts dockertypes.Container
func
(
d
*
kubeDockerClient
)
inspectImageRaw
(
ref
string
)
(
*
dockertypes
.
ImageInspect
,
error
)
{
func
(
d
*
kubeDockerClient
)
inspectImageRaw
(
ref
string
)
(
*
dockertypes
.
ImageInspect
,
error
)
{
ctx
,
cancel
:=
d
.
getTimeoutContext
()
ctx
,
cancel
:=
d
.
getTimeoutContext
()
defer
cancel
()
defer
cancel
()
resp
,
_
,
err
:=
d
.
client
.
ImageInspectWithRaw
(
ctx
,
ref
,
true
)
resp
,
_
,
err
:=
d
.
client
.
ImageInspectWithRaw
(
ctx
,
ref
)
if
ctxErr
:=
contextError
(
ctx
);
ctxErr
!=
nil
{
if
ctxErr
:=
contextError
(
ctx
);
ctxErr
!=
nil
{
return
nil
,
ctxErr
return
nil
,
ctxErr
}
}
...
@@ -231,7 +222,7 @@ func (d *kubeDockerClient) ImageHistory(id string) ([]dockertypes.ImageHistory,
...
@@ -231,7 +222,7 @@ func (d *kubeDockerClient) ImageHistory(id string) ([]dockertypes.ImageHistory,
return
resp
,
err
return
resp
,
err
}
}
func
(
d
*
kubeDockerClient
)
ListImages
(
opts
dockertypes
.
ImageListOptions
)
([]
dockertypes
.
Image
,
error
)
{
func
(
d
*
kubeDockerClient
)
ListImages
(
opts
dockertypes
.
ImageListOptions
)
([]
dockertypes
.
Image
Summary
,
error
)
{
ctx
,
cancel
:=
d
.
getTimeoutContext
()
ctx
,
cancel
:=
d
.
getTimeoutContext
()
defer
cancel
()
defer
cancel
()
images
,
err
:=
d
.
client
.
ImageList
(
ctx
,
opts
)
images
,
err
:=
d
.
client
.
ImageList
(
ctx
,
opts
)
...
@@ -429,7 +420,7 @@ func (d *kubeDockerClient) Info() (*dockertypes.Info, error) {
...
@@ -429,7 +420,7 @@ func (d *kubeDockerClient) Info() (*dockertypes.Info, error) {
}
}
// TODO(random-liu): Add unit test for exec and attach functions, just like what go-dockerclient did.
// TODO(random-liu): Add unit test for exec and attach functions, just like what go-dockerclient did.
func
(
d
*
kubeDockerClient
)
CreateExec
(
id
string
,
opts
dockertypes
.
ExecConfig
)
(
*
dockertypes
.
ContainerExecCreate
Response
,
error
)
{
func
(
d
*
kubeDockerClient
)
CreateExec
(
id
string
,
opts
dockertypes
.
ExecConfig
)
(
*
dockertypes
.
ID
Response
,
error
)
{
ctx
,
cancel
:=
d
.
getTimeoutContext
()
ctx
,
cancel
:=
d
.
getTimeoutContext
()
defer
cancel
()
defer
cancel
()
resp
,
err
:=
d
.
client
.
ContainerExecCreate
(
ctx
,
id
,
opts
)
resp
,
err
:=
d
.
client
.
ContainerExecCreate
(
ctx
,
id
,
opts
)
...
@@ -493,7 +484,7 @@ func (d *kubeDockerClient) AttachToContainer(id string, opts dockertypes.Contain
...
@@ -493,7 +484,7 @@ func (d *kubeDockerClient) AttachToContainer(id string, opts dockertypes.Contain
return
d
.
holdHijackedConnection
(
sopts
.
RawTerminal
,
sopts
.
InputStream
,
sopts
.
OutputStream
,
sopts
.
ErrorStream
,
resp
)
return
d
.
holdHijackedConnection
(
sopts
.
RawTerminal
,
sopts
.
InputStream
,
sopts
.
OutputStream
,
sopts
.
ErrorStream
,
resp
)
}
}
func
(
d
*
kubeDockerClient
)
ResizeExecTTY
(
id
string
,
height
,
width
int
)
error
{
func
(
d
*
kubeDockerClient
)
ResizeExecTTY
(
id
string
,
height
,
width
u
int
)
error
{
ctx
,
cancel
:=
d
.
getCancelableContext
()
ctx
,
cancel
:=
d
.
getCancelableContext
()
defer
cancel
()
defer
cancel
()
return
d
.
client
.
ContainerExecResize
(
ctx
,
id
,
dockertypes
.
ResizeOptions
{
return
d
.
client
.
ContainerExecResize
(
ctx
,
id
,
dockertypes
.
ResizeOptions
{
...
@@ -502,7 +493,7 @@ func (d *kubeDockerClient) ResizeExecTTY(id string, height, width int) error {
...
@@ -502,7 +493,7 @@ func (d *kubeDockerClient) ResizeExecTTY(id string, height, width int) error {
})
})
}
}
func
(
d
*
kubeDockerClient
)
ResizeContainerTTY
(
id
string
,
height
,
width
int
)
error
{
func
(
d
*
kubeDockerClient
)
ResizeContainerTTY
(
id
string
,
height
,
width
u
int
)
error
{
ctx
,
cancel
:=
d
.
getCancelableContext
()
ctx
,
cancel
:=
d
.
getCancelableContext
()
defer
cancel
()
defer
cancel
()
return
d
.
client
.
ContainerResize
(
ctx
,
id
,
dockertypes
.
ResizeOptions
{
return
d
.
client
.
ContainerResize
(
ctx
,
id
,
dockertypes
.
ResizeOptions
{
...
...
pkg/kubelet/dockershim/libdocker/legacy_test.go
View file @
bf2ced83
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"hash/adler32"
"hash/adler32"
"testing"
"testing"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
...
...
pkg/kubelet/dockershim/security_context.go
View file @
bf2ced83
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"strings"
"strings"
"github.com/blang/semver"
"github.com/blang/semver"
dockercontainer
"github.com/docker/
engine-
api/types/container"
dockercontainer
"github.com/docker/
docker/
api/types/container"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
knetwork
"k8s.io/kubernetes/pkg/kubelet/network"
knetwork
"k8s.io/kubernetes/pkg/kubelet/network"
...
...
pkg/kubelet/dockershim/security_context_test.go
View file @
bf2ced83
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"testing"
"testing"
"github.com/blang/semver"
"github.com/blang/semver"
dockercontainer
"github.com/docker/
engine-
api/types/container"
dockercontainer
"github.com/docker/
docker/
api/types/container"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
...
...
pkg/kubelet/rkt/BUILD
View file @
bf2ced83
...
@@ -46,7 +46,7 @@ go_library(
...
@@ -46,7 +46,7 @@ go_library(
"//vendor/github.com/coreos/go-systemd/dbus:go_default_library",
"//vendor/github.com/coreos/go-systemd/dbus:go_default_library",
"//vendor/github.com/coreos/go-systemd/unit:go_default_library",
"//vendor/github.com/coreos/go-systemd/unit:go_default_library",
"//vendor/github.com/coreos/rkt/api/v1alpha:go_default_library",
"//vendor/github.com/coreos/rkt/api/v1alpha:go_default_library",
"//vendor/github.com/docker/
engine-
api/types:go_default_library",
"//vendor/github.com/docker/
docker/
api/types:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",
...
...
pkg/kubelet/rkt/image.go
View file @
bf2ced83
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
appcschema
"github.com/appc/spec/schema"
appcschema
"github.com/appc/spec/schema"
appctypes
"github.com/appc/spec/schema/types"
appctypes
"github.com/appc/spec/schema/types"
rktapi
"github.com/coreos/rkt/api/v1alpha"
rktapi
"github.com/coreos/rkt/api/v1alpha"
dockertypes
"github.com/docker/
engine-
api/types"
dockertypes
"github.com/docker/
docker/
api/types"
"github.com/golang/glog"
"github.com/golang/glog"
"golang.org/x/net/context"
"golang.org/x/net/context"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
...
...
test/e2e_node/system/BUILD
View file @
bf2ced83
...
@@ -23,8 +23,8 @@ go_library(
...
@@ -23,8 +23,8 @@ go_library(
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/github.com/docker/
engine-api/client
:go_default_library",
"//vendor/github.com/docker/
docker/api/types
:go_default_library",
"//vendor/github.com/docker/
engine-api/types
:go_default_library",
"//vendor/github.com/docker/
docker/client
:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
...
@@ -43,7 +43,7 @@ go_test(
...
@@ -43,7 +43,7 @@ go_test(
library = ":go_default_library",
library = ":go_default_library",
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//vendor/github.com/docker/
engine-
api/types:go_default_library",
"//vendor/github.com/docker/
docker/
api/types:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
],
)
)
...
...
test/e2e_node/system/docker_validator.go
View file @
bf2ced83
...
@@ -20,8 +20,8 @@ import (
...
@@ -20,8 +20,8 @@ import (
"fmt"
"fmt"
"regexp"
"regexp"
"github.com/docker/
engine-api/client
"
"github.com/docker/
docker/api/types
"
"github.com/docker/
engine-api/types
"
"github.com/docker/
docker/client
"
"golang.org/x/net/context"
"golang.org/x/net/context"
)
)
...
...
test/e2e_node/system/docker_validator_test.go
View file @
bf2ced83
...
@@ -19,7 +19,7 @@ package system
...
@@ -19,7 +19,7 @@ package system
import
(
import
(
"testing"
"testing"
"github.com/docker/
engine-
api/types"
"github.com/docker/
docker/
api/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment