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
1459a17d
Commit
1459a17d
authored
Mar 29, 2016
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove nsinit related code and bump up minimum docker apiversion
parent
812b9a47
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
75 deletions
+3
-75
runtime.go
pkg/kubelet/container/runtime.go
+1
-1
docker_test.go
pkg/kubelet/dockertools/docker_test.go
+0
-33
manager.go
pkg/kubelet/dockertools/manager.go
+2
-41
No files found.
pkg/kubelet/container/runtime.go
View file @
1459a17d
...
...
@@ -103,7 +103,7 @@ type ContainerAttacher interface {
// CommandRunner encapsulates the command runner interfaces for testability.
type
ContainerCommandRunner
interface
{
// TODO(vmarmol): Merge RunInContainer and ExecInContainer.
// Runs the command in the container of the specified pod
using nsinit
.
// Runs the command in the container of the specified pod.
RunInContainer
(
containerID
ContainerID
,
cmd
[]
string
)
([]
byte
,
error
)
// Runs the command in the container of the specified pod using nsenter.
// Attaches the processes stdin, stdout, and stderr. Optionally uses a
...
...
pkg/kubelet/dockertools/docker_test.go
View file @
1459a17d
...
...
@@ -177,39 +177,6 @@ func TestVersion(t *testing.T) {
}
}
func
TestExecSupportExists
(
t
*
testing
.
T
)
{
fakeDocker
:=
&
FakeDockerClient
{
VersionInfo
:
docker
.
Env
{
"Version=1.3.0"
,
"ApiVersion=1.15"
}}
runner
:=
&
DockerManager
{
client
:
fakeDocker
}
useNativeExec
,
err
:=
runner
.
nativeExecSupportExists
()
if
err
!=
nil
{
t
.
Errorf
(
"got error while checking for exec support - %s"
,
err
)
}
if
!
useNativeExec
{
t
.
Errorf
(
"invalid exec support check output. Expected true"
)
}
}
func
TestExecSupportNotExists
(
t
*
testing
.
T
)
{
fakeDocker
:=
&
FakeDockerClient
{
VersionInfo
:
docker
.
Env
{
"Version=1.1.2"
,
"ApiVersion=1.14"
}}
runner
:=
&
DockerManager
{
client
:
fakeDocker
}
useNativeExec
,
_
:=
runner
.
nativeExecSupportExists
()
if
useNativeExec
{
t
.
Errorf
(
"invalid exec support check output."
)
}
}
func
TestDockerContainerCommand
(
t
*
testing
.
T
)
{
runner
:=
&
DockerManager
{}
containerID
:=
kubecontainer
.
DockerID
(
"1234"
)
.
ContainerID
()
command
:=
[]
string
{
"ls"
}
cmd
,
_
:=
runner
.
getRunInContainerCommand
(
containerID
,
command
)
if
cmd
.
Dir
!=
"/var/lib/docker/execdriver/native/"
+
containerID
.
ID
{
t
.
Errorf
(
"unexpected command CWD: %s"
,
cmd
.
Dir
)
}
if
!
reflect
.
DeepEqual
(
cmd
.
Args
,
[]
string
{
"/usr/sbin/nsinit"
,
"exec"
,
"ls"
})
{
t
.
Errorf
(
"unexpected command args: %s"
,
cmd
.
Args
)
}
}
func
TestParseImageName
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
imageName
string
...
...
pkg/kubelet/dockertools/manager.go
View file @
1459a17d
...
...
@@ -60,7 +60,7 @@ import (
const
(
DockerType
=
"docker"
minimumDockerAPIVersion
=
"1.
18
"
minimumDockerAPIVersion
=
"1.
20
"
// ndots specifies the minimum number of dots that a domain name must contain for the resolver to consider it as FQDN (fully-qualified)
// we want to able to consider SRV lookup names like _dns._udp.kube-dns.default.svc to be considered relative.
...
...
@@ -964,21 +964,6 @@ func (dm *DockerManager) checkVersionCompatibility() error {
return
nil
}
// The first version of docker that supports exec natively is 1.3.0 == API 1.15
var
dockerAPIVersionWithExec
=
"1.15"
func
(
dm
*
DockerManager
)
nativeExecSupportExists
()
(
bool
,
error
)
{
version
,
err
:=
dm
.
APIVersion
()
if
err
!=
nil
{
return
false
,
err
}
result
,
err
:=
version
.
Compare
(
dockerAPIVersionWithExec
)
if
result
>=
0
{
return
true
,
err
}
return
false
,
err
}
func
(
dm
*
DockerManager
)
defaultSecurityOpt
()
([]
string
,
error
)
{
version
,
err
:=
dm
.
APIVersion
()
if
err
!=
nil
{
...
...
@@ -995,32 +980,8 @@ func (dm *DockerManager) defaultSecurityOpt() ([]string, error) {
return
nil
,
nil
}
func
(
dm
*
DockerManager
)
getRunInContainerCommand
(
containerID
kubecontainer
.
ContainerID
,
cmd
[]
string
)
(
*
exec
.
Cmd
,
error
)
{
args
:=
append
([]
string
{
"exec"
},
cmd
...
)
command
:=
exec
.
Command
(
"/usr/sbin/nsinit"
,
args
...
)
command
.
Dir
=
fmt
.
Sprintf
(
"/var/lib/docker/execdriver/native/%s"
,
containerID
.
ID
)
return
command
,
nil
}
func
(
dm
*
DockerManager
)
runInContainerUsingNsinit
(
containerID
kubecontainer
.
ContainerID
,
cmd
[]
string
)
([]
byte
,
error
)
{
c
,
err
:=
dm
.
getRunInContainerCommand
(
containerID
,
cmd
)
if
err
!=
nil
{
return
nil
,
err
}
return
c
.
CombinedOutput
()
}
// RunInContainer uses nsinit to run the command inside the container identified by containerID
// RunInContainer run the command inside the container identified by containerID
func
(
dm
*
DockerManager
)
RunInContainer
(
containerID
kubecontainer
.
ContainerID
,
cmd
[]
string
)
([]
byte
,
error
)
{
// If native exec support does not exist in the local docker daemon use nsinit.
useNativeExec
,
err
:=
dm
.
nativeExecSupportExists
()
if
err
!=
nil
{
return
nil
,
err
}
if
!
useNativeExec
{
glog
.
V
(
2
)
.
Infof
(
"Using nsinit to run the command %+v inside container %s"
,
cmd
,
containerID
)
return
dm
.
runInContainerUsingNsinit
(
containerID
,
cmd
)
}
glog
.
V
(
2
)
.
Infof
(
"Using docker native exec to run cmd %+v inside container %s"
,
cmd
,
containerID
)
createOpts
:=
docker
.
CreateExecOptions
{
Container
:
containerID
.
ID
,
...
...
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