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
054b4a79
Commit
054b4a79
authored
May 02, 2018
by
Ashley Gau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check for new backend naming scheme
parent
c9591ee6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
19 deletions
+42
-19
ingress_utils.go
test/e2e/framework/ingress_utils.go
+36
-13
ingress.go
test/e2e/network/ingress.go
+6
-6
No files found.
test/e2e/framework/ingress_utils.go
View file @
054b4a79
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"bytes"
"bytes"
"crypto/rand"
"crypto/rand"
"crypto/rsa"
"crypto/rsa"
"crypto/sha256"
"crypto/tls"
"crypto/tls"
"crypto/x509"
"crypto/x509"
"crypto/x509/pkix"
"crypto/x509/pkix"
...
@@ -907,28 +908,38 @@ func (cont *GCEIngressController) isHTTPErrorCode(err error, code int) bool {
...
@@ -907,28 +908,38 @@ func (cont *GCEIngressController) isHTTPErrorCode(err error, code int) bool {
}
}
// BackendServiceUsingNEG returns true only if all global backend service with matching nodeports pointing to NEG as backend
// BackendServiceUsingNEG returns true only if all global backend service with matching nodeports pointing to NEG as backend
func
(
cont
*
GCEIngressController
)
BackendServiceUsingNEG
(
nodeports
[]
string
)
(
bool
,
error
)
{
func
(
cont
*
GCEIngressController
)
BackendServiceUsingNEG
(
svcPorts
map
[
string
]
v1
.
ServicePort
)
(
bool
,
error
)
{
return
cont
.
backendMode
(
nodep
orts
,
"networkEndpointGroups"
)
return
cont
.
backendMode
(
svcP
orts
,
"networkEndpointGroups"
)
}
}
// BackendServiceUsingIG returns true only if all global backend service with matching
nodep
orts pointing to IG as backend
// BackendServiceUsingIG returns true only if all global backend service with matching
svcP
orts pointing to IG as backend
func
(
cont
*
GCEIngressController
)
BackendServiceUsingIG
(
nodeports
[]
string
)
(
bool
,
error
)
{
func
(
cont
*
GCEIngressController
)
BackendServiceUsingIG
(
svcPorts
map
[
string
]
v1
.
ServicePort
)
(
bool
,
error
)
{
return
cont
.
backendMode
(
nodep
orts
,
"instanceGroups"
)
return
cont
.
backendMode
(
svcP
orts
,
"instanceGroups"
)
}
}
func
(
cont
*
GCEIngressController
)
backendMode
(
nodeports
[]
string
,
keyword
string
)
(
bool
,
error
)
{
func
(
cont
*
GCEIngressController
)
backendMode
(
svcPorts
map
[
string
]
v1
.
ServicePort
,
keyword
string
)
(
bool
,
error
)
{
gceCloud
:=
cont
.
Cloud
.
Provider
.
(
*
gcecloud
.
GCECloud
)
gceCloud
:=
cont
.
Cloud
.
Provider
.
(
*
gcecloud
.
GCECloud
)
beList
,
err
:=
gceCloud
.
ListGlobalBackendServices
()
beList
,
err
:=
gceCloud
.
ListGlobalBackendServices
()
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"failed to list backend services: %v"
,
err
)
return
false
,
fmt
.
Errorf
(
"failed to list backend services: %v"
,
err
)
}
}
uid
:=
cont
.
UID
if
len
(
uid
)
>
8
{
uid
=
uid
[
:
8
]
}
matchingBackendService
:=
0
matchingBackendService
:=
0
for
_
,
bs
:=
range
beList
{
for
_
,
bs
:=
range
beList
{
match
:=
false
match
:=
false
for
_
,
np
:=
range
nodeports
{
for
svcName
,
sp
:=
range
svcPorts
{
// Warning: This assumes backend service naming convention includes nodeport in the name
// Non-NEG BackendServices are named with the Nodeport in the name.
if
strings
.
Contains
(
bs
.
Name
,
np
)
{
// NEG BackendServices' names contain the a sha256 hash of a string.
negString
:=
strings
.
Join
([]
string
{
uid
,
cont
.
Ns
,
svcName
,
sp
.
TargetPort
.
String
()},
";"
)
negHash
:=
fmt
.
Sprintf
(
"%x"
,
sha256
.
Sum256
([]
byte
(
negString
)))[
:
8
]
if
strings
.
Contains
(
bs
.
Name
,
strconv
.
Itoa
(
int
(
sp
.
NodePort
)))
||
strings
.
Contains
(
bs
.
Name
,
negHash
)
{
match
=
true
match
=
true
matchingBackendService
+=
1
matchingBackendService
+=
1
}
}
...
@@ -941,7 +952,7 @@ func (cont *GCEIngressController) backendMode(nodeports []string, keyword string
...
@@ -941,7 +952,7 @@ func (cont *GCEIngressController) backendMode(nodeports []string, keyword string
}
}
}
}
}
}
return
matchingBackendService
==
len
(
nodep
orts
),
nil
return
matchingBackendService
==
len
(
svcP
orts
),
nil
}
}
// Cleanup cleans up cloud resources.
// Cleanup cleans up cloud resources.
...
@@ -1480,10 +1491,22 @@ func (j *IngressTestJig) GetDefaultBackendNodePort() (int32, error) {
...
@@ -1480,10 +1491,22 @@ func (j *IngressTestJig) GetDefaultBackendNodePort() (int32, error) {
// by default, so retrieve its nodePort if includeDefaultBackend is true.
// by default, so retrieve its nodePort if includeDefaultBackend is true.
func
(
j
*
IngressTestJig
)
GetIngressNodePorts
(
includeDefaultBackend
bool
)
[]
string
{
func
(
j
*
IngressTestJig
)
GetIngressNodePorts
(
includeDefaultBackend
bool
)
[]
string
{
nodePorts
:=
[]
string
{}
nodePorts
:=
[]
string
{}
svcPorts
:=
j
.
GetServicePorts
(
includeDefaultBackend
)
for
_
,
svcPort
:=
range
svcPorts
{
nodePorts
=
append
(
nodePorts
,
strconv
.
Itoa
(
int
(
svcPort
.
NodePort
)))
}
return
nodePorts
}
// GetIngressNodePorts returns related backend services' svcPorts.
// Current GCE ingress controller allows traffic to the default HTTP backend
// by default, so retrieve its nodePort if includeDefaultBackend is true.
func
(
j
*
IngressTestJig
)
GetServicePorts
(
includeDefaultBackend
bool
)
map
[
string
]
v1
.
ServicePort
{
svcPorts
:=
make
(
map
[
string
]
v1
.
ServicePort
)
if
includeDefaultBackend
{
if
includeDefaultBackend
{
defaultSvc
,
err
:=
j
.
Client
.
CoreV1
()
.
Services
(
metav1
.
NamespaceSystem
)
.
Get
(
defaultBackendName
,
metav1
.
GetOptions
{})
defaultSvc
,
err
:=
j
.
Client
.
CoreV1
()
.
Services
(
metav1
.
NamespaceSystem
)
.
Get
(
defaultBackendName
,
metav1
.
GetOptions
{})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
nodePorts
=
append
(
nodePorts
,
strconv
.
Itoa
(
int
(
defaultSvc
.
Spec
.
Ports
[
0
]
.
NodePort
)))
svcPorts
[
defaultBackendName
]
=
defaultSvc
.
Spec
.
Ports
[
0
]
}
}
backendSvcs
:=
[]
string
{}
backendSvcs
:=
[]
string
{}
...
@@ -1498,9 +1521,9 @@ func (j *IngressTestJig) GetIngressNodePorts(includeDefaultBackend bool) []strin
...
@@ -1498,9 +1521,9 @@ func (j *IngressTestJig) GetIngressNodePorts(includeDefaultBackend bool) []strin
for
_
,
svcName
:=
range
backendSvcs
{
for
_
,
svcName
:=
range
backendSvcs
{
svc
,
err
:=
j
.
Client
.
CoreV1
()
.
Services
(
j
.
Ingress
.
Namespace
)
.
Get
(
svcName
,
metav1
.
GetOptions
{})
svc
,
err
:=
j
.
Client
.
CoreV1
()
.
Services
(
j
.
Ingress
.
Namespace
)
.
Get
(
svcName
,
metav1
.
GetOptions
{})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
nodePorts
=
append
(
nodePorts
,
strconv
.
Itoa
(
int
(
svc
.
Spec
.
Ports
[
0
]
.
NodePort
)))
svcPorts
[
svcName
]
=
svc
.
Spec
.
Ports
[
0
]
}
}
return
node
Ports
return
svc
Ports
}
}
// ConstructFirewallForIngress returns the expected GCE firewall rule for the ingress resource
// ConstructFirewallForIngress returns the expected GCE firewall rule for the ingress resource
...
...
test/e2e/network/ingress.go
View file @
054b4a79
...
@@ -497,7 +497,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -497,7 +497,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
t
.
Execute
()
t
.
Execute
()
By
(
t
.
ExitLog
)
By
(
t
.
ExitLog
)
jig
.
WaitForIngress
(
true
)
jig
.
WaitForIngress
(
true
)
usingNeg
,
err
:=
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
IngressNod
ePorts
(
false
))
usingNeg
,
err
:=
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
Servic
ePorts
(
false
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
usingNeg
)
.
To
(
BeTrue
())
Expect
(
usingNeg
)
.
To
(
BeTrue
())
}
}
...
@@ -508,7 +508,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -508,7 +508,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
By
(
"Create a basic HTTP ingress using NEG"
)
By
(
"Create a basic HTTP ingress using NEG"
)
jig
.
CreateIngress
(
filepath
.
Join
(
framework
.
IngressManifestPath
,
"neg"
),
ns
,
map
[
string
]
string
{},
map
[
string
]
string
{})
jig
.
CreateIngress
(
filepath
.
Join
(
framework
.
IngressManifestPath
,
"neg"
),
ns
,
map
[
string
]
string
{},
map
[
string
]
string
{})
jig
.
WaitForIngress
(
true
)
jig
.
WaitForIngress
(
true
)
usingNEG
,
err
:=
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
IngressNod
ePorts
(
false
))
usingNEG
,
err
:=
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
Servic
ePorts
(
false
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
usingNEG
)
.
To
(
BeTrue
())
Expect
(
usingNEG
)
.
To
(
BeTrue
())
...
@@ -521,7 +521,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -521,7 +521,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
}
wait
.
Poll
(
5
*
time
.
Second
,
framework
.
LoadBalancerPollTimeout
,
func
()
(
bool
,
error
)
{
wait
.
Poll
(
5
*
time
.
Second
,
framework
.
LoadBalancerPollTimeout
,
func
()
(
bool
,
error
)
{
return
gceController
.
BackendServiceUsingIG
(
jig
.
Get
IngressNod
ePorts
(
true
))
return
gceController
.
BackendServiceUsingIG
(
jig
.
Get
Servic
ePorts
(
true
))
})
})
jig
.
WaitForIngress
(
true
)
jig
.
WaitForIngress
(
true
)
...
@@ -534,7 +534,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -534,7 +534,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
}
wait
.
Poll
(
5
*
time
.
Second
,
framework
.
LoadBalancerPollTimeout
,
func
()
(
bool
,
error
)
{
wait
.
Poll
(
5
*
time
.
Second
,
framework
.
LoadBalancerPollTimeout
,
func
()
(
bool
,
error
)
{
return
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
IngressNod
ePorts
(
false
))
return
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
Servic
ePorts
(
false
))
})
})
jig
.
WaitForIngress
(
true
)
jig
.
WaitForIngress
(
true
)
})
})
...
@@ -561,7 +561,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -561,7 +561,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
By
(
"Create a basic HTTP ingress using NEG"
)
By
(
"Create a basic HTTP ingress using NEG"
)
jig
.
CreateIngress
(
filepath
.
Join
(
framework
.
IngressManifestPath
,
"neg"
),
ns
,
map
[
string
]
string
{},
map
[
string
]
string
{})
jig
.
CreateIngress
(
filepath
.
Join
(
framework
.
IngressManifestPath
,
"neg"
),
ns
,
map
[
string
]
string
{},
map
[
string
]
string
{})
jig
.
WaitForIngress
(
true
)
jig
.
WaitForIngress
(
true
)
usingNEG
,
err
:=
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
IngressNod
ePorts
(
false
))
usingNEG
,
err
:=
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
Servic
ePorts
(
false
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
usingNEG
)
.
To
(
BeTrue
())
Expect
(
usingNEG
)
.
To
(
BeTrue
())
// initial replicas number is 1
// initial replicas number is 1
...
@@ -586,7 +586,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -586,7 +586,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
By
(
"Create a basic HTTP ingress using NEG"
)
By
(
"Create a basic HTTP ingress using NEG"
)
jig
.
CreateIngress
(
filepath
.
Join
(
framework
.
IngressManifestPath
,
"neg"
),
ns
,
map
[
string
]
string
{},
map
[
string
]
string
{})
jig
.
CreateIngress
(
filepath
.
Join
(
framework
.
IngressManifestPath
,
"neg"
),
ns
,
map
[
string
]
string
{},
map
[
string
]
string
{})
jig
.
WaitForIngress
(
true
)
jig
.
WaitForIngress
(
true
)
usingNEG
,
err
:=
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
IngressNod
ePorts
(
false
))
usingNEG
,
err
:=
gceController
.
BackendServiceUsingNEG
(
jig
.
Get
Servic
ePorts
(
false
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
usingNEG
)
.
To
(
BeTrue
())
Expect
(
usingNEG
)
.
To
(
BeTrue
())
...
...
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