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
5eb088eb
Commit
5eb088eb
authored
Aug 08, 2016
by
Kubernetes Submit Queue
Committed by
GitHub
Aug 08, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #30172 from yujuhong/interface_cleanup
Automatic merge from submit-queue Repalce rawContainerID with containerID
parents
06479bde
93f0c5a8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
40 deletions
+40
-40
services.go
pkg/kubelet/api/services.go
+5
-5
fake_runtime_service.go
pkg/kubelet/api/testing/fake_runtime_service.go
+12
-12
docker_container.go
pkg/kubelet/dockershim/docker_container.go
+10
-10
remote_runtime.go
pkg/kubelet/remote/remote_runtime.go
+13
-13
No files found.
pkg/kubelet/api/services.go
View file @
5eb088eb
...
...
@@ -43,17 +43,17 @@ type RuntimeService interface {
// CreateContainer creates a new container in specified PodSandbox.
CreateContainer
(
podSandboxID
string
,
config
*
runtimeApi
.
ContainerConfig
,
sandboxConfig
*
runtimeApi
.
PodSandboxConfig
)
(
string
,
error
)
// StartContainer starts the container.
StartContainer
(
rawC
ontainerID
string
)
error
StartContainer
(
c
ontainerID
string
)
error
// StopContainer stops a running container with a grace period (i.e., timeout).
StopContainer
(
rawC
ontainerID
string
,
timeout
int64
)
error
StopContainer
(
c
ontainerID
string
,
timeout
int64
)
error
// RemoveContainer removes the container.
RemoveContainer
(
rawC
ontainerID
string
)
error
RemoveContainer
(
c
ontainerID
string
)
error
// ListContainers lists all containers by filters.
ListContainers
(
filter
*
runtimeApi
.
ContainerFilter
)
([]
*
runtimeApi
.
Container
,
error
)
// ContainerStatus returns the status of the container.
ContainerStatus
(
rawC
ontainerID
string
)
(
*
runtimeApi
.
ContainerStatus
,
error
)
ContainerStatus
(
c
ontainerID
string
)
(
*
runtimeApi
.
ContainerStatus
,
error
)
// Exec executes a command in the container.
Exec
(
rawC
ontainerID
string
,
cmd
[]
string
,
tty
bool
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
)
error
Exec
(
c
ontainerID
string
,
cmd
[]
string
,
tty
bool
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
)
error
}
// ImageManagerService interface should be implemented by a container image
...
...
pkg/kubelet/api/testing/fake_runtime_service.go
View file @
5eb088eb
...
...
@@ -244,15 +244,15 @@ func (r *FakeRuntimeService) CreateContainer(podSandboxID string, config *runtim
return
containerID
,
nil
}
func
(
r
*
FakeRuntimeService
)
StartContainer
(
rawC
ontainerID
string
)
error
{
func
(
r
*
FakeRuntimeService
)
StartContainer
(
c
ontainerID
string
)
error
{
r
.
Lock
()
defer
r
.
Unlock
()
r
.
Called
=
append
(
r
.
Called
,
"StartContainer"
)
c
,
ok
:=
r
.
Containers
[
rawC
ontainerID
]
c
,
ok
:=
r
.
Containers
[
c
ontainerID
]
if
!
ok
{
return
fmt
.
Errorf
(
"container %s not found"
,
rawC
ontainerID
)
return
fmt
.
Errorf
(
"container %s not found"
,
c
ontainerID
)
}
// Set container to running.
...
...
@@ -264,15 +264,15 @@ func (r *FakeRuntimeService) StartContainer(rawContainerID string) error {
return
nil
}
func
(
r
*
FakeRuntimeService
)
StopContainer
(
rawC
ontainerID
string
,
timeout
int64
)
error
{
func
(
r
*
FakeRuntimeService
)
StopContainer
(
c
ontainerID
string
,
timeout
int64
)
error
{
r
.
Lock
()
defer
r
.
Unlock
()
r
.
Called
=
append
(
r
.
Called
,
"StopContainer"
)
c
,
ok
:=
r
.
Containers
[
rawC
ontainerID
]
c
,
ok
:=
r
.
Containers
[
c
ontainerID
]
if
!
ok
{
return
fmt
.
Errorf
(
"container %q not found"
,
rawC
ontainerID
)
return
fmt
.
Errorf
(
"container %q not found"
,
c
ontainerID
)
}
// Set container to exited state.
...
...
@@ -284,14 +284,14 @@ func (r *FakeRuntimeService) StopContainer(rawContainerID string, timeout int64)
return
nil
}
func
(
r
*
FakeRuntimeService
)
RemoveContainer
(
rawC
ontainerID
string
)
error
{
func
(
r
*
FakeRuntimeService
)
RemoveContainer
(
c
ontainerID
string
)
error
{
r
.
Lock
()
defer
r
.
Unlock
()
r
.
Called
=
append
(
r
.
Called
,
"RemoveContainer"
)
// Remove the container
delete
(
r
.
Containers
,
rawC
ontainerID
)
delete
(
r
.
Containers
,
c
ontainerID
)
return
nil
}
...
...
@@ -335,15 +335,15 @@ func (r *FakeRuntimeService) ListContainers(filter *runtimeApi.ContainerFilter)
return
result
,
nil
}
func
(
r
*
FakeRuntimeService
)
ContainerStatus
(
rawC
ontainerID
string
)
(
*
runtimeApi
.
ContainerStatus
,
error
)
{
func
(
r
*
FakeRuntimeService
)
ContainerStatus
(
c
ontainerID
string
)
(
*
runtimeApi
.
ContainerStatus
,
error
)
{
r
.
Lock
()
defer
r
.
Unlock
()
r
.
Called
=
append
(
r
.
Called
,
"ContainerStatus"
)
c
,
ok
:=
r
.
Containers
[
rawC
ontainerID
]
c
,
ok
:=
r
.
Containers
[
c
ontainerID
]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"container %q not found"
,
rawC
ontainerID
)
return
nil
,
fmt
.
Errorf
(
"container %q not found"
,
c
ontainerID
)
}
return
&
runtimeApi
.
ContainerStatus
{
...
...
@@ -363,7 +363,7 @@ func (r *FakeRuntimeService) ContainerStatus(rawContainerID string) (*runtimeApi
},
nil
}
func
(
r
*
FakeRuntimeService
)
Exec
(
rawC
ontainerID
string
,
cmd
[]
string
,
tty
bool
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
)
error
{
func
(
r
*
FakeRuntimeService
)
Exec
(
c
ontainerID
string
,
cmd
[]
string
,
tty
bool
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
)
error
{
r
.
Lock
()
defer
r
.
Unlock
()
...
...
pkg/kubelet/dockershim/docker_container.go
View file @
5eb088eb
...
...
@@ -174,19 +174,19 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi
}
// StartContainer starts the container.
func
(
ds
*
dockerService
)
StartContainer
(
rawC
ontainerID
string
)
error
{
return
ds
.
client
.
StartContainer
(
rawC
ontainerID
)
func
(
ds
*
dockerService
)
StartContainer
(
c
ontainerID
string
)
error
{
return
ds
.
client
.
StartContainer
(
c
ontainerID
)
}
// StopContainer stops a running container with a grace period (i.e., timeout).
func
(
ds
*
dockerService
)
StopContainer
(
rawC
ontainerID
string
,
timeout
int64
)
error
{
return
ds
.
client
.
StopContainer
(
rawC
ontainerID
,
int
(
timeout
))
func
(
ds
*
dockerService
)
StopContainer
(
c
ontainerID
string
,
timeout
int64
)
error
{
return
ds
.
client
.
StopContainer
(
c
ontainerID
,
int
(
timeout
))
}
// RemoveContainer removes the container.
// TODO: If a container is still running, should we forcibly remove it?
func
(
ds
*
dockerService
)
RemoveContainer
(
rawC
ontainerID
string
)
error
{
return
ds
.
client
.
RemoveContainer
(
rawC
ontainerID
,
dockertypes
.
ContainerRemoveOptions
{
RemoveVolumes
:
true
})
func
(
ds
*
dockerService
)
RemoveContainer
(
c
ontainerID
string
)
error
{
return
ds
.
client
.
RemoveContainer
(
c
ontainerID
,
dockertypes
.
ContainerRemoveOptions
{
RemoveVolumes
:
true
})
}
func
getContainerTimestamps
(
r
*
dockertypes
.
ContainerJSON
)
(
time
.
Time
,
time
.
Time
,
time
.
Time
,
error
)
{
...
...
@@ -209,8 +209,8 @@ func getContainerTimestamps(r *dockertypes.ContainerJSON) (time.Time, time.Time,
}
// ContainerStatus returns the container status.
func
(
ds
*
dockerService
)
ContainerStatus
(
rawC
ontainerID
string
)
(
*
runtimeApi
.
ContainerStatus
,
error
)
{
r
,
err
:=
ds
.
client
.
InspectContainer
(
rawC
ontainerID
)
func
(
ds
*
dockerService
)
ContainerStatus
(
c
ontainerID
string
)
(
*
runtimeApi
.
ContainerStatus
,
error
)
{
r
,
err
:=
ds
.
client
.
InspectContainer
(
c
ontainerID
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -218,7 +218,7 @@ func (ds *dockerService) ContainerStatus(rawContainerID string) (*runtimeApi.Con
// Parse the timstamps.
createdAt
,
startedAt
,
finishedAt
,
err
:=
getContainerTimestamps
(
r
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to parse timestamp for container %q: %v"
,
rawC
ontainerID
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to parse timestamp for container %q: %v"
,
c
ontainerID
,
err
)
}
// Convert the mounts.
...
...
@@ -295,6 +295,6 @@ func (ds *dockerService) ContainerStatus(rawContainerID string) (*runtimeApi.Con
// Exec execute a command in the container.
// TODO: Need to handle terminal resizing before implementing this function.
// https://github.com/kubernetes/kubernetes/issues/29579.
func
(
ds
*
dockerService
)
Exec
(
rawC
ontainerID
string
,
cmd
[]
string
,
tty
bool
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
)
error
{
func
(
ds
*
dockerService
)
Exec
(
c
ontainerID
string
,
cmd
[]
string
,
tty
bool
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
)
error
{
return
fmt
.
Errorf
(
"not implemented"
)
}
pkg/kubelet/remote/remote_runtime.go
View file @
5eb088eb
...
...
@@ -165,15 +165,15 @@ func (r *RemoteRuntimeService) CreateContainer(podSandBoxID string, config *runt
}
// StartContainer starts the container.
func
(
r
*
RemoteRuntimeService
)
StartContainer
(
rawC
ontainerID
string
)
error
{
func
(
r
*
RemoteRuntimeService
)
StartContainer
(
c
ontainerID
string
)
error
{
ctx
,
cancel
:=
getContextWithTimeout
(
r
.
timeout
)
defer
cancel
()
_
,
err
:=
r
.
runtimeClient
.
StartContainer
(
ctx
,
&
runtimeApi
.
StartContainerRequest
{
ContainerId
:
&
rawC
ontainerID
,
ContainerId
:
&
c
ontainerID
,
})
if
err
!=
nil
{
glog
.
Errorf
(
"StartContainer %q from runtime service failed: %v"
,
rawC
ontainerID
,
err
)
glog
.
Errorf
(
"StartContainer %q from runtime service failed: %v"
,
c
ontainerID
,
err
)
return
err
}
...
...
@@ -181,16 +181,16 @@ func (r *RemoteRuntimeService) StartContainer(rawContainerID string) error {
}
// StopContainer stops a running container with a grace period (i.e., timeout).
func
(
r
*
RemoteRuntimeService
)
StopContainer
(
rawC
ontainerID
string
,
timeout
int64
)
error
{
func
(
r
*
RemoteRuntimeService
)
StopContainer
(
c
ontainerID
string
,
timeout
int64
)
error
{
ctx
,
cancel
:=
getContextWithTimeout
(
r
.
timeout
)
defer
cancel
()
_
,
err
:=
r
.
runtimeClient
.
StopContainer
(
ctx
,
&
runtimeApi
.
StopContainerRequest
{
ContainerId
:
&
rawC
ontainerID
,
ContainerId
:
&
c
ontainerID
,
Timeout
:
&
timeout
,
})
if
err
!=
nil
{
glog
.
Errorf
(
"StopContainer %q from runtime service failed: %v"
,
rawC
ontainerID
,
err
)
glog
.
Errorf
(
"StopContainer %q from runtime service failed: %v"
,
c
ontainerID
,
err
)
return
err
}
...
...
@@ -199,15 +199,15 @@ func (r *RemoteRuntimeService) StopContainer(rawContainerID string, timeout int6
// RemoveContainer removes the container. If the container is running, the container
// should be forced to removal.
func
(
r
*
RemoteRuntimeService
)
RemoveContainer
(
rawC
ontainerID
string
)
error
{
func
(
r
*
RemoteRuntimeService
)
RemoveContainer
(
c
ontainerID
string
)
error
{
ctx
,
cancel
:=
getContextWithTimeout
(
r
.
timeout
)
defer
cancel
()
_
,
err
:=
r
.
runtimeClient
.
RemoveContainer
(
ctx
,
&
runtimeApi
.
RemoveContainerRequest
{
ContainerId
:
&
rawC
ontainerID
,
ContainerId
:
&
c
ontainerID
,
})
if
err
!=
nil
{
glog
.
Errorf
(
"RemoveContainer %q from runtime service failed: %v"
,
rawC
ontainerID
,
err
)
glog
.
Errorf
(
"RemoveContainer %q from runtime service failed: %v"
,
c
ontainerID
,
err
)
return
err
}
...
...
@@ -231,15 +231,15 @@ func (r *RemoteRuntimeService) ListContainers(filter *runtimeApi.ContainerFilter
}
// ContainerStatus returns the container status.
func
(
r
*
RemoteRuntimeService
)
ContainerStatus
(
rawC
ontainerID
string
)
(
*
runtimeApi
.
ContainerStatus
,
error
)
{
func
(
r
*
RemoteRuntimeService
)
ContainerStatus
(
c
ontainerID
string
)
(
*
runtimeApi
.
ContainerStatus
,
error
)
{
ctx
,
cancel
:=
getContextWithTimeout
(
r
.
timeout
)
defer
cancel
()
resp
,
err
:=
r
.
runtimeClient
.
ContainerStatus
(
ctx
,
&
runtimeApi
.
ContainerStatusRequest
{
ContainerId
:
&
rawC
ontainerID
,
ContainerId
:
&
c
ontainerID
,
})
if
err
!=
nil
{
glog
.
Errorf
(
"ContainerStatus %q from runtime service failed: %v"
,
rawC
ontainerID
,
err
)
glog
.
Errorf
(
"ContainerStatus %q from runtime service failed: %v"
,
c
ontainerID
,
err
)
return
nil
,
err
}
...
...
@@ -248,6 +248,6 @@ func (r *RemoteRuntimeService) ContainerStatus(rawContainerID string) (*runtimeA
// Exec executes a command in the container.
// TODO: support terminal resizing for exec, refer https://github.com/kubernetes/kubernetes/issues/29579.
func
(
r
*
RemoteRuntimeService
)
Exec
(
rawC
ontainerID
string
,
cmd
[]
string
,
tty
bool
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
)
error
{
func
(
r
*
RemoteRuntimeService
)
Exec
(
c
ontainerID
string
,
cmd
[]
string
,
tty
bool
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
WriteCloser
)
error
{
return
fmt
.
Errorf
(
"Not implemented"
)
}
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