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
968d8336
Unverified
Commit
968d8336
authored
Mar 08, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75073 from grayluck/esipp
Allow session affinity a period of time to setup for new services.
parents
41b544bc
70c42380
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
20 deletions
+14
-20
service_util.go
test/e2e/framework/service_util.go
+8
-14
service.go
test/e2e/network/service.go
+6
-6
No files found.
test/e2e/framework/service_util.go
View file @
968d8336
...
...
@@ -1453,6 +1453,7 @@ type affinityTracker struct {
// Record the response going to a given host.
func
(
at
*
affinityTracker
)
recordHost
(
host
string
)
{
at
.
hostTrace
=
append
(
at
.
hostTrace
,
host
)
Logf
(
"Received response from host: %s"
,
host
)
}
// Check that we got a constant count requests going to the same host.
...
...
@@ -1480,13 +1481,11 @@ func checkAffinityFailed(tracker affinityTracker, err string) {
}
// CheckAffinity function tests whether the service affinity works as expected.
// If affinity is expected and transitionState is true, the test will
// return true once affinityConfirmCount number of same response observed in a
// row. If affinity is not expected, the test will keep observe until different
// responses observed. The function will return false only when no expected
// responses observed before timeout. If transitionState is false, the test will
// fail once different host is given if shouldHold is true.
func
CheckAffinity
(
jig
*
ServiceTestJig
,
execPod
*
v1
.
Pod
,
targetIp
string
,
targetPort
int
,
shouldHold
,
transitionState
bool
)
bool
{
// If affinity is expected, the test will return true once affinityConfirmCount
// number of same response observed in a row. If affinity is not expected, the
// test will keep observe until different responses observed. The function will
// return false only in case of unexpected errors.
func
CheckAffinity
(
jig
*
ServiceTestJig
,
execPod
*
v1
.
Pod
,
targetIp
string
,
targetPort
int
,
shouldHold
bool
)
bool
{
targetIpPort
:=
net
.
JoinHostPort
(
targetIp
,
strconv
.
Itoa
(
targetPort
))
cmd
:=
fmt
.
Sprintf
(
`wget -qO- http://%s/ -T 2`
,
targetIpPort
)
timeout
:=
ServiceTestTimeout
...
...
@@ -1510,13 +1509,8 @@ func CheckAffinity(jig *ServiceTestJig, execPod *v1.Pod, targetIp string, target
if
!
shouldHold
&&
!
affinityHolds
{
return
true
,
nil
}
if
shouldHold
{
if
!
transitionState
&&
!
affinityHolds
{
return
true
,
fmt
.
Errorf
(
"Affinity should hold but didn't."
)
}
if
trackerFulfilled
&&
affinityHolds
{
return
true
,
nil
}
if
shouldHold
&&
trackerFulfilled
&&
affinityHolds
{
return
true
,
nil
}
return
false
,
nil
});
pollErr
!=
nil
{
...
...
test/e2e/network/service.go
View file @
968d8336
...
...
@@ -2200,17 +2200,17 @@ func execAffinityTestForNonLBService(f *framework.Framework, cs clientset.Interf
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"failed to fetch pod: %s in namespace: %s"
,
execPodName
,
ns
)
if
!
isTransitionTest
{
Expect
(
framework
.
CheckAffinity
(
jig
,
execPod
,
svcIp
,
servicePort
,
true
,
false
))
.
To
(
BeTrue
())
Expect
(
framework
.
CheckAffinity
(
jig
,
execPod
,
svcIp
,
servicePort
,
true
))
.
To
(
BeTrue
())
}
if
isTransitionTest
{
svc
=
jig
.
UpdateServiceOrFail
(
svc
.
Namespace
,
svc
.
Name
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
SessionAffinity
=
v1
.
ServiceAffinityNone
})
Expect
(
framework
.
CheckAffinity
(
jig
,
execPod
,
svcIp
,
servicePort
,
false
,
true
))
.
To
(
BeTrue
())
Expect
(
framework
.
CheckAffinity
(
jig
,
execPod
,
svcIp
,
servicePort
,
false
))
.
To
(
BeTrue
())
svc
=
jig
.
UpdateServiceOrFail
(
svc
.
Namespace
,
svc
.
Name
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
SessionAffinity
=
v1
.
ServiceAffinityClientIP
})
Expect
(
framework
.
CheckAffinity
(
jig
,
execPod
,
svcIp
,
servicePort
,
true
,
true
))
.
To
(
BeTrue
())
Expect
(
framework
.
CheckAffinity
(
jig
,
execPod
,
svcIp
,
servicePort
,
true
))
.
To
(
BeTrue
())
}
}
...
...
@@ -2240,16 +2240,16 @@ func execAffinityTestForLBService(f *framework.Framework, cs clientset.Interface
port
:=
int
(
svc
.
Spec
.
Ports
[
0
]
.
Port
)
if
!
isTransitionTest
{
Expect
(
framework
.
CheckAffinity
(
jig
,
nil
,
ingressIP
,
port
,
true
,
false
))
.
To
(
BeTrue
())
Expect
(
framework
.
CheckAffinity
(
jig
,
nil
,
ingressIP
,
port
,
true
))
.
To
(
BeTrue
())
}
if
isTransitionTest
{
svc
=
jig
.
UpdateServiceOrFail
(
svc
.
Namespace
,
svc
.
Name
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
SessionAffinity
=
v1
.
ServiceAffinityNone
})
Expect
(
framework
.
CheckAffinity
(
jig
,
nil
,
ingressIP
,
port
,
false
,
true
))
.
To
(
BeTrue
())
Expect
(
framework
.
CheckAffinity
(
jig
,
nil
,
ingressIP
,
port
,
false
))
.
To
(
BeTrue
())
svc
=
jig
.
UpdateServiceOrFail
(
svc
.
Namespace
,
svc
.
Name
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
SessionAffinity
=
v1
.
ServiceAffinityClientIP
})
Expect
(
framework
.
CheckAffinity
(
jig
,
nil
,
ingressIP
,
port
,
true
,
true
))
.
To
(
BeTrue
())
Expect
(
framework
.
CheckAffinity
(
jig
,
nil
,
ingressIP
,
port
,
true
))
.
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