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
651206fd
Commit
651206fd
authored
Jan 11, 2016
by
Saad Ali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19393 from yujuhong/fix_dockerclient
Fix fake docker client to corretly report status of containers
parents
f5ea4f46
b969599d
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 @
651206fd
...
@@ -28,14 +28,18 @@ import (
...
@@ -28,14 +28,18 @@ 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
// (kubecontainer) types.
// (kubecontainer) types.
const
(
statusRunningPrefix
=
"Up"
statusExitedPrefix
=
"Exited"
)
func
mapState
(
state
string
)
kubecontainer
.
ContainerState
{
func
mapState
(
state
string
)
kubecontainer
.
ContainerState
{
// Parse the state string in docker.APIContainers. This could break when
// Parse the state string in docker.APIContainers. This could break when
// we upgrade docker.
// we upgrade docker.
switch
{
switch
{
case
strings
.
HasPrefix
(
state
,
"Up"
)
:
case
strings
.
HasPrefix
(
state
,
statusRunningPrefix
)
:
return
kubecontainer
.
ContainerStateRunning
return
kubecontainer
.
ContainerStateRunning
case
strings
.
HasPrefix
(
state
,
"Exited"
)
:
case
strings
.
HasPrefix
(
state
,
statusExitedPrefix
)
:
return
kubecontainer
.
ContainerStateExited
return
kubecontainer
.
ContainerStateExited
default
:
default
:
return
kubecontainer
.
ContainerStateUnknown
return
kubecontainer
.
ContainerStateUnknown
...
...
pkg/kubelet/dockertools/fake_docker_client.go
View file @
651206fd
...
@@ -282,6 +282,7 @@ func (f *FakeDockerClient) StartContainer(id string, hostConfig *docker.HostConf
...
@@ -282,6 +282,7 @@ func (f *FakeDockerClient) StartContainer(id string, hostConfig *docker.HostConf
}
}
container
.
NetworkSettings
=
&
docker
.
NetworkSettings
{
IPAddress
:
"2.3.4.5"
}
container
.
NetworkSettings
=
&
docker
.
NetworkSettings
{
IPAddress
:
"2.3.4.5"
}
f
.
ContainerMap
[
id
]
=
container
f
.
ContainerMap
[
id
]
=
container
f
.
updateContainerStatus
(
id
,
statusRunningPrefix
)
f
.
normalSleep
(
200
,
50
,
50
)
f
.
normalSleep
(
200
,
50
,
50
)
return
nil
return
nil
}
}
...
@@ -322,6 +323,7 @@ func (f *FakeDockerClient) StopContainer(id string, timeout uint) error {
...
@@ -322,6 +323,7 @@ func (f *FakeDockerClient) StopContainer(id string, timeout uint) error {
container
.
State
.
Running
=
false
container
.
State
.
Running
=
false
}
}
f
.
ContainerMap
[
id
]
=
container
f
.
ContainerMap
[
id
]
=
container
f
.
updateContainerStatus
(
id
,
statusExitedPrefix
)
f
.
normalSleep
(
200
,
50
,
50
)
f
.
normalSleep
(
200
,
50
,
50
)
return
nil
return
nil
}
}
...
@@ -412,6 +414,14 @@ func (f *FakeDockerClient) RemoveImage(image string) error {
...
@@ -412,6 +414,14 @@ func (f *FakeDockerClient) RemoveImage(image string) error {
return
err
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.
// FakeDockerPuller is a stub implementation of DockerPuller.
type
FakeDockerPuller
struct
{
type
FakeDockerPuller
struct
{
sync
.
Mutex
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