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
76056a47
Commit
76056a47
authored
Oct 06, 2016
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the timestamp unit to nanosecond.
parent
a6aad159
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
17 deletions
+25
-17
api.pb.go
pkg/kubelet/api/v1alpha1/runtime/api.pb.go
+6
-6
api.proto
pkg/kubelet/api/v1alpha1/runtime/api.proto
+6
-6
convert.go
pkg/kubelet/dockershim/convert.go
+7
-1
docker_container_test.go
pkg/kubelet/dockershim/docker_container_test.go
+2
-0
kuberuntime_container.go
pkg/kubelet/kuberuntime/kuberuntime_container.go
+3
-3
kuberuntime_gc.go
pkg/kubelet/kuberuntime/kuberuntime_gc.go
+1
-1
No files found.
pkg/kubelet/api/v1alpha1/runtime/api.pb.go
View file @
76056a47
...
...
@@ -812,7 +812,7 @@ type PodSandboxStatus struct {
Metadata
*
PodSandboxMetadata
`protobuf:"bytes,2,opt,name=metadata" json:"metadata,omitempty"`
// State of the sandbox.
State
*
PodSandBoxState
`protobuf:"varint,3,opt,name=state,enum=runtime.PodSandBoxState" json:"state,omitempty"`
// Creation timestamp of the sandbox
// Creation timestamp of the sandbox
in nanoseconds.
CreatedAt
*
int64
`protobuf:"varint,4,opt,name=created_at,json=createdAt" json:"created_at,omitempty"`
// Network contains network status if network is handled by the runtime.
Network
*
PodSandboxNetworkStatus
`protobuf:"bytes,5,opt,name=network" json:"network,omitempty"`
...
...
@@ -971,7 +971,7 @@ type PodSandbox struct {
Metadata
*
PodSandboxMetadata
`protobuf:"bytes,2,opt,name=metadata" json:"metadata,omitempty"`
// The state of the PodSandbox
State
*
PodSandBoxState
`protobuf:"varint,3,opt,name=state,enum=runtime.PodSandBoxState" json:"state,omitempty"`
// Creation timestamps of the sandbox
// Creation timestamps of the sandbox
in nanoseconds
CreatedAt
*
int64
`protobuf:"varint,4,opt,name=created_at,json=createdAt" json:"created_at,omitempty"`
// The labels of the PodSandbox
Labels
map
[
string
]
string
`protobuf:"bytes,5,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
...
...
@@ -1740,7 +1740,7 @@ type Container struct {
ImageRef
*
string
`protobuf:"bytes,5,opt,name=image_ref,json=imageRef" json:"image_ref,omitempty"`
// State is the state of the container.
State
*
ContainerState
`protobuf:"varint,6,opt,name=state,enum=runtime.ContainerState" json:"state,omitempty"`
// Creation time of the container.
// Creation time of the container
in nanoseconds
.
CreatedAt
*
int64
`protobuf:"varint,7,opt,name=created_at,json=createdAt" json:"created_at,omitempty"`
// Labels are key value pairs that may be used to scope and select individual resources.
Labels
map
[
string
]
string
`protobuf:"bytes,8,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
...
...
@@ -1862,11 +1862,11 @@ type ContainerStatus struct {
Metadata
*
ContainerMetadata
`protobuf:"bytes,2,opt,name=metadata" json:"metadata,omitempty"`
// Status of the container.
State
*
ContainerState
`protobuf:"varint,3,opt,name=state,enum=runtime.ContainerState" json:"state,omitempty"`
// Creation time of the container.
// Creation time of the container
in nanoseconds
.
CreatedAt
*
int64
`protobuf:"varint,4,opt,name=created_at,json=createdAt" json:"created_at,omitempty"`
// Start time of the container.
// Start time of the container
in nanoseconds
.
StartedAt
*
int64
`protobuf:"varint,5,opt,name=started_at,json=startedAt" json:"started_at,omitempty"`
// Finish time of the container.
// Finish time of the container
in nanoseconds
.
FinishedAt
*
int64
`protobuf:"varint,6,opt,name=finished_at,json=finishedAt" json:"finished_at,omitempty"`
// Exit code of the container.
ExitCode
*
int32
`protobuf:"varint,7,opt,name=exit_code,json=exitCode" json:"exit_code,omitempty"`
...
...
pkg/kubelet/api/v1alpha1/runtime/api.proto
View file @
76056a47
...
...
@@ -251,7 +251,7 @@ message PodSandboxStatus {
optional
PodSandboxMetadata
metadata
=
2
;
// State of the sandbox.
optional
PodSandBoxState
state
=
3
;
// Creation timestamp of the sandbox
// Creation timestamp of the sandbox
in nanoseconds.
optional
int64
created_at
=
4
;
// Network contains network status if network is handled by the runtime.
optional
PodSandboxNetworkStatus
network
=
5
;
...
...
@@ -296,7 +296,7 @@ message PodSandbox {
optional
PodSandboxMetadata
metadata
=
2
;
// The state of the PodSandbox
optional
PodSandBoxState
state
=
3
;
// Creation timestamps of the sandbox
// Creation timestamps of the sandbox
in nanoseconds
optional
int64
created_at
=
4
;
// The labels of the PodSandbox
map
<
string
,
string
>
labels
=
5
;
...
...
@@ -533,7 +533,7 @@ message Container {
optional
string
image_ref
=
5
;
// State is the state of the container.
optional
ContainerState
state
=
6
;
// Creation time of the container.
// Creation time of the container
in nanoseconds
.
optional
int64
created_at
=
7
;
// Labels are key value pairs that may be used to scope and select individual resources.
map
<
string
,
string
>
labels
=
8
;
...
...
@@ -560,11 +560,11 @@ message ContainerStatus {
optional
ContainerMetadata
metadata
=
2
;
// Status of the container.
optional
ContainerState
state
=
3
;
// Creation time of the container.
// Creation time of the container
in nanoseconds
.
optional
int64
created_at
=
4
;
// Start time of the container.
// Start time of the container
in nanoseconds
.
optional
int64
started_at
=
5
;
// Finish time of the container.
// Finish time of the container
in nanoseconds
.
optional
int64
finished_at
=
6
;
// Exit code of the container.
optional
int32
exit_code
=
7
;
...
...
pkg/kubelet/dockershim/convert.go
View file @
76056a47
...
...
@@ -19,6 +19,7 @@ package dockershim
import
(
"fmt"
"strings"
"time"
dockertypes
"github.com/docker/engine-api/types"
...
...
@@ -57,6 +58,8 @@ func toRuntimeAPIContainer(c *dockertypes.Container) (*runtimeApi.Container, err
}
labels
,
annotations
:=
extractLabels
(
c
.
Labels
)
sandboxID
:=
c
.
Labels
[
sandboxIDLabelKey
]
// The timestamp in dockertypes.Container is in seconds.
createdAt
:=
c
.
Created
*
int64
(
time
.
Second
)
return
&
runtimeApi
.
Container
{
Id
:
&
c
.
ID
,
PodSandboxId
:
&
sandboxID
,
...
...
@@ -64,6 +67,7 @@ func toRuntimeAPIContainer(c *dockertypes.Container) (*runtimeApi.Container, err
Image
:
&
runtimeApi
.
ImageSpec
{
Image
:
&
c
.
Image
},
ImageRef
:
&
c
.
ImageID
,
State
:
&
state
,
CreatedAt
:
&
createdAt
,
Labels
:
labels
,
Annotations
:
annotations
,
},
nil
...
...
@@ -117,11 +121,13 @@ func toRuntimeAPISandbox(c *dockertypes.Container) (*runtimeApi.PodSandbox, erro
return
nil
,
err
}
labels
,
annotations
:=
extractLabels
(
c
.
Labels
)
// The timestamp in dockertypes.Container is in seconds.
createdAt
:=
c
.
Created
*
int64
(
time
.
Second
)
return
&
runtimeApi
.
PodSandbox
{
Id
:
&
c
.
ID
,
Metadata
:
metadata
,
State
:
&
state
,
CreatedAt
:
&
c
.
Created
,
CreatedAt
:
&
c
reatedAt
,
Labels
:
labels
,
Annotations
:
annotations
,
},
nil
...
...
pkg/kubelet/dockershim/docker_container_test.go
View file @
76056a47
...
...
@@ -61,6 +61,7 @@ func TestListContainers(t *testing.T) {
expected
:=
[]
*
runtimeApi
.
Container
{}
state
:=
runtimeApi
.
ContainerState_RUNNING
var
createdAt
int64
=
0
for
i
:=
range
configs
{
// We don't care about the sandbox id; pass a bogus one.
sandboxID
:=
fmt
.
Sprintf
(
"sandboxid%d"
,
i
)
...
...
@@ -77,6 +78,7 @@ func TestListContainers(t *testing.T) {
Id
:
&
id
,
PodSandboxId
:
&
sandboxID
,
State
:
&
state
,
CreatedAt
:
&
createdAt
,
Image
:
configs
[
i
]
.
Image
,
ImageRef
:
&
imageRef
,
Labels
:
configs
[
i
]
.
Labels
,
...
...
pkg/kubelet/kuberuntime/kuberuntime_container.go
View file @
76056a47
...
...
@@ -379,16 +379,16 @@ func (m *kubeGenericRuntimeManager) getPodContainerStatuses(uid kubetypes.UID, n
Hash
:
annotatedInfo
.
Hash
,
RestartCount
:
annotatedInfo
.
RestartCount
,
State
:
toKubeContainerState
(
c
.
GetState
()),
CreatedAt
:
time
.
Unix
(
status
.
GetCreatedAt
(),
0
),
CreatedAt
:
time
.
Unix
(
0
,
status
.
GetCreatedAt
()
),
}
if
c
.
GetState
()
==
runtimeApi
.
ContainerState_RUNNING
{
cStatus
.
StartedAt
=
time
.
Unix
(
status
.
GetStartedAt
(),
0
)
cStatus
.
StartedAt
=
time
.
Unix
(
0
,
status
.
GetStartedAt
()
)
}
else
{
cStatus
.
Reason
=
status
.
GetReason
()
cStatus
.
Message
=
status
.
GetMessage
()
cStatus
.
ExitCode
=
int
(
status
.
GetExitCode
())
cStatus
.
FinishedAt
=
time
.
Unix
(
status
.
GetFinishedAt
(),
0
)
cStatus
.
FinishedAt
=
time
.
Unix
(
0
,
status
.
GetFinishedAt
()
)
}
tMessage
:=
getTerminationMessage
(
status
,
cStatus
,
annotatedInfo
.
TerminationMessagePath
)
...
...
pkg/kubelet/kuberuntime/kuberuntime_gc.go
View file @
76056a47
...
...
@@ -141,7 +141,7 @@ func (cgc *containerGC) evictableContainers(minAge time.Duration) (containersByE
continue
}
createdAt
:=
time
.
Unix
(
container
.
GetCreatedAt
(),
0
)
createdAt
:=
time
.
Unix
(
0
,
container
.
GetCreatedAt
()
)
if
newestGCTime
.
Before
(
createdAt
)
{
continue
}
...
...
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