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
16a49515
Commit
16a49515
authored
Oct 11, 2016
by
Jing Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a retry when reading a file content from a container
To avoid temporal failure in reading the file content, add a retry process in function verifyPDContentsViaContainer
parent
ead65fc2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
pd.go
test/e2e/pd.go
+17
-9
No files found.
test/e2e/pd.go
View file @
16a49515
...
@@ -49,6 +49,7 @@ const (
...
@@ -49,6 +49,7 @@ const (
nodeStatusPollTime
=
1
*
time
.
Second
nodeStatusPollTime
=
1
*
time
.
Second
gcePDRetryTimeout
=
5
*
time
.
Minute
gcePDRetryTimeout
=
5
*
time
.
Minute
gcePDRetryPollTime
=
5
*
time
.
Second
gcePDRetryPollTime
=
5
*
time
.
Second
maxReadRetry
=
3
)
)
var
_
=
framework
.
KubeDescribe
(
"Pod Disks"
,
func
()
{
var
_
=
framework
.
KubeDescribe
(
"Pod Disks"
,
func
()
{
...
@@ -450,18 +451,25 @@ func deletePDWithRetry(diskName string) {
...
@@ -450,18 +451,25 @@ func deletePDWithRetry(diskName string) {
func
verifyPDContentsViaContainer
(
f
*
framework
.
Framework
,
podName
,
containerName
string
,
fileAndContentToVerify
map
[
string
]
string
)
{
func
verifyPDContentsViaContainer
(
f
*
framework
.
Framework
,
podName
,
containerName
string
,
fileAndContentToVerify
map
[
string
]
string
)
{
for
filePath
,
expectedContents
:=
range
fileAndContentToVerify
{
for
filePath
,
expectedContents
:=
range
fileAndContentToVerify
{
v
,
err
:=
f
.
ReadFileViaContainer
(
podName
,
containerName
,
filePath
)
var
v
string
if
err
!=
nil
{
// Add a retry to avoid temporal failure in reading the content
framework
.
Logf
(
"Error reading file: %v"
,
err
)
for
i
:=
0
;
i
<
maxReadRetry
;
i
++
{
}
v
,
err
:=
f
.
ReadFileViaContainer
(
podName
,
containerName
,
filePath
)
framework
.
ExpectNoError
(
err
)
framework
.
Logf
(
"Read file %q with content: %v"
,
filePath
,
v
)
if
strings
.
TrimSpace
(
v
)
!=
strings
.
TrimSpace
(
expectedContents
)
{
size
,
err
:=
f
.
CheckFileSizeViaContainer
(
podName
,
containerName
,
filePath
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Logf
(
"Error reading file: %v"
,
err
)
framework
.
Logf
(
"Error reading file: %v"
,
err
)
}
}
framework
.
Logf
(
"Check file %q size: %q"
,
filePath
,
size
)
framework
.
ExpectNoError
(
err
)
framework
.
Logf
(
"Read file %q with content: %v"
,
filePath
,
v
)
if
strings
.
TrimSpace
(
v
)
!=
strings
.
TrimSpace
(
expectedContents
)
{
framework
.
Logf
(
"Warning: read content <%q> does not match execpted content <%q>."
,
v
,
expectedContents
)
size
,
err
:=
f
.
CheckFileSizeViaContainer
(
podName
,
containerName
,
filePath
)
if
err
!=
nil
{
framework
.
Logf
(
"Error checking file size: %v"
,
err
)
}
framework
.
Logf
(
"Check file %q size: %q"
,
filePath
,
size
)
}
else
{
break
}
}
}
Expect
(
strings
.
TrimSpace
(
v
))
.
To
(
Equal
(
strings
.
TrimSpace
(
expectedContents
)))
Expect
(
strings
.
TrimSpace
(
v
))
.
To
(
Equal
(
strings
.
TrimSpace
(
expectedContents
)))
}
}
...
...
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