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
304bb501
Commit
304bb501
authored
Sep 12, 2018
by
David Zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change VolumeTestCleanup to not fail when pod already deleted
parent
ae8a0469
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
25 deletions
+16
-25
pv_util.go
test/e2e/framework/pv_util.go
+12
-8
volume_util.go
test/e2e/framework/volume_util.go
+4
-17
No files found.
test/e2e/framework/pv_util.go
View file @
304bb501
...
...
@@ -507,21 +507,25 @@ 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
// not existing.
func
DeletePodWithWait
(
f
*
Framework
,
c
clientset
.
Interface
,
pod
*
v1
.
Pod
)
error
{
if
pod
==
nil
{
return
nil
}
Logf
(
"Deleting pod %q in namespace %q"
,
pod
.
Name
,
pod
.
Namespace
)
err
:=
c
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
Delete
(
pod
.
Name
,
nil
)
return
DeletePodWithWaitByName
(
f
,
c
,
pod
.
GetName
(),
pod
.
GetNamespace
())
}
// Deletes the named and namespaced pod and waits for the pod to be terminated. Resilient to the pod
// not existing.
func
DeletePodWithWaitByName
(
f
*
Framework
,
c
clientset
.
Interface
,
podName
,
podNamespace
string
)
error
{
const
maxWait
=
5
*
time
.
Minute
Logf
(
"Deleting pod %q in namespace %q"
,
podName
,
podNamespace
)
err
:=
c
.
CoreV1
()
.
Pods
(
podNamespace
)
.
Delete
(
podName
,
nil
)
if
err
!=
nil
{
if
apierrs
.
IsNotFound
(
err
)
{
return
nil
// assume pod was already deleted
}
return
fmt
.
Errorf
(
"pod Delete API error: %v"
,
err
)
}
Logf
(
"Wait up to %v for pod %q to be fully deleted"
,
PodDeleteTimeout
,
pod
.
Name
)
err
=
f
.
WaitForPodNotFound
(
pod
.
Name
,
PodDeleteTimeou
t
)
Logf
(
"Wait up to %v for pod %q to be fully deleted"
,
maxWait
,
pod
Name
)
err
=
f
.
WaitForPodNotFound
(
pod
Name
,
maxWai
t
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"pod %q was not deleted: %v"
,
pod
.
Name
,
err
)
return
fmt
.
Errorf
(
"pod %q was not deleted: %v"
,
podName
,
err
)
}
return
nil
}
...
...
test/e2e/framework/volume_util.go
View file @
304bb501
...
...
@@ -52,7 +52,6 @@ import (
clientset
"k8s.io/client-go/kubernetes"
imageutils
"k8s.io/kubernetes/test/utils/image"
"github.com/golang/glog"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
)
...
...
@@ -389,24 +388,12 @@ func VolumeTestCleanup(f *Framework, config VolumeTestConfig) {
cs
:=
f
.
ClientSet
pod
,
err
:=
cs
.
CoreV1
()
.
Pods
(
config
.
Namespace
)
.
Get
(
config
.
Prefix
+
"-client"
,
metav1
.
GetOptions
{})
ExpectNoError
(
err
,
"Failed to get client pod: %v"
,
err
)
err
=
DeletePodWithWait
(
f
,
cs
,
pod
)
if
err
!=
nil
{
// Log the error before failing test: if the test has already failed,
// framework.ExpectNoError() won't print anything to logs!
glog
.
Warningf
(
"Failed to delete client pod: %v"
,
err
)
ExpectNoError
(
err
,
"Failed to delete client pod: %v"
,
err
)
}
err
:=
DeletePodWithWaitByName
(
f
,
cs
,
config
.
Prefix
+
"-client"
,
config
.
Namespace
)
Expect
(
err
)
.
To
(
BeNil
(),
"Failed to delete pod %v in namespace %v"
,
config
.
Prefix
+
"-client"
,
config
.
Namespace
)
if
config
.
ServerImage
!=
""
{
pod
,
err
:=
cs
.
CoreV1
()
.
Pods
(
config
.
Namespace
)
.
Get
(
config
.
Prefix
+
"-server"
,
metav1
.
GetOptions
{})
ExpectNoError
(
err
,
"Failed to get server pod: %v"
,
err
)
err
=
DeletePodWithWait
(
f
,
cs
,
pod
)
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to delete server pod: %v"
,
err
)
ExpectNoError
(
err
,
"Failed to delete server pod: %v"
,
err
)
}
err
:=
DeletePodWithWaitByName
(
f
,
cs
,
config
.
Prefix
+
"-server"
,
config
.
Namespace
)
Expect
(
err
)
.
To
(
BeNil
(),
"Failed to delete pod %v in namespace %v"
,
config
.
Prefix
+
"-server"
,
config
.
Namespace
)
}
}
...
...
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