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
168b4563
Unverified
Commit
168b4563
authored
Jan 07, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #68792 from johnSchnake/68747-fallbackToInternalIP
e2e: Fallback to internal IPs when using SSH in tests
parents
10381305
23a7538c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
util.go
test/e2e/framework/util.go
+16
-10
No files found.
test/e2e/framework/util.go
View file @
168b4563
...
...
@@ -3373,10 +3373,6 @@ func NodeAddresses(nodelist *v1.NodeList, addrType v1.NodeAddressType) []string
hosts
:=
[]
string
{}
for
_
,
n
:=
range
nodelist
.
Items
{
for
_
,
addr
:=
range
n
.
Status
.
Addresses
{
// Use the first external IP address we find on the node, and
// use at most one per node.
// TODO(roberthbailey): Use the "preferred" address for the node, once
// such a thing is defined (#2462).
if
addr
.
Type
==
addrType
{
hosts
=
append
(
hosts
,
addr
.
Address
)
break
...
...
@@ -3386,19 +3382,29 @@ func NodeAddresses(nodelist *v1.NodeList, addrType v1.NodeAddressType) []string
return
hosts
}
// NodeSSHHosts returns SSH-able host names for all schedulable nodes - this excludes master node.
// It returns an error if it can't find an external IP for every node, though it still returns all
// hosts that it found in that case.
// NodeSSHHosts returns SSH-able host names for all schedulable nodes - this
// excludes master node. If it can't find any external IPs, it falls back to
// looking for internal IPs. If it can't find an internal IP for every node it
// returns an error, though it still returns all hosts that it found in that
// case.
func
NodeSSHHosts
(
c
clientset
.
Interface
)
([]
string
,
error
)
{
nodelist
:=
waitListSchedulableNodesOrDie
(
c
)
// TODO(roberthbailey): Use the "preferred" address for the node, once such a thing is defined (#2462).
hosts
:=
NodeAddresses
(
nodelist
,
v1
.
NodeExternalIP
)
// If ExternalIPs aren't set, assume the test programs can reach the
// InternalIP. Simplified exception logic here assumes that the hosts will
// either all have ExternalIP or none will. Simplifies handling here and
// should be adequate since the setting of the external IPs is provider
// specific: they should either all have them or none of them will.
if
len
(
hosts
)
==
0
{
Logf
(
"No external IP address on nodes, falling back to internal IPs"
)
hosts
=
NodeAddresses
(
nodelist
,
v1
.
NodeInternalIP
)
}
// Error if any node didn't have an external IP.
// Error if any node didn't have an external
/internal
IP.
if
len
(
hosts
)
!=
len
(
nodelist
.
Items
)
{
return
hosts
,
fmt
.
Errorf
(
"only found %d
external
IPs on nodes, but found %d nodes. Nodelist: %v"
,
"only found %d IPs on nodes, but found %d nodes. Nodelist: %v"
,
len
(
hosts
),
len
(
nodelist
.
Items
),
nodelist
)
}
...
...
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