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
d7e18ac5
Commit
d7e18ac5
authored
Oct 06, 2017
by
jeff vance
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wait for pod to be fully deleted
parent
c7f970c5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
16 deletions
+38
-16
framework.go
test/e2e/framework/framework.go
+5
-0
pv_util.go
test/e2e/framework/pv_util.go
+8
-11
util.go
test/e2e/framework/util.go
+17
-0
kubelet.go
test/e2e/node/kubelet.go
+8
-5
No files found.
test/e2e/framework/framework.go
View file @
d7e18ac5
...
@@ -381,6 +381,11 @@ func (f *Framework) WaitForPodTerminated(podName, reason string) error {
...
@@ -381,6 +381,11 @@ func (f *Framework) WaitForPodTerminated(podName, reason string) error {
return
waitForPodTerminatedInNamespace
(
f
.
ClientSet
,
podName
,
reason
,
f
.
Namespace
.
Name
)
return
waitForPodTerminatedInNamespace
(
f
.
ClientSet
,
podName
,
reason
,
f
.
Namespace
.
Name
)
}
}
// WaitForPodNotFound waits for the pod to be completely terminated (not "Get-able").
func
(
f
*
Framework
)
WaitForPodNotFound
(
podName
string
,
timeout
time
.
Duration
)
error
{
return
waitForPodNotFoundInNamespace
(
f
.
ClientSet
,
podName
,
f
.
Namespace
.
Name
,
timeout
)
}
// WaitForPodRunning waits for the pod to run in the namespace.
// WaitForPodRunning waits for the pod to run in the namespace.
func
(
f
*
Framework
)
WaitForPodRunning
(
podName
string
)
error
{
func
(
f
*
Framework
)
WaitForPodRunning
(
podName
string
)
error
{
return
WaitForPodNameRunningInNamespace
(
f
.
ClientSet
,
podName
,
f
.
Namespace
.
Name
)
return
WaitForPodNameRunningInNamespace
(
f
.
ClientSet
,
podName
,
f
.
Namespace
.
Name
)
...
...
test/e2e/framework/pv_util.go
View file @
d7e18ac5
...
@@ -494,25 +494,22 @@ func testPodSuccessOrFail(c clientset.Interface, ns string, pod *v1.Pod) error {
...
@@ -494,25 +494,22 @@ func testPodSuccessOrFail(c clientset.Interface, ns string, pod *v1.Pod) error {
// Deletes the passed-in pod and waits for the pod to be terminated. Resilient to the pod
// Deletes the passed-in pod and waits for the pod to be terminated. Resilient to the pod
// not existing.
// not existing.
func
DeletePodWithWait
(
f
*
Framework
,
c
clientset
.
Interface
,
pod
*
v1
.
Pod
)
error
{
func
DeletePodWithWait
(
f
*
Framework
,
c
clientset
.
Interface
,
pod
*
v1
.
Pod
)
error
{
const
maxWait
=
5
*
time
.
Minute
if
pod
==
nil
{
if
pod
==
nil
{
return
nil
return
nil
}
}
Logf
(
"Deleting pod %
v"
,
pod
.
Nam
e
)
Logf
(
"Deleting pod %
q in namespace %q"
,
pod
.
Name
,
pod
.
Namespac
e
)
err
:=
c
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
Delete
(
pod
.
Name
,
nil
)
err
:=
c
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
Delete
(
pod
.
Name
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
if
apierrs
.
IsNotFound
(
err
)
{
if
apierrs
.
IsNotFound
(
err
)
{
return
nil
// assume pod was
deleted already
return
nil
// assume pod was
already deleted
}
}
return
fmt
.
Errorf
(
"pod
Get
API error: %v"
,
err
)
return
fmt
.
Errorf
(
"pod
Delete
API error: %v"
,
err
)
}
}
Logf
(
"Wait up to %v for pod %q to be fully deleted"
,
maxWait
,
pod
.
Name
)
// wait for pod to terminate
err
=
f
.
WaitForPodNotFound
(
pod
.
Name
,
maxWait
)
err
=
f
.
WaitForPodTerminated
(
pod
.
Name
,
""
)
if
err
!=
nil
{
if
err
!=
nil
&&
!
apierrs
.
IsNotFound
(
err
)
{
return
fmt
.
Errorf
(
"pod %q was not deleted: %v"
,
pod
.
Name
,
err
)
return
fmt
.
Errorf
(
"error deleting pod %q: %v"
,
pod
.
Name
,
err
)
}
if
apierrs
.
IsNotFound
(
err
)
{
Logf
(
"Ignore
\"
not found
\"
error above. Pod %q successfully deleted"
,
pod
.
Name
)
}
}
return
nil
return
nil
}
}
...
...
test/e2e/framework/util.go
View file @
d7e18ac5
...
@@ -1445,6 +1445,23 @@ func waitForPodTerminatedInNamespace(c clientset.Interface, podName, reason, nam
...
@@ -1445,6 +1445,23 @@ func waitForPodTerminatedInNamespace(c clientset.Interface, podName, reason, nam
})
})
}
}
// waitForPodNotFoundInNamespace returns an error if it takes too long for the pod to fully terminate.
// Unlike `waitForPodTerminatedInNamespace`, the pod's Phase and Reason are ignored. If the pod Get
// api returns IsNotFound then the wait stops and nil is returned. If the Get api returns an error other
// than "not found" then that error is returned and the wait stops.
func
waitForPodNotFoundInNamespace
(
c
clientset
.
Interface
,
podName
,
ns
string
,
timeout
time
.
Duration
)
error
{
return
wait
.
PollImmediate
(
Poll
,
timeout
,
func
()
(
bool
,
error
)
{
_
,
err
:=
c
.
CoreV1
()
.
Pods
(
ns
)
.
Get
(
podName
,
metav1
.
GetOptions
{})
if
apierrs
.
IsNotFound
(
err
)
{
return
true
,
nil
// done
}
if
err
!=
nil
{
return
true
,
err
// stop wait with error
}
return
false
,
nil
})
}
// waitForPodSuccessInNamespaceTimeout returns nil if the pod reached state success, or an error if it reached failure or ran too long.
// waitForPodSuccessInNamespaceTimeout returns nil if the pod reached state success, or an error if it reached failure or ran too long.
func
waitForPodSuccessInNamespaceTimeout
(
c
clientset
.
Interface
,
podName
string
,
namespace
string
,
timeout
time
.
Duration
)
error
{
func
waitForPodSuccessInNamespaceTimeout
(
c
clientset
.
Interface
,
podName
string
,
namespace
string
,
timeout
time
.
Duration
)
error
{
return
WaitForPodCondition
(
c
,
namespace
,
podName
,
"success or failure"
,
timeout
,
func
(
pod
*
v1
.
Pod
)
(
bool
,
error
)
{
return
WaitForPodCondition
(
c
,
namespace
,
podName
,
"success or failure"
,
timeout
,
func
(
pod
*
v1
.
Pod
)
(
bool
,
error
)
{
...
...
test/e2e/node/kubelet.go
View file @
d7e18ac5
...
@@ -423,8 +423,10 @@ var _ = SIGDescribe("kubelet", func() {
...
@@ -423,8 +423,10 @@ var _ = SIGDescribe("kubelet", func() {
})
})
AfterEach
(
func
()
{
AfterEach
(
func
()
{
framework
.
ExpectNoError
(
framework
.
DeletePodWithWait
(
f
,
c
,
pod
),
"AfterEach: Failed to delete pod "
,
pod
.
Name
)
err
:=
framework
.
DeletePodWithWait
(
f
,
c
,
pod
)
framework
.
ExpectNoError
(
framework
.
DeletePodWithWait
(
f
,
c
,
nfsServerPod
),
"AfterEach: Failed to delete pod "
,
nfsServerPod
.
Name
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"AfterEach: Failed to delete client pod "
,
pod
.
Name
)
err
=
framework
.
DeletePodWithWait
(
f
,
c
,
nfsServerPod
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"AfterEach: Failed to delete server pod "
,
nfsServerPod
.
Name
)
})
})
// execute It blocks from above table of tests
// execute It blocks from above table of tests
...
@@ -435,8 +437,9 @@ var _ = SIGDescribe("kubelet", func() {
...
@@ -435,8 +437,9 @@ var _ = SIGDescribe("kubelet", func() {
By
(
"Stop the NFS server"
)
By
(
"Stop the NFS server"
)
stopNfsServer
(
nfsServerPod
)
stopNfsServer
(
nfsServerPod
)
By
(
"Delete the pod mounted to the NFS volume"
)
By
(
"Delete the pod mounted to the NFS volume -- expect failure"
)
framework
.
ExpectNoError
(
framework
.
DeletePodWithWait
(
f
,
c
,
pod
),
"Failed to delete pod "
,
pod
.
Name
)
err
:=
framework
.
DeletePodWithWait
(
f
,
c
,
pod
)
Expect
(
err
)
.
To
(
HaveOccurred
())
// pod object is now stale, but is intentionally not nil
// pod object is now stale, but is intentionally not nil
By
(
"Check if pod's host has been cleaned up -- expect not"
)
By
(
"Check if pod's host has been cleaned up -- expect not"
)
...
@@ -445,7 +448,7 @@ var _ = SIGDescribe("kubelet", func() {
...
@@ -445,7 +448,7 @@ var _ = SIGDescribe("kubelet", func() {
By
(
"Restart the nfs server"
)
By
(
"Restart the nfs server"
)
restartNfsServer
(
nfsServerPod
)
restartNfsServer
(
nfsServerPod
)
By
(
"Verify
host running the deleted
pod is now cleaned up"
)
By
(
"Verify
that the deleted client
pod is now cleaned up"
)
checkPodCleanup
(
c
,
pod
,
true
)
checkPodCleanup
(
c
,
pod
,
true
)
})
})
}
}
...
...
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