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
08aedca1
Commit
08aedca1
authored
Oct 06, 2016
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add MinAge for sandbox GC.
parent
76056a47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
kuberuntime_gc.go
pkg/kubelet/kuberuntime/kuberuntime_gc.go
+21
-0
No files found.
pkg/kubelet/kuberuntime/kuberuntime_gc.go
View file @
08aedca1
...
...
@@ -27,6 +27,20 @@ import (
"k8s.io/kubernetes/pkg/types"
)
// sandboxMinGCAge is the minimum age for an empty sandbox before it is garbage collected.
// This is introduced to avoid a sandbox being garbage collected before its containers are
// created.
// Notice that if the first container of a sandbox is created too late (exceeds sandboxMinGCAge),
// the sandbox could still be garbaged collected. In that case, SyncPod will recreate the
// sandbox and make sure old containers are all stopped.
// In the following figure, 'o' is a stopped sandbox, 'x' is a removed sandbox. It shows
// that, approximately if a sandbox keeps crashing and MinAge = 1/n GC Period, there will
// be 1/n more sandboxes not garbage collected.
// oooooo|xxxxxx|xxxxxx| <--- MinAge = 0
// gc gc gc gc
// oooooo|oooxxx|xxxxxx| <--- MinAge = 1/2 GC Perod
const
sandboxMinGCAge
time
.
Duration
=
30
*
time
.
Second
// containerGC is the manager of garbage collection.
type
containerGC
struct
{
client
internalApi
.
RuntimeService
...
...
@@ -182,6 +196,7 @@ func (cgc *containerGC) evictableSandboxes() ([]string, error) {
}
evictSandboxes
:=
make
([]
string
,
0
)
newestGCTime
:=
time
.
Now
()
.
Add
(
-
sandboxMinGCAge
)
for
_
,
sandbox
:=
range
sandboxes
{
// Prune out ready sandboxes.
if
sandbox
.
GetState
()
==
runtimeApi
.
PodSandBoxState_READY
{
...
...
@@ -201,6 +216,12 @@ func (cgc *containerGC) evictableSandboxes() ([]string, error) {
continue
}
// Only garbage collect sandboxes older than sandboxMinGCAge.
createdAt
:=
time
.
Unix
(
0
,
sandbox
.
GetCreatedAt
())
if
createdAt
.
After
(
newestGCTime
)
{
continue
}
evictSandboxes
=
append
(
evictSandboxes
,
sandboxID
)
}
...
...
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