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
b969599d
Commit
b969599d
authored
Jan 05, 2016
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix fake docker client to corretly report status of containers
parent
7ca0fa43
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
convert.go
pkg/kubelet/dockertools/convert.go
+6
-2
fake_docker_client.go
pkg/kubelet/dockertools/fake_docker_client.go
+10
-0
No files found.
pkg/kubelet/dockertools/convert.go
View file @
b969599d
...
...
@@ -28,14 +28,18 @@ import (
// This file contains helper functions to convert docker API types to runtime
// (kubecontainer) types.
const
(
statusRunningPrefix
=
"Up"
statusExitedPrefix
=
"Exited"
)
func
mapState
(
state
string
)
kubecontainer
.
ContainerState
{
// Parse the state string in docker.APIContainers. This could break when
// we upgrade docker.
switch
{
case
strings
.
HasPrefix
(
state
,
"Up"
)
:
case
strings
.
HasPrefix
(
state
,
statusRunningPrefix
)
:
return
kubecontainer
.
ContainerStateRunning
case
strings
.
HasPrefix
(
state
,
"Exited"
)
:
case
strings
.
HasPrefix
(
state
,
statusExitedPrefix
)
:
return
kubecontainer
.
ContainerStateExited
default
:
return
kubecontainer
.
ContainerStateUnknown
...
...
pkg/kubelet/dockertools/fake_docker_client.go
View file @
b969599d
...
...
@@ -282,6 +282,7 @@ func (f *FakeDockerClient) StartContainer(id string, hostConfig *docker.HostConf
}
container
.
NetworkSettings
=
&
docker
.
NetworkSettings
{
IPAddress
:
"2.3.4.5"
}
f
.
ContainerMap
[
id
]
=
container
f
.
updateContainerStatus
(
id
,
statusRunningPrefix
)
f
.
normalSleep
(
200
,
50
,
50
)
return
nil
}
...
...
@@ -322,6 +323,7 @@ func (f *FakeDockerClient) StopContainer(id string, timeout uint) error {
container
.
State
.
Running
=
false
}
f
.
ContainerMap
[
id
]
=
container
f
.
updateContainerStatus
(
id
,
statusExitedPrefix
)
f
.
normalSleep
(
200
,
50
,
50
)
return
nil
}
...
...
@@ -412,6 +414,14 @@ func (f *FakeDockerClient) RemoveImage(image string) error {
return
err
}
func
(
f
*
FakeDockerClient
)
updateContainerStatus
(
id
,
status
string
)
{
for
i
:=
range
f
.
ContainerList
{
if
f
.
ContainerList
[
i
]
.
ID
==
id
{
f
.
ContainerList
[
i
]
.
Status
=
status
}
}
}
// FakeDockerPuller is a stub implementation of DockerPuller.
type
FakeDockerPuller
struct
{
sync
.
Mutex
...
...
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