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
7767dafb
Commit
7767dafb
authored
Aug 25, 2015
by
Yifan Gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubelet/rkt: include the pod restart count in service file.
Also remove the service file when the pod is killed.
parent
763ffdb1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
9 deletions
+27
-9
pod_info.go
pkg/kubelet/rkt/pod_info.go
+27
-9
rkt.go
pkg/kubelet/rkt/rkt.go
+0
-0
No files found.
pkg/kubelet/rkt/pod_info.go
View file @
7767dafb
...
@@ -18,6 +18,7 @@ package rkt
...
@@ -18,6 +18,7 @@ package rkt
import
(
import
(
"fmt"
"fmt"
"reflect"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -43,6 +44,21 @@ const (
...
@@ -43,6 +44,21 @@ const (
exitCodePrefix
=
"app-"
exitCodePrefix
=
"app-"
)
)
// rktInfo represents the information of the rkt pod that stored in the
// systemd service file.
type
rktInfo
struct
{
uuid
string
restartCount
int
}
func
emptyRktInfo
()
*
rktInfo
{
return
&
rktInfo
{
restartCount
:
-
1
}
}
func
(
r
*
rktInfo
)
isEmpty
()
bool
{
return
reflect
.
DeepEqual
(
r
,
emptyRktInfo
())
}
// podInfo is the internal type that represents the state of
// podInfo is the internal type that represents the state of
// the rkt pod.
// the rkt pod.
type
podInfo
struct
{
type
podInfo
struct
{
...
@@ -122,15 +138,15 @@ func getIPFromNetworkInfo(networkInfo string) string {
...
@@ -122,15 +138,15 @@ func getIPFromNetworkInfo(networkInfo string) string {
return
""
return
""
}
}
//
get
ContainerStatus creates the api.containerStatus of a container from the podInfo.
//
make
ContainerStatus creates the api.containerStatus of a container from the podInfo.
func
(
p
*
podInfo
)
getContainerStatus
(
container
*
kubecontainer
.
Container
)
api
.
ContainerStatus
{
func
makeContainerStatus
(
container
*
kubecontainer
.
Container
,
podInfo
*
podInfo
)
api
.
ContainerStatus
{
var
status
api
.
ContainerStatus
var
status
api
.
ContainerStatus
status
.
Name
=
container
.
Name
status
.
Name
=
container
.
Name
status
.
Image
=
container
.
Image
status
.
Image
=
container
.
Image
status
.
ContainerID
=
string
(
container
.
ID
)
status
.
ContainerID
=
string
(
container
.
ID
)
// TODO(yifan): Add image ID info.
// TODO(yifan): Add image ID info.
switch
p
.
state
{
switch
p
odInfo
.
state
{
case
Running
:
case
Running
:
// TODO(yifan): Get StartedAt.
// TODO(yifan): Get StartedAt.
status
.
State
=
api
.
ContainerState
{
status
.
State
=
api
.
ContainerState
{
...
@@ -141,7 +157,7 @@ func (p *podInfo) getContainerStatus(container *kubecontainer.Container) api.Con
...
@@ -141,7 +157,7 @@ func (p *podInfo) getContainerStatus(container *kubecontainer.Container) api.Con
case
Embryo
,
Preparing
,
Prepared
:
case
Embryo
,
Preparing
,
Prepared
:
status
.
State
=
api
.
ContainerState
{
Waiting
:
&
api
.
ContainerStateWaiting
{}}
status
.
State
=
api
.
ContainerState
{
Waiting
:
&
api
.
ContainerStateWaiting
{}}
case
AbortedPrepare
,
Deleting
,
Exited
,
Garbage
:
case
AbortedPrepare
,
Deleting
,
Exited
,
Garbage
:
exitCode
,
ok
:=
p
.
exitCodes
[
status
.
Name
]
exitCode
,
ok
:=
p
odInfo
.
exitCodes
[
status
.
Name
]
if
!
ok
{
if
!
ok
{
glog
.
Warningf
(
"rkt: Cannot get exit code for container %v"
,
container
)
glog
.
Warningf
(
"rkt: Cannot get exit code for container %v"
,
container
)
exitCode
=
-
1
exitCode
=
-
1
...
@@ -154,18 +170,20 @@ func (p *podInfo) getContainerStatus(container *kubecontainer.Container) api.Con
...
@@ -154,18 +170,20 @@ func (p *podInfo) getContainerStatus(container *kubecontainer.Container) api.Con
},
},
}
}
default
:
default
:
glog
.
Warningf
(
"rkt: Unknown pod state: %q"
,
p
.
state
)
glog
.
Warningf
(
"rkt: Unknown pod state: %q"
,
p
odInfo
.
state
)
}
}
return
status
return
status
}
}
//
toPodStatus converts a podInfo type into an api.PodStatus type
.
//
makePodStatus constructs the pod status from the pod info and rkt info
.
func
(
p
*
podInfo
)
toPodStatus
(
pod
*
kubecontainer
.
Pod
)
api
.
PodStatus
{
func
makePodStatus
(
pod
*
kubecontainer
.
Pod
,
podInfo
*
podInfo
,
rktInfo
*
rktInfo
)
api
.
PodStatus
{
var
status
api
.
PodStatus
var
status
api
.
PodStatus
status
.
PodIP
=
p
.
ip
status
.
PodIP
=
p
odInfo
.
ip
// For now just make every container's state the same as the pod.
// For now just make every container's state the same as the pod.
for
_
,
container
:=
range
pod
.
Containers
{
for
_
,
container
:=
range
pod
.
Containers
{
status
.
ContainerStatuses
=
append
(
status
.
ContainerStatuses
,
p
.
getContainerStatus
(
container
))
containerStatus
:=
makeContainerStatus
(
container
,
podInfo
)
containerStatus
.
RestartCount
=
rktInfo
.
restartCount
status
.
ContainerStatuses
=
append
(
status
.
ContainerStatuses
,
containerStatus
)
}
}
return
status
return
status
}
}
...
...
pkg/kubelet/rkt/rkt.go
View file @
7767dafb
This diff is collapsed.
Click to expand it.
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