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
38d8da12
Commit
38d8da12
authored
Mar 08, 2017
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FakeDockerClient: add creation timestamp
This is necessary for kubemark to work correctly.
parent
d6ae61c3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
8 deletions
+11
-8
docker_container_test.go
pkg/kubelet/dockershim/docker_container_test.go
+2
-2
docker_sandbox_test.go
pkg/kubelet/dockershim/docker_sandbox_test.go
+2
-2
convert.go
pkg/kubelet/dockertools/convert.go
+1
-0
fake_docker_client.go
pkg/kubelet/dockertools/fake_docker_client.go
+6
-4
No files found.
pkg/kubelet/dockershim/docker_container_test.go
View file @
38d8da12
...
...
@@ -47,7 +47,7 @@ func makeContainerConfig(sConfig *runtimeapi.PodSandboxConfig, name, image strin
// TestListContainers creates several containers and then list them to check
// whether the correct metadatas, states, and labels are returned.
func
TestListContainers
(
t
*
testing
.
T
)
{
ds
,
_
,
_
:=
newTestDockerService
()
ds
,
_
,
fakeClock
:=
newTestDockerService
()
podName
,
namespace
:=
"foo"
,
"bar"
containerName
,
image
:=
"sidecar"
,
"logger"
...
...
@@ -66,7 +66,7 @@ func TestListContainers(t *testing.T) {
expected
:=
[]
*
runtimeapi
.
Container
{}
state
:=
runtimeapi
.
ContainerState_CONTAINER_RUNNING
var
createdAt
int64
=
0
var
createdAt
int64
=
fakeClock
.
Now
()
.
UnixNano
()
for
i
:=
range
configs
{
// We don't care about the sandbox id; pass a bogus one.
sandboxID
:=
fmt
.
Sprintf
(
"sandboxid%d"
,
i
)
...
...
pkg/kubelet/dockershim/docker_sandbox_test.go
View file @
38d8da12
...
...
@@ -52,7 +52,7 @@ func makeSandboxConfigWithLabelsAndAnnotations(name, namespace, uid string, atte
// TestListSandboxes creates several sandboxes and then list them to check
// whether the correct metadatas, states, and labels are returned.
func
TestListSandboxes
(
t
*
testing
.
T
)
{
ds
,
_
,
_
:=
newTestDockerService
()
ds
,
_
,
fakeClock
:=
newTestDockerService
()
name
,
namespace
:=
"foo"
,
"bar"
configs
:=
[]
*
runtimeapi
.
PodSandboxConfig
{}
for
i
:=
0
;
i
<
3
;
i
++
{
...
...
@@ -66,7 +66,7 @@ func TestListSandboxes(t *testing.T) {
expected
:=
[]
*
runtimeapi
.
PodSandbox
{}
state
:=
runtimeapi
.
PodSandboxState_SANDBOX_READY
var
createdAt
int64
=
0
var
createdAt
int64
=
fakeClock
.
Now
()
.
UnixNano
()
for
i
:=
range
configs
{
id
,
err
:=
ds
.
RunPodSandbox
(
configs
[
i
])
assert
.
NoError
(
t
,
err
)
...
...
pkg/kubelet/dockertools/convert.go
View file @
38d8da12
...
...
@@ -28,6 +28,7 @@ import (
// (kubecontainer) types.
const
(
statusRunningPrefix
=
"Up"
statusCreatedPrefix
=
"Created"
statusExitedPrefix
=
"Exited"
)
...
...
pkg/kubelet/dockertools/fake_docker_client.go
View file @
38d8da12
...
...
@@ -516,12 +516,13 @@ func (f *FakeDockerClient) CreateContainer(c dockertypes.ContainerCreateConfig)
name
:=
"/"
+
c
.
Name
id
:=
GetFakeContainerID
(
name
)
f
.
appendContainerTrace
(
"Created"
,
id
)
timestamp
:=
f
.
Clock
.
Now
()
// The newest container should be in front, because we assume so in GetPodStatus()
f
.
RunningContainerList
=
append
([]
dockertypes
.
Container
{
{
ID
:
id
,
Names
:
[]
string
{
name
},
Image
:
c
.
Config
.
Image
,
Labels
:
c
.
Config
.
Labels
},
{
ID
:
id
,
Names
:
[]
string
{
name
},
Image
:
c
.
Config
.
Image
,
Created
:
timestamp
.
Unix
(),
State
:
statusCreatedPrefix
,
Labels
:
c
.
Config
.
Labels
},
},
f
.
RunningContainerList
...
)
f
.
ContainerMap
[
id
]
=
convertFakeContainer
(
&
FakeContainer
{
ID
:
id
,
Name
:
name
,
Config
:
c
.
Config
,
HostConfig
:
c
.
HostConfig
,
CreatedAt
:
f
.
Clock
.
Now
()
})
ID
:
id
,
Name
:
name
,
Config
:
c
.
Config
,
HostConfig
:
c
.
HostConfig
,
CreatedAt
:
timestamp
})
f
.
normalSleep
(
100
,
25
,
25
)
...
...
@@ -539,12 +540,13 @@ func (f *FakeDockerClient) StartContainer(id string) error {
}
f
.
appendContainerTrace
(
"Started"
,
id
)
container
,
ok
:=
f
.
ContainerMap
[
id
]
timestamp
:=
f
.
Clock
.
Now
()
if
!
ok
{
container
=
convertFakeContainer
(
&
FakeContainer
{
ID
:
id
,
Name
:
id
})
container
=
convertFakeContainer
(
&
FakeContainer
{
ID
:
id
,
Name
:
id
,
CreatedAt
:
timestamp
})
}
container
.
State
.
Running
=
true
container
.
State
.
Pid
=
os
.
Getpid
()
container
.
State
.
StartedAt
=
dockerTimestampToString
(
f
.
Clock
.
Now
()
)
container
.
State
.
StartedAt
=
dockerTimestampToString
(
timestamp
)
container
.
NetworkSettings
.
IPAddress
=
"2.3.4.5"
f
.
ContainerMap
[
id
]
=
container
f
.
updateContainerStatus
(
id
,
statusRunningPrefix
)
...
...
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