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
c3f591a3
Commit
c3f591a3
authored
Oct 07, 2016
by
Bowei Du
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add retry loop around check for /etc/hosts contents to work around issue #34256
See
https://github.com/kubernetes/kubernetes/issues/34256
parent
c23346f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
27 deletions
+14
-27
kubelet_etc_hosts.go
test/e2e/common/kubelet_etc_hosts.go
+14
-27
No files found.
test/e2e/common/kubelet_etc_hosts.go
View file @
c3f591a3
...
...
@@ -87,31 +87,25 @@ func (config *KubeletManagedHostConfig) createPodWithHostNetwork() {
func
assertManagedStatus
(
config
*
KubeletManagedHostConfig
,
podName
string
,
expectedIsManaged
bool
,
name
string
)
{
//
See https://github.com/kubernetes/kubernetes/issues/27023
//
TODO: workaround for https://github.com/kubernetes/kubernetes/issues/34256
//
// Retry until timeout for the right contents of /etc/hosts to show
// up. There may be a low probability race here. We still fail the
// test if retry was necessary, but at least we will know whether or
// not it resolves or seems to be a permanent condition.
//
// If /etc/hosts is properly mounted, then this will succeed
// immediately.
// Retry until timeout for the contents of /etc/hosts to show
// up. Note: if /etc/hosts is properly mounted, then this will
// succeed immediately.
const
retryTimeout
=
30
*
time
.
Second
retryCount
:=
0
etcHostsContent
:=
""
matched
:=
false
for
startTime
:=
time
.
Now
();
time
.
Since
(
startTime
)
<
retryTimeout
;
{
etcHostsContent
=
config
.
getEtcHostsContent
(
podName
,
name
)
isManaged
:=
strings
.
Contains
(
etcHostsContent
,
etcHostsPartialContent
)
if
expectedIsManaged
==
isManaged
{
matched
=
true
break
return
}
glog
.
Error
f
(
glog
.
Warning
f
(
"For pod: %s, name: %s, expected %t, actual %t (/etc/hosts was %q), retryCount: %d"
,
podName
,
name
,
expectedIsManaged
,
isManaged
,
etcHostsContent
,
retryCount
)
...
...
@@ -119,21 +113,14 @@ func assertManagedStatus(
time
.
Sleep
(
100
*
time
.
Millisecond
)
}
if
retryCount
>
0
{
if
matched
{
conditionText
:=
"should"
if
!
expectedIsManaged
{
conditionText
=
"should not"
}
framework
.
Failf
(
"/etc/hosts file %s be kubelet managed (name: %s, retries: %d). /etc/hosts contains %q"
,
conditionText
,
name
,
retryCount
,
etcHostsContent
)
}
else
{
framework
.
Failf
(
"had to retry %d times to get matching content in /etc/hosts (name: %s)"
,
retryCount
,
name
)
}
if
expectedIsManaged
{
framework
.
Failf
(
"/etc/hosts file should be kubelet managed (name: %s, retries: %d). /etc/hosts contains %q"
,
name
,
retryCount
,
etcHostsContent
)
}
else
{
framework
.
Failf
(
"/etc/hosts file should no be kubelet managed (name: %s, retries: %d). /etc/hosts contains %q"
,
name
,
retryCount
,
etcHostsContent
)
}
}
...
...
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