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
acef505c
Commit
acef505c
authored
Jul 23, 2015
by
Max Forbes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement 'Nodes Network' test for GKE; add optional verbose SSH.
parent
9f495e7f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
27 deletions
+54
-27
util.sh
cluster/gke/util.sh
+2
-3
ginkgo-e2e.sh
hack/ginkgo-e2e.sh
+1
-1
resize_nodes.go
test/e2e/resize_nodes.go
+25
-21
util.go
test/e2e/util.go
+26
-2
No files found.
cluster/gke/util.sh
View file @
acef505c
...
@@ -210,18 +210,17 @@ function get-password() {
...
@@ -210,18 +210,17 @@ function get-password() {
|
grep
password |
cut
-f
4
-d
' '
)
|
grep
password |
cut
-f
4
-d
' '
)
}
}
# Detect the instance name and IP for the master
# Detect the IP for the master. Note that on GKE, we don't know the name of the
# master, so KUBE_MASTER is not set.
#
#
# Assumed vars:
# Assumed vars:
# ZONE
# ZONE
# CLUSTER_NAME
# CLUSTER_NAME
# Vars set:
# Vars set:
# KUBE_MASTER
# KUBE_MASTER_IP
# KUBE_MASTER_IP
function
detect-master
()
{
function
detect-master
()
{
echo
"... in gke:detect-master()"
>
&2
echo
"... in gke:detect-master()"
>
&2
detect-project
>
&2
detect-project
>
&2
KUBE_MASTER
=
"k8s-
${
CLUSTER_NAME
}
-master"
KUBE_MASTER_IP
=
$(
"
${
GCLOUD
}
"
"
${
CMD_GROUP
}
"
container clusters describe
\
KUBE_MASTER_IP
=
$(
"
${
GCLOUD
}
"
"
${
CMD_GROUP
}
"
container clusters describe
\
--project
=
"
${
PROJECT
}
"
--zone
=
"
${
ZONE
}
"
"
${
CLUSTER_NAME
}
"
\
--project
=
"
${
PROJECT
}
"
--zone
=
"
${
ZONE
}
"
"
${
CLUSTER_NAME
}
"
\
|
grep
endpoint |
cut
-f
2
-d
' '
)
|
grep
endpoint |
cut
-f
2
-d
' '
)
...
...
hack/ginkgo-e2e.sh
View file @
acef505c
...
@@ -89,7 +89,7 @@ fi
...
@@ -89,7 +89,7 @@ fi
export
PATH
=
$(
dirname
"
${
e2e_test
}
"
)
:
"
${
PATH
}
"
export
PATH
=
$(
dirname
"
${
e2e_test
}
"
)
:
"
${
PATH
}
"
"
${
ginkgo
}
"
"
${
ginkgo_args
[@]
:+
${
ginkgo_args
[@]
}}
"
"
${
e2e_test
}
"
--
\
"
${
ginkgo
}
"
"
${
ginkgo_args
[@]
:+
${
ginkgo_args
[@]
}}
"
"
${
e2e_test
}
"
--
\
"
${
auth_config
[@]
:+
${
auth_config
[@]
}}
"
\
"
${
auth_config
[@]
:+
${
auth_config
[@]
}}
"
\
--host
=
"https://
${
KUBE_MASTER_IP
-
}
"
\
--host
=
"https://
${
KUBE_MASTER_IP
:
-}
"
\
--provider
=
"
${
KUBERNETES_PROVIDER
}
"
\
--provider
=
"
${
KUBERNETES_PROVIDER
}
"
\
--gce-project
=
"
${
PROJECT
:-}
"
\
--gce-project
=
"
${
PROJECT
:-}
"
\
--gce-zone
=
"
${
ZONE
:-}
"
\
--gce-zone
=
"
${
ZONE
:-}
"
\
...
...
test/e2e/resize_nodes.go
View file @
acef505c
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"fmt"
"fmt"
"os/exec"
"os/exec"
"regexp"
"regexp"
"strings"
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
...
@@ -35,10 +36,11 @@ import (
...
@@ -35,10 +36,11 @@ import (
"k8s.io/kubernetes/pkg/cloudprovider/aws"
"k8s.io/kubernetes/pkg/cloudprovider/aws"
)
)
const
serveHostnameImage
=
"gcr.io/google_containers/serve_hostname:1.1"
const
(
serveHostnameImage
=
"gcr.io/google_containers/serve_hostname:1.1"
const
resizeNodeReadyTimeout
=
2
*
time
.
Minute
resizeNodeReadyTimeout
=
2
*
time
.
Minute
const
resizeNodeNotReadyTimeout
=
2
*
time
.
Minute
resizeNodeNotReadyTimeout
=
2
*
time
.
Minute
)
func
resizeGroup
(
size
int
)
error
{
func
resizeGroup
(
size
int
)
error
{
if
testContext
.
Provider
==
"gce"
||
testContext
.
Provider
==
"gke"
{
if
testContext
.
Provider
==
"gce"
||
testContext
.
Provider
==
"gke"
{
...
@@ -312,23 +314,25 @@ func performTemporaryNetworkFailure(c *client.Client, ns, rcName string, replica
...
@@ -312,23 +314,25 @@ func performTemporaryNetworkFailure(c *client.Client, ns, rcName string, replica
if
host
==
""
{
if
host
==
""
{
Failf
(
"Couldn't get the external IP of host %s with addresses %v"
,
node
.
Name
,
node
.
Status
.
Addresses
)
Failf
(
"Couldn't get the external IP of host %s with addresses %v"
,
node
.
Name
,
node
.
Status
.
Addresses
)
}
}
By
(
fmt
.
Sprintf
(
"block network traffic from node %s to the master"
,
node
.
Name
))
// TODO marekbiskup 2015-06-19 #10085
By
(
fmt
.
Sprintf
(
"block network traffic from node %s to the master"
,
node
.
Name
))
// The use of MasterName will cause iptables to do a DNS lookup to
master
:=
""
// resolve the name to an IP address, which will slow down the test
switch
testContext
.
Provider
{
// and cause it to fail if DNS is absent or broken.
case
"gce"
:
// Use the IP address instead.
// TODO(#10085): The use of MasterName will cause iptables to do a DNS
// lookup to resolve the name to an IP address, which will slow down the
destination
:=
testContext
.
CloudConfig
.
MasterName
// test and cause it to fail if DNS is absent or broken. Use the
if
providerIs
(
"aws"
)
{
// internal IP address instead (i.e. NOT the one in testContext.Host).
// This is the (internal) IP address used on AWS for the master
master
=
testContext
.
CloudConfig
.
MasterName
// TODO: Use IP address for all clouds?
case
"gke"
:
// TODO: Avoid hard-coding this
master
=
strings
.
TrimPrefix
(
testContext
.
Host
,
"https://"
)
destination
=
"172.20.0.9"
case
"aws"
:
// TODO(justinsb): Avoid hardcoding this.
master
=
"172.20.0.9"
default
:
Failf
(
"This test is not supported for provider %s and should be disabled"
,
testContext
.
Provider
)
}
}
iptablesRule
:=
fmt
.
Sprintf
(
"OUTPUT --destination %s --jump DROP"
,
master
)
iptablesRule
:=
fmt
.
Sprintf
(
"OUTPUT --destination %s --jump DROP"
,
destination
)
defer
func
()
{
defer
func
()
{
// This code will execute even if setting the iptables rule failed.
// This code will execute even if setting the iptables rule failed.
// It is on purpose because we may have an error even if the new rule
// It is on purpose because we may have an error even if the new rule
...
@@ -344,7 +348,7 @@ func performTemporaryNetworkFailure(c *client.Client, ns, rcName string, replica
...
@@ -344,7 +348,7 @@ func performTemporaryNetworkFailure(c *client.Client, ns, rcName string, replica
// may fail). Manual intervention is required in such case (recreating the
// may fail). Manual intervention is required in such case (recreating the
// cluster solves the problem too).
// cluster solves the problem too).
err
:=
wait
.
Poll
(
time
.
Millisecond
*
100
,
time
.
Second
*
30
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
(
time
.
Millisecond
*
100
,
time
.
Second
*
30
,
func
()
(
bool
,
error
)
{
_
,
_
,
code
,
err
:=
SSH
(
undropCmd
,
host
,
testContext
.
Provider
)
_
,
_
,
code
,
err
:=
SSH
Verbose
(
undropCmd
,
host
,
testContext
.
Provider
)
if
code
==
0
&&
err
==
nil
{
if
code
==
0
&&
err
==
nil
{
return
true
,
nil
return
true
,
nil
}
else
{
}
else
{
...
@@ -370,7 +374,7 @@ func performTemporaryNetworkFailure(c *client.Client, ns, rcName string, replica
...
@@ -370,7 +374,7 @@ func performTemporaryNetworkFailure(c *client.Client, ns, rcName string, replica
// We could also block network traffic from the master(s) to this node,
// We could also block network traffic from the master(s) to this node,
// but blocking it one way is sufficient for this test.
// but blocking it one way is sufficient for this test.
dropCmd
:=
fmt
.
Sprintf
(
"sudo iptables --insert %s"
,
iptablesRule
)
dropCmd
:=
fmt
.
Sprintf
(
"sudo iptables --insert %s"
,
iptablesRule
)
if
_
,
_
,
code
,
err
:=
SSH
(
dropCmd
,
host
,
testContext
.
Provider
);
code
!=
0
||
err
!=
nil
{
if
_
,
_
,
code
,
err
:=
SSH
Verbose
(
dropCmd
,
host
,
testContext
.
Provider
);
code
!=
0
||
err
!=
nil
{
Failf
(
"Expected 0 exit code and nil error when running %s on %s, got %d and %v"
,
Failf
(
"Expected 0 exit code and nil error when running %s on %s, got %d and %v"
,
dropCmd
,
node
.
Name
,
code
,
err
)
dropCmd
,
node
.
Name
,
code
,
err
)
}
}
...
...
test/e2e/util.go
View file @
acef505c
...
@@ -1480,15 +1480,39 @@ func NodeSSHHosts(c *client.Client) ([]string, error) {
...
@@ -1480,15 +1480,39 @@ func NodeSSHHosts(c *client.Client) ([]string, error) {
// is no error performing the SSH, the stdout, stderr, and exit code are
// is no error performing the SSH, the stdout, stderr, and exit code are
// returned.
// returned.
func
SSH
(
cmd
,
host
,
provider
string
)
(
string
,
string
,
int
,
error
)
{
func
SSH
(
cmd
,
host
,
provider
string
)
(
string
,
string
,
int
,
error
)
{
return
sshCore
(
cmd
,
host
,
provider
,
false
)
}
// SSHVerbose is just like SSH, but it logs the command, user, host, stdout,
// stderr, exit code, and error.
func
SSHVerbose
(
cmd
,
host
,
provider
string
)
(
string
,
string
,
int
,
error
)
{
return
sshCore
(
cmd
,
host
,
provider
,
true
)
}
func
sshCore
(
cmd
,
host
,
provider
string
,
verbose
bool
)
(
string
,
string
,
int
,
error
)
{
// Get a signer for the provider.
// Get a signer for the provider.
signer
,
err
:=
getSigner
(
provider
)
signer
,
err
:=
getSigner
(
provider
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
""
,
0
,
fmt
.
Errorf
(
"error getting signer for provider %s: '%v'"
,
provider
,
err
)
return
""
,
""
,
0
,
fmt
.
Errorf
(
"error getting signer for provider %s: '%v'"
,
provider
,
err
)
}
}
// RunSSHCommand will default to Getenv("USER") if user == "", but we're
// defaulting here as well for logging clarity.
user
:=
os
.
Getenv
(
"KUBE_SSH_USER"
)
user
:=
os
.
Getenv
(
"KUBE_SSH_USER"
)
// RunSSHCommand will default to Getenv("USER") if user == ""
if
user
==
""
{
return
util
.
RunSSHCommand
(
cmd
,
user
,
host
,
signer
)
user
=
os
.
Getenv
(
"USER"
)
}
stdout
,
stderr
,
code
,
err
:=
util
.
RunSSHCommand
(
cmd
,
user
,
host
,
signer
)
if
verbose
{
remote
:=
fmt
.
Sprintf
(
"%s@%s"
,
user
,
host
)
Logf
(
"[%s] Running `%s`"
,
remote
,
cmd
)
Logf
(
"[%s] stdout: %q"
,
remote
,
stdout
)
Logf
(
"[%s] stderr: %q"
,
remote
,
stderr
)
Logf
(
"[%s] exit code: %d"
,
remote
,
code
)
Logf
(
"[%s] error: %v"
,
remote
,
err
)
}
return
stdout
,
stderr
,
code
,
err
}
}
// getSigner returns an ssh.Signer for the provider ("gce", etc.) that can be
// getSigner returns an ssh.Signer for the provider ("gce", etc.) that can be
...
...
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