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
f4cb3584
Commit
f4cb3584
authored
May 03, 2017
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix flake in sandbox garbage collection
parent
868da1e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
kuberuntime_gc_test.go
pkg/kubelet/kuberuntime/kuberuntime_gc_test.go
+15
-14
No files found.
pkg/kubelet/kuberuntime/kuberuntime_gc_test.go
View file @
f4cb3584
...
@@ -35,15 +35,16 @@ func TestSandboxGC(t *testing.T) {
...
@@ -35,15 +35,16 @@ func TestSandboxGC(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
fakePodGetter
:=
m
.
containerGC
.
podGetter
.
(
*
fakePodGetter
)
fakePodGetter
:=
m
.
containerGC
.
podGetter
.
(
*
fakePodGetter
)
makeGCSandbox
:=
func
(
pod
*
v1
.
Pod
,
attempt
uint32
,
state
runtimeapi
.
PodSandboxState
,
withPodGetter
bool
)
sandboxTemplate
{
makeGCSandbox
:=
func
(
pod
*
v1
.
Pod
,
attempt
uint32
,
state
runtimeapi
.
PodSandboxState
,
withPodGetter
bool
,
createdAt
int64
)
sandboxTemplate
{
if
withPodGetter
{
if
withPodGetter
{
// initialize the pod getter
// initialize the pod getter
fakePodGetter
.
pods
[
pod
.
UID
]
=
pod
fakePodGetter
.
pods
[
pod
.
UID
]
=
pod
}
}
return
sandboxTemplate
{
return
sandboxTemplate
{
pod
:
pod
,
pod
:
pod
,
state
:
state
,
state
:
state
,
attempt
:
attempt
,
attempt
:
attempt
,
createdAt
:
createdAt
,
}
}
}
}
...
@@ -70,7 +71,7 @@ func TestSandboxGC(t *testing.T) {
...
@@ -70,7 +71,7 @@ func TestSandboxGC(t *testing.T) {
{
{
description
:
"notready sandboxes without containers for deleted pods should be garbage collected."
,
description
:
"notready sandboxes without containers for deleted pods should be garbage collected."
,
sandboxes
:
[]
sandboxTemplate
{
sandboxes
:
[]
sandboxTemplate
{
makeGCSandbox
(
pods
[
2
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
false
),
makeGCSandbox
(
pods
[
2
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
false
,
0
),
},
},
containers
:
[]
containerTemplate
{},
containers
:
[]
containerTemplate
{},
remain
:
[]
int
{},
remain
:
[]
int
{},
...
@@ -78,7 +79,7 @@ func TestSandboxGC(t *testing.T) {
...
@@ -78,7 +79,7 @@ func TestSandboxGC(t *testing.T) {
{
{
description
:
"ready sandboxes without containers for deleted pods should not be garbage collected."
,
description
:
"ready sandboxes without containers for deleted pods should not be garbage collected."
,
sandboxes
:
[]
sandboxTemplate
{
sandboxes
:
[]
sandboxTemplate
{
makeGCSandbox
(
pods
[
2
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_READY
,
false
),
makeGCSandbox
(
pods
[
2
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_READY
,
false
,
0
),
},
},
containers
:
[]
containerTemplate
{},
containers
:
[]
containerTemplate
{},
remain
:
[]
int
{
0
},
remain
:
[]
int
{
0
},
...
@@ -86,8 +87,8 @@ func TestSandboxGC(t *testing.T) {
...
@@ -86,8 +87,8 @@ func TestSandboxGC(t *testing.T) {
{
{
description
:
"sandboxes for existing pods should not be garbage collected."
,
description
:
"sandboxes for existing pods should not be garbage collected."
,
sandboxes
:
[]
sandboxTemplate
{
sandboxes
:
[]
sandboxTemplate
{
makeGCSandbox
(
pods
[
0
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_READY
,
true
),
makeGCSandbox
(
pods
[
0
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_READY
,
true
,
0
),
makeGCSandbox
(
pods
[
1
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
true
),
makeGCSandbox
(
pods
[
1
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
true
,
0
),
},
},
containers
:
[]
containerTemplate
{},
containers
:
[]
containerTemplate
{},
remain
:
[]
int
{
0
,
1
},
remain
:
[]
int
{
0
,
1
},
...
@@ -95,7 +96,7 @@ func TestSandboxGC(t *testing.T) {
...
@@ -95,7 +96,7 @@ func TestSandboxGC(t *testing.T) {
{
{
description
:
"sandbox with containers should not be garbage collected."
,
description
:
"sandbox with containers should not be garbage collected."
,
sandboxes
:
[]
sandboxTemplate
{
sandboxes
:
[]
sandboxTemplate
{
makeGCSandbox
(
pods
[
0
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
false
),
makeGCSandbox
(
pods
[
0
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
false
,
0
),
},
},
containers
:
[]
containerTemplate
{
containers
:
[]
containerTemplate
{
{
pod
:
pods
[
0
],
container
:
&
pods
[
0
]
.
Spec
.
Containers
[
0
],
state
:
runtimeapi
.
ContainerState_CONTAINER_EXITED
},
{
pod
:
pods
[
0
],
container
:
&
pods
[
0
]
.
Spec
.
Containers
[
0
],
state
:
runtimeapi
.
ContainerState_CONTAINER_EXITED
},
...
@@ -106,15 +107,15 @@ func TestSandboxGC(t *testing.T) {
...
@@ -106,15 +107,15 @@ func TestSandboxGC(t *testing.T) {
description
:
"multiple sandboxes should be handled properly."
,
description
:
"multiple sandboxes should be handled properly."
,
sandboxes
:
[]
sandboxTemplate
{
sandboxes
:
[]
sandboxTemplate
{
// running sandbox.
// running sandbox.
makeGCSandbox
(
pods
[
0
],
1
,
runtimeapi
.
PodSandboxState_SANDBOX_READY
,
true
),
makeGCSandbox
(
pods
[
0
],
1
,
runtimeapi
.
PodSandboxState_SANDBOX_READY
,
true
,
1
),
// exited sandbox without containers.
// exited sandbox without containers.
makeGCSandbox
(
pods
[
0
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
false
),
makeGCSandbox
(
pods
[
0
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
true
,
0
),
// exited sandbox with containers.
// exited sandbox with containers.
makeGCSandbox
(
pods
[
1
],
1
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
true
),
makeGCSandbox
(
pods
[
1
],
1
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
true
,
1
),
// exited sandbox without containers.
// exited sandbox without containers.
makeGCSandbox
(
pods
[
1
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
false
),
makeGCSandbox
(
pods
[
1
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
true
,
0
),
// exited sandbox without containers for deleted pods.
// exited sandbox without containers for deleted pods.
makeGCSandbox
(
pods
[
2
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
false
),
makeGCSandbox
(
pods
[
2
],
0
,
runtimeapi
.
PodSandboxState_SANDBOX_NOTREADY
,
false
,
0
),
},
},
containers
:
[]
containerTemplate
{
containers
:
[]
containerTemplate
{
{
pod
:
pods
[
1
],
container
:
&
pods
[
1
]
.
Spec
.
Containers
[
0
],
sandboxAttempt
:
1
,
state
:
runtimeapi
.
ContainerState_CONTAINER_EXITED
},
{
pod
:
pods
[
1
],
container
:
&
pods
[
1
]
.
Spec
.
Containers
[
0
],
sandboxAttempt
:
1
,
state
:
runtimeapi
.
ContainerState_CONTAINER_EXITED
},
...
...
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