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
14940eda
Commit
14940eda
authored
Jan 30, 2017
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add legacy container cleanup
parent
c84f3abc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
4 deletions
+45
-4
docker_container.go
pkg/kubelet/dockershim/docker_container.go
+18
-0
docker_legacy.go
pkg/kubelet/dockershim/docker_legacy.go
+0
-0
docker_sandbox.go
pkg/kubelet/dockershim/docker_sandbox.go
+23
-2
docker_service.go
pkg/kubelet/dockershim/docker_service.go
+4
-1
naming.go
pkg/kubelet/dockershim/naming.go
+0
-1
No files found.
pkg/kubelet/dockershim/docker_container.go
View file @
14940eda
...
@@ -75,6 +75,15 @@ func (ds *dockerService) ListContainers(filter *runtimeapi.ContainerFilter) ([]*
...
@@ -75,6 +75,15 @@ func (ds *dockerService) ListContainers(filter *runtimeapi.ContainerFilter) ([]*
result
=
append
(
result
,
converted
)
result
=
append
(
result
,
converted
)
}
}
// Include legacy containers if there are still legacy containers not cleaned up yet.
if
!
ds
.
legacyCleanup
.
Done
()
{
legacyContainers
,
err
:=
ds
.
ListLegacyContainers
(
filter
)
if
err
!=
nil
{
return
nil
,
err
}
// Legacy containers are always older, so we can safely append them to the end.
result
=
append
(
result
,
legacyContainers
...
)
}
return
result
,
nil
return
result
,
nil
}
}
...
@@ -360,6 +369,15 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeapi.Contai
...
@@ -360,6 +369,15 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeapi.Contai
ct
,
st
,
ft
:=
createdAt
.
UnixNano
(),
startedAt
.
UnixNano
(),
finishedAt
.
UnixNano
()
ct
,
st
,
ft
:=
createdAt
.
UnixNano
(),
startedAt
.
UnixNano
(),
finishedAt
.
UnixNano
()
exitCode
:=
int32
(
r
.
State
.
ExitCode
)
exitCode
:=
int32
(
r
.
State
.
ExitCode
)
// If the container has no containerTypeLabelKey label, treat it as a legacy container.
if
_
,
ok
:=
r
.
Config
.
Labels
[
containerTypeLabelKey
];
!
ok
{
names
,
labels
,
err
:=
convertLegacyNameAndLabels
([]
string
{
r
.
Name
},
r
.
Config
.
Labels
)
if
err
!=
nil
{
return
nil
,
err
}
r
.
Name
,
r
.
Config
.
Labels
=
names
[
0
],
labels
}
metadata
,
err
:=
parseContainerName
(
r
.
Name
)
metadata
,
err
:=
parseContainerName
(
r
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
pkg/kubelet/dockershim/docker_legacy.go
0 → 100644
View file @
14940eda
This diff is collapsed.
Click to expand it.
pkg/kubelet/dockershim/docker_sandbox.go
View file @
14940eda
...
@@ -244,12 +244,23 @@ func (ds *dockerService) PodSandboxStatus(podSandboxID string) (*runtimeapi.PodS
...
@@ -244,12 +244,23 @@ func (ds *dockerService) PodSandboxStatus(podSandboxID string) (*runtimeapi.PodS
}
}
network
:=
&
runtimeapi
.
PodSandboxNetworkStatus
{
Ip
:
IP
}
network
:=
&
runtimeapi
.
PodSandboxNetworkStatus
{
Ip
:
IP
}
netNS
:=
getNetworkNamespace
(
r
)
netNS
:=
getNetworkNamespace
(
r
)
hostNetwork
:=
sharesHostNetwork
(
r
)
// If the sandbox has no containerTypeLabelKey label, treat it as a legacy sandbox.
if
_
,
ok
:=
r
.
Config
.
Labels
[
containerTypeLabelKey
];
!
ok
{
names
,
labels
,
err
:=
convertLegacyNameAndLabels
([]
string
{
r
.
Name
},
r
.
Config
.
Labels
)
if
err
!=
nil
{
return
nil
,
err
}
r
.
Name
,
r
.
Config
.
Labels
=
names
[
0
],
labels
// Forcibly trigger infra container restart.
hostNetwork
=
!
hostNetwork
}
metadata
,
err
:=
parseSandboxName
(
r
.
Name
)
metadata
,
err
:=
parseSandboxName
(
r
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
hostNetwork
:=
sharesHostNetwork
(
r
)
labels
,
annotations
:=
extractLabels
(
r
.
Config
.
Labels
)
labels
,
annotations
:=
extractLabels
(
r
.
Config
.
Labels
)
return
&
runtimeapi
.
PodSandboxStatus
{
return
&
runtimeapi
.
PodSandboxStatus
{
Id
:
r
.
ID
,
Id
:
r
.
ID
,
...
@@ -318,7 +329,7 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]
...
@@ -318,7 +329,7 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]
c
:=
containers
[
i
]
c
:=
containers
[
i
]
converted
,
err
:=
containerToRuntimeAPISandbox
(
&
c
)
converted
,
err
:=
containerToRuntimeAPISandbox
(
&
c
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
4
)
.
Infof
(
"Unable to convert docker to runtime API sandbox
: %v"
,
err
)
glog
.
V
(
4
)
.
Infof
(
"Unable to convert docker to runtime API sandbox
%+v: %v"
,
c
,
err
)
continue
continue
}
}
if
filterOutReadySandboxes
&&
converted
.
State
==
runtimeapi
.
PodSandboxState_SANDBOX_READY
{
if
filterOutReadySandboxes
&&
converted
.
State
==
runtimeapi
.
PodSandboxState_SANDBOX_READY
{
...
@@ -353,6 +364,16 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]
...
@@ -353,6 +364,16 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]
result
=
append
(
result
,
checkpointToRuntimeAPISandbox
(
id
,
checkpoint
))
result
=
append
(
result
,
checkpointToRuntimeAPISandbox
(
id
,
checkpoint
))
}
}
}
}
// Include legacy sandboxes if there are still legacy sandboxes not cleaned up yet.
if
!
ds
.
legacyCleanup
.
Done
()
{
legacySandboxes
,
err
:=
ds
.
ListLegacyPodSandbox
(
filter
)
if
err
!=
nil
{
return
nil
,
err
}
// Legacy sandboxes are always older, so we can safely append them to the end.
result
=
append
(
result
,
legacySandboxes
...
)
}
return
result
,
nil
return
result
,
nil
}
}
...
...
pkg/kubelet/dockershim/docker_service.go
View file @
14940eda
...
@@ -153,7 +153,6 @@ func NewDockerService(client dockertools.DockerInterface, seccompProfileRoot str
...
@@ -153,7 +153,6 @@ func NewDockerService(client dockertools.DockerInterface, seccompProfileRoot str
glog
.
Infof
(
"Setting cgroupDriver to %s"
,
cgroupDriver
)
glog
.
Infof
(
"Setting cgroupDriver to %s"
,
cgroupDriver
)
}
}
ds
.
cgroupDriver
=
cgroupDriver
ds
.
cgroupDriver
=
cgroupDriver
return
ds
,
nil
return
ds
,
nil
}
}
...
@@ -179,6 +178,8 @@ type dockerService struct {
...
@@ -179,6 +178,8 @@ type dockerService struct {
// cgroup driver used by Docker runtime.
// cgroup driver used by Docker runtime.
cgroupDriver
string
cgroupDriver
string
checkpointHandler
CheckpointHandler
checkpointHandler
CheckpointHandler
// legacyCleanup indicates whether legacy cleanup has finished or not.
legacyCleanup
legacyCleanupFlag
}
}
// Version returns the runtime name, runtime version and runtime API version
// Version returns the runtime name, runtime version and runtime API version
...
@@ -241,6 +242,8 @@ type dockerNetworkHost struct {
...
@@ -241,6 +242,8 @@ type dockerNetworkHost struct {
// Start initializes and starts components in dockerService.
// Start initializes and starts components in dockerService.
func
(
ds
*
dockerService
)
Start
()
error
{
func
(
ds
*
dockerService
)
Start
()
error
{
// Initialize the legacy cleanup flag.
ds
.
LegacyCleanupInit
()
return
ds
.
containerManager
.
Start
()
return
ds
.
containerManager
.
Start
()
}
}
...
...
pkg/kubelet/dockershim/naming.go
View file @
14940eda
...
@@ -76,7 +76,6 @@ func makeContainerName(s *runtimeapi.PodSandboxConfig, c *runtimeapi.ContainerCo
...
@@ -76,7 +76,6 @@ func makeContainerName(s *runtimeapi.PodSandboxConfig, c *runtimeapi.ContainerCo
s
.
Metadata
.
Uid
,
// 4 sandbox uid
s
.
Metadata
.
Uid
,
// 4 sandbox uid
fmt
.
Sprintf
(
"%d"
,
c
.
Metadata
.
Attempt
),
// 5
fmt
.
Sprintf
(
"%d"
,
c
.
Metadata
.
Attempt
),
// 5
},
nameDelimiter
)
},
nameDelimiter
)
}
}
// randomizeName randomizes the container name. This should only be used when we hit the
// randomizeName randomizes the container name. This should only be used when we hit the
...
...
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