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
e4ee8871
Unverified
Commit
e4ee8871
authored
Nov 15, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 15, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69303 from appian/host_aliases_on_same_line
Write HostAliases aliases on same line per host IP
parents
7cf211d7
ab507dfc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
23 deletions
+9
-23
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+2
-4
kubelet_pods_test.go
pkg/kubelet/kubelet_pods_test.go
+6
-18
kubelet.go
test/e2e/common/kubelet.go
+1
-1
No files found.
pkg/kubelet/kubelet_pods.go
View file @
e4ee8871
...
@@ -356,11 +356,9 @@ func hostsEntriesFromHostAliases(hostAliases []v1.HostAlias) []byte {
...
@@ -356,11 +356,9 @@ func hostsEntriesFromHostAliases(hostAliases []v1.HostAlias) []byte {
var
buffer
bytes
.
Buffer
var
buffer
bytes
.
Buffer
buffer
.
WriteString
(
"
\n
"
)
buffer
.
WriteString
(
"
\n
"
)
buffer
.
WriteString
(
"# Entries added by HostAliases.
\n
"
)
buffer
.
WriteString
(
"# Entries added by HostAliases.
\n
"
)
//
write each IP/hostname pair as an entry into
hosts file
//
for each IP, write all aliases onto single line in
hosts file
for
_
,
hostAlias
:=
range
hostAliases
{
for
_
,
hostAlias
:=
range
hostAliases
{
for
_
,
hostname
:=
range
hostAlias
.
Hostnames
{
buffer
.
WriteString
(
fmt
.
Sprintf
(
"%s
\t
%s
\n
"
,
hostAlias
.
IP
,
strings
.
Join
(
hostAlias
.
Hostnames
,
"
\t
"
)))
buffer
.
WriteString
(
fmt
.
Sprintf
(
"%s
\t
%s
\n
"
,
hostAlias
.
IP
,
hostname
))
}
}
}
return
buffer
.
Bytes
()
return
buffer
.
Bytes
()
}
}
...
...
pkg/kubelet/kubelet_pods_test.go
View file @
e4ee8871
...
@@ -183,9 +183,7 @@ fe00::2 ip6-allrouters
...
@@ -183,9 +183,7 @@ fe00::2 ip6-allrouters
123.45.67.89 some.domain
123.45.67.89 some.domain
# Entries added by HostAliases.
# Entries added by HostAliases.
123.45.67.89 foo
123.45.67.89 foo bar baz
123.45.67.89 bar
123.45.67.89 baz
`
,
`
,
},
},
{
{
...
@@ -214,12 +212,8 @@ fe00::2 ip6-allrouters
...
@@ -214,12 +212,8 @@ fe00::2 ip6-allrouters
12.34.56.78 another.domain
12.34.56.78 another.domain
# Entries added by HostAliases.
# Entries added by HostAliases.
123.45.67.89 foo
123.45.67.89 foo bar baz
123.45.67.89 bar
456.78.90.123 park doo boo
123.45.67.89 baz
456.78.90.123 park
456.78.90.123 doo
456.78.90.123 boo
`
,
`
,
},
},
}
}
...
@@ -300,9 +294,7 @@ fe00::2 ip6-allrouters
...
@@ -300,9 +294,7 @@ fe00::2 ip6-allrouters
203.0.113.1 podFoo.domainFoo podFoo
203.0.113.1 podFoo.domainFoo podFoo
# Entries added by HostAliases.
# Entries added by HostAliases.
123.45.67.89 foo
123.45.67.89 foo bar baz
123.45.67.89 bar
123.45.67.89 baz
`
,
`
,
},
},
{
{
...
@@ -323,12 +315,8 @@ fe00::2 ip6-allrouters
...
@@ -323,12 +315,8 @@ fe00::2 ip6-allrouters
203.0.113.1 podFoo.domainFoo podFoo
203.0.113.1 podFoo.domainFoo podFoo
# Entries added by HostAliases.
# Entries added by HostAliases.
123.45.67.89 foo
123.45.67.89 foo bar baz
123.45.67.89 bar
456.78.90.123 park doo boo
123.45.67.89 baz
456.78.90.123 park
456.78.90.123 doo
456.78.90.123 boo
`
,
`
,
},
},
}
}
...
...
test/e2e/common/kubelet.go
View file @
e4ee8871
...
@@ -175,7 +175,7 @@ var _ = framework.KubeDescribe("Kubelet", func() {
...
@@ -175,7 +175,7 @@ var _ = framework.KubeDescribe("Kubelet", func() {
buf
.
ReadFrom
(
rc
)
buf
.
ReadFrom
(
rc
)
hostsFileContent
:=
buf
.
String
()
hostsFileContent
:=
buf
.
String
()
if
!
strings
.
Contains
(
hostsFileContent
,
"123.45.67.89
\t
foo
"
)
||
!
strings
.
Contains
(
hostsFileContent
,
"123.45.67.89
\t
bar"
)
{
if
!
strings
.
Contains
(
hostsFileContent
,
"123.45.67.89
\t
foo
\t
bar"
)
{
return
fmt
.
Errorf
(
"expected hosts file to contain entries from HostAliases. Got:
\n
%+v"
,
hostsFileContent
)
return
fmt
.
Errorf
(
"expected hosts file to contain entries from HostAliases. Got:
\n
%+v"
,
hostsFileContent
)
}
}
...
...
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