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
06cc355b
Unverified
Commit
06cc355b
authored
Nov 30, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 30, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #71574 from msau42/remove-events-e2e
Check for subpath error in container status instead of pod events
parents
3156df3e
7571b7e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
11 deletions
+47
-11
BUILD
test/e2e/storage/testsuites/BUILD
+0
-1
subpath.go
test/e2e/storage/testsuites/subpath.go
+47
-10
No files found.
test/e2e/storage/testsuites/BUILD
View file @
06cc355b
...
@@ -18,7 +18,6 @@ go_library(
...
@@ -18,7 +18,6 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/rand:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/rand:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
...
...
test/e2e/storage/testsuites/subpath.go
View file @
06cc355b
...
@@ -24,7 +24,6 @@ import (
...
@@ -24,7 +24,6 @@ import (
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
...
@@ -587,16 +586,54 @@ func testPodFailSubpathError(f *framework.Framework, pod *v1.Pod, errorMsg strin
...
@@ -587,16 +586,54 @@ func testPodFailSubpathError(f *framework.Framework, pod *v1.Pod, errorMsg strin
defer
func
()
{
defer
func
()
{
framework
.
DeletePodWithWait
(
f
,
f
.
ClientSet
,
pod
)
framework
.
DeletePodWithWait
(
f
,
f
.
ClientSet
,
pod
)
}()
}()
By
(
"Checking for subpath error in container status"
)
err
=
waitForPodSubpathError
(
f
,
pod
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"while waiting for subpath failure"
)
}
func
findSubpathContainerName
(
pod
*
v1
.
Pod
)
string
{
for
_
,
container
:=
range
pod
.
Spec
.
Containers
{
for
_
,
mount
:=
range
container
.
VolumeMounts
{
if
mount
.
SubPath
!=
""
{
return
container
.
Name
}
}
}
return
""
}
func
waitForPodSubpathError
(
f
*
framework
.
Framework
,
pod
*
v1
.
Pod
)
error
{
subpathContainerName
:=
findSubpathContainerName
(
pod
)
if
subpathContainerName
==
""
{
return
fmt
.
Errorf
(
"failed to find container that uses subpath"
)
}
By
(
"Checking for subpath error event"
)
return
wait
.
PollImmediate
(
framework
.
Poll
,
framework
.
PodStartTimeout
,
func
()
(
bool
,
error
)
{
selector
:=
fields
.
Set
{
pod
,
err
:=
f
.
ClientSet
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
Get
(
pod
.
Name
,
metav1
.
GetOptions
{})
"involvedObject.kind"
:
"Pod"
,
if
err
!=
nil
{
"involvedObject.name"
:
pod
.
Name
,
return
false
,
err
"involvedObject.namespace"
:
f
.
Namespace
.
Name
,
}
"reason"
:
"Failed"
,
for
_
,
status
:=
range
pod
.
Status
.
ContainerStatuses
{
}
.
AsSelector
()
.
String
()
// 0 is the container that uses subpath
err
=
framework
.
WaitTimeoutForPodEvent
(
f
.
ClientSet
,
pod
.
Name
,
f
.
Namespace
.
Name
,
selector
,
errorMsg
,
framework
.
PodStartTimeout
)
if
status
.
Name
==
subpathContainerName
{
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"while waiting for failed event to occur"
)
switch
{
case
status
.
State
.
Running
!=
nil
:
return
false
,
fmt
.
Errorf
(
"subpath container unexpectedly became running"
)
case
status
.
State
.
Terminated
!=
nil
:
return
false
,
fmt
.
Errorf
(
"subpath container unexpectedly terminated"
)
case
status
.
State
.
Waiting
!=
nil
:
if
status
.
State
.
Waiting
.
Reason
==
"CreateContainerConfigError"
&&
strings
.
Contains
(
status
.
State
.
Waiting
.
Message
,
"subPath"
)
{
return
true
,
nil
}
return
false
,
nil
default
:
return
false
,
nil
}
}
}
return
false
,
nil
})
}
}
// Tests that the existing subpath mount is detected when a container restarts
// Tests that the existing subpath mount is detected when a container restarts
...
...
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