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
20cece67
Unverified
Commit
20cece67
authored
Apr 05, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Apr 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76006 from atoato88/fix-golint-e2e-framework-s
Fix golint failures of e2e/framework/statefulset_utils.go
parents
63ae3730
b0a4d7cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
45 deletions
+45
-45
statefulset.go
test/e2e/apps/statefulset.go
+18
-18
statefulset_utils.go
test/e2e/framework/statefulset_utils.go
+27
-27
No files found.
test/e2e/apps/statefulset.go
View file @
20cece67
...
@@ -278,7 +278,7 @@ var _ = SIGDescribe("StatefulSet", func() {
...
@@ -278,7 +278,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By
(
"Creating a new StatefulSet"
)
By
(
"Creating a new StatefulSet"
)
ss
:=
framework
.
NewStatefulSet
(
"ss2"
,
ns
,
headlessSvcName
,
3
,
nil
,
nil
,
labels
)
ss
:=
framework
.
NewStatefulSet
(
"ss2"
,
ns
,
headlessSvcName
,
3
,
nil
,
nil
,
labels
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
.
SetH
ttp
Probe
(
ss
)
sst
.
SetH
TTP
Probe
(
ss
)
ss
.
Spec
.
UpdateStrategy
=
apps
.
StatefulSetUpdateStrategy
{
ss
.
Spec
.
UpdateStrategy
=
apps
.
StatefulSetUpdateStrategy
{
Type
:
apps
.
RollingUpdateStatefulSetStrategyType
,
Type
:
apps
.
RollingUpdateStatefulSetStrategyType
,
RollingUpdate
:
func
()
*
apps
.
RollingUpdateStatefulSetStrategy
{
RollingUpdate
:
func
()
*
apps
.
RollingUpdateStatefulSetStrategy
{
...
@@ -489,7 +489,7 @@ var _ = SIGDescribe("StatefulSet", func() {
...
@@ -489,7 +489,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By
(
"Creating a new StatefulSet"
)
By
(
"Creating a new StatefulSet"
)
ss
:=
framework
.
NewStatefulSet
(
"ss2"
,
ns
,
headlessSvcName
,
3
,
nil
,
nil
,
labels
)
ss
:=
framework
.
NewStatefulSet
(
"ss2"
,
ns
,
headlessSvcName
,
3
,
nil
,
nil
,
labels
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
.
SetH
ttp
Probe
(
ss
)
sst
.
SetH
TTP
Probe
(
ss
)
ss
.
Spec
.
UpdateStrategy
=
apps
.
StatefulSetUpdateStrategy
{
ss
.
Spec
.
UpdateStrategy
=
apps
.
StatefulSetUpdateStrategy
{
Type
:
apps
.
OnDeleteStatefulSetStrategyType
,
Type
:
apps
.
OnDeleteStatefulSetStrategyType
,
}
}
...
@@ -581,7 +581,7 @@ var _ = SIGDescribe("StatefulSet", func() {
...
@@ -581,7 +581,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By
(
"Creating stateful set "
+
ssName
+
" in namespace "
+
ns
)
By
(
"Creating stateful set "
+
ssName
+
" in namespace "
+
ns
)
ss
:=
framework
.
NewStatefulSet
(
ssName
,
ns
,
headlessSvcName
,
1
,
nil
,
nil
,
psLabels
)
ss
:=
framework
.
NewStatefulSet
(
ssName
,
ns
,
headlessSvcName
,
1
,
nil
,
nil
,
psLabels
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
.
SetH
ttp
Probe
(
ss
)
sst
.
SetH
TTP
Probe
(
ss
)
ss
,
err
=
c
.
AppsV1
()
.
StatefulSets
(
ns
)
.
Create
(
ss
)
ss
,
err
=
c
.
AppsV1
()
.
StatefulSets
(
ns
)
.
Create
(
ss
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -589,14 +589,14 @@ var _ = SIGDescribe("StatefulSet", func() {
...
@@ -589,14 +589,14 @@ var _ = SIGDescribe("StatefulSet", func() {
sst
.
WaitForRunningAndReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
sst
.
WaitForRunningAndReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
By
(
"Confirming that stateful set scale up will halt with unhealthy stateful pod"
)
By
(
"Confirming that stateful set scale up will halt with unhealthy stateful pod"
)
sst
.
BreakH
ttp
Probe
(
ss
)
sst
.
BreakH
TTP
Probe
(
ss
)
sst
.
WaitForRunningAndNotReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
sst
.
WaitForRunningAndNotReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
sst
.
WaitForStatusReadyReplicas
(
ss
,
0
)
sst
.
WaitForStatusReadyReplicas
(
ss
,
0
)
sst
.
UpdateReplicas
(
ss
,
3
)
sst
.
UpdateReplicas
(
ss
,
3
)
sst
.
ConfirmStatefulPodCount
(
1
,
ss
,
10
*
time
.
Second
,
true
)
sst
.
ConfirmStatefulPodCount
(
1
,
ss
,
10
*
time
.
Second
,
true
)
By
(
"Scaling up stateful set "
+
ssName
+
" to 3 replicas and waiting until all of them will be running in namespace "
+
ns
)
By
(
"Scaling up stateful set "
+
ssName
+
" to 3 replicas and waiting until all of them will be running in namespace "
+
ns
)
sst
.
RestoreH
ttp
Probe
(
ss
)
sst
.
RestoreH
TTP
Probe
(
ss
)
sst
.
WaitForRunningAndReady
(
3
,
ss
)
sst
.
WaitForRunningAndReady
(
3
,
ss
)
By
(
"Verifying that stateful set "
+
ssName
+
" was scaled up in order"
)
By
(
"Verifying that stateful set "
+
ssName
+
" was scaled up in order"
)
...
@@ -622,14 +622,14 @@ var _ = SIGDescribe("StatefulSet", func() {
...
@@ -622,14 +622,14 @@ var _ = SIGDescribe("StatefulSet", func() {
})
})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
sst
.
BreakH
ttp
Probe
(
ss
)
sst
.
BreakH
TTP
Probe
(
ss
)
sst
.
WaitForStatusReadyReplicas
(
ss
,
0
)
sst
.
WaitForStatusReadyReplicas
(
ss
,
0
)
sst
.
WaitForRunningAndNotReady
(
3
,
ss
)
sst
.
WaitForRunningAndNotReady
(
3
,
ss
)
sst
.
UpdateReplicas
(
ss
,
0
)
sst
.
UpdateReplicas
(
ss
,
0
)
sst
.
ConfirmStatefulPodCount
(
3
,
ss
,
10
*
time
.
Second
,
true
)
sst
.
ConfirmStatefulPodCount
(
3
,
ss
,
10
*
time
.
Second
,
true
)
By
(
"Scaling down stateful set "
+
ssName
+
" to 0 replicas and waiting until none of pods will run in namespace"
+
ns
)
By
(
"Scaling down stateful set "
+
ssName
+
" to 0 replicas and waiting until none of pods will run in namespace"
+
ns
)
sst
.
RestoreH
ttp
Probe
(
ss
)
sst
.
RestoreH
TTP
Probe
(
ss
)
sst
.
Scale
(
ss
,
0
)
sst
.
Scale
(
ss
,
0
)
By
(
"Verifying that stateful set "
+
ssName
+
" was scaled down in reverse order"
)
By
(
"Verifying that stateful set "
+
ssName
+
" was scaled down in reverse order"
)
...
@@ -662,7 +662,7 @@ var _ = SIGDescribe("StatefulSet", func() {
...
@@ -662,7 +662,7 @@ var _ = SIGDescribe("StatefulSet", func() {
ss
:=
framework
.
NewStatefulSet
(
ssName
,
ns
,
headlessSvcName
,
1
,
nil
,
nil
,
psLabels
)
ss
:=
framework
.
NewStatefulSet
(
ssName
,
ns
,
headlessSvcName
,
1
,
nil
,
nil
,
psLabels
)
ss
.
Spec
.
PodManagementPolicy
=
apps
.
ParallelPodManagement
ss
.
Spec
.
PodManagementPolicy
=
apps
.
ParallelPodManagement
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
.
SetH
ttp
Probe
(
ss
)
sst
.
SetH
TTP
Probe
(
ss
)
ss
,
err
:=
c
.
AppsV1
()
.
StatefulSets
(
ns
)
.
Create
(
ss
)
ss
,
err
:=
c
.
AppsV1
()
.
StatefulSets
(
ns
)
.
Create
(
ss
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -670,25 +670,25 @@ var _ = SIGDescribe("StatefulSet", func() {
...
@@ -670,25 +670,25 @@ var _ = SIGDescribe("StatefulSet", func() {
sst
.
WaitForRunningAndReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
sst
.
WaitForRunningAndReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
By
(
"Confirming that stateful set scale up will not halt with unhealthy stateful pod"
)
By
(
"Confirming that stateful set scale up will not halt with unhealthy stateful pod"
)
sst
.
BreakH
ttp
Probe
(
ss
)
sst
.
BreakH
TTP
Probe
(
ss
)
sst
.
WaitForRunningAndNotReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
sst
.
WaitForRunningAndNotReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
sst
.
WaitForStatusReadyReplicas
(
ss
,
0
)
sst
.
WaitForStatusReadyReplicas
(
ss
,
0
)
sst
.
UpdateReplicas
(
ss
,
3
)
sst
.
UpdateReplicas
(
ss
,
3
)
sst
.
ConfirmStatefulPodCount
(
3
,
ss
,
10
*
time
.
Second
,
false
)
sst
.
ConfirmStatefulPodCount
(
3
,
ss
,
10
*
time
.
Second
,
false
)
By
(
"Scaling up stateful set "
+
ssName
+
" to 3 replicas and waiting until all of them will be running in namespace "
+
ns
)
By
(
"Scaling up stateful set "
+
ssName
+
" to 3 replicas and waiting until all of them will be running in namespace "
+
ns
)
sst
.
RestoreH
ttp
Probe
(
ss
)
sst
.
RestoreH
TTP
Probe
(
ss
)
sst
.
WaitForRunningAndReady
(
3
,
ss
)
sst
.
WaitForRunningAndReady
(
3
,
ss
)
By
(
"Scale down will not halt with unhealthy stateful pod"
)
By
(
"Scale down will not halt with unhealthy stateful pod"
)
sst
.
BreakH
ttp
Probe
(
ss
)
sst
.
BreakH
TTP
Probe
(
ss
)
sst
.
WaitForStatusReadyReplicas
(
ss
,
0
)
sst
.
WaitForStatusReadyReplicas
(
ss
,
0
)
sst
.
WaitForRunningAndNotReady
(
3
,
ss
)
sst
.
WaitForRunningAndNotReady
(
3
,
ss
)
sst
.
UpdateReplicas
(
ss
,
0
)
sst
.
UpdateReplicas
(
ss
,
0
)
sst
.
ConfirmStatefulPodCount
(
0
,
ss
,
10
*
time
.
Second
,
false
)
sst
.
ConfirmStatefulPodCount
(
0
,
ss
,
10
*
time
.
Second
,
false
)
By
(
"Scaling down stateful set "
+
ssName
+
" to 0 replicas and waiting until none of pods will run in namespace"
+
ns
)
By
(
"Scaling down stateful set "
+
ssName
+
" to 0 replicas and waiting until none of pods will run in namespace"
+
ns
)
sst
.
RestoreH
ttp
Probe
(
ss
)
sst
.
RestoreH
TTP
Probe
(
ss
)
sst
.
Scale
(
ss
,
0
)
sst
.
Scale
(
ss
,
0
)
sst
.
WaitForStatusReplicas
(
ss
,
0
)
sst
.
WaitForStatusReplicas
(
ss
,
0
)
})
})
...
@@ -788,7 +788,7 @@ var _ = SIGDescribe("StatefulSet", func() {
...
@@ -788,7 +788,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By
(
"Creating statefulset "
+
ssName
+
" in namespace "
+
ns
)
By
(
"Creating statefulset "
+
ssName
+
" in namespace "
+
ns
)
ss
:=
framework
.
NewStatefulSet
(
ssName
,
ns
,
headlessSvcName
,
1
,
nil
,
nil
,
labels
)
ss
:=
framework
.
NewStatefulSet
(
ssName
,
ns
,
headlessSvcName
,
1
,
nil
,
nil
,
labels
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
.
SetH
ttp
Probe
(
ss
)
sst
.
SetH
TTP
Probe
(
ss
)
ss
,
err
:=
c
.
AppsV1
()
.
StatefulSets
(
ns
)
.
Create
(
ss
)
ss
,
err
:=
c
.
AppsV1
()
.
StatefulSets
(
ns
)
.
Create
(
ss
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
sst
.
WaitForRunningAndReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
sst
.
WaitForRunningAndReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
...
@@ -1083,7 +1083,7 @@ func pollReadWithTimeout(statefulPod statefulPodTester, statefulPodNumber int, k
...
@@ -1083,7 +1083,7 @@ func pollReadWithTimeout(statefulPod statefulPodTester, statefulPodNumber int, k
// PVCs and one using no storage.
// PVCs and one using no storage.
func
rollbackTest
(
c
clientset
.
Interface
,
ns
string
,
ss
*
apps
.
StatefulSet
)
{
func
rollbackTest
(
c
clientset
.
Interface
,
ns
string
,
ss
*
apps
.
StatefulSet
)
{
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
:=
framework
.
NewStatefulSetTester
(
c
)
sst
.
SetH
ttp
Probe
(
ss
)
sst
.
SetH
TTP
Probe
(
ss
)
ss
,
err
:=
c
.
AppsV1
()
.
StatefulSets
(
ns
)
.
Create
(
ss
)
ss
,
err
:=
c
.
AppsV1
()
.
StatefulSets
(
ns
)
.
Create
(
ss
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
sst
.
WaitForRunningAndReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
sst
.
WaitForRunningAndReady
(
*
ss
.
Spec
.
Replicas
,
ss
)
...
@@ -1102,7 +1102,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
...
@@ -1102,7 +1102,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
currentRevision
))
currentRevision
))
}
}
sst
.
SortStatefulPods
(
pods
)
sst
.
SortStatefulPods
(
pods
)
err
=
sst
.
BreakPodH
ttp
Probe
(
ss
,
&
pods
.
Items
[
1
])
err
=
sst
.
BreakPodH
TTP
Probe
(
ss
,
&
pods
.
Items
[
1
])
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
ss
,
pods
=
sst
.
WaitForPodNotReady
(
ss
,
pods
.
Items
[
1
]
.
Name
)
ss
,
pods
=
sst
.
WaitForPodNotReady
(
ss
,
pods
.
Items
[
1
]
.
Name
)
newImage
:=
NewNginxImage
newImage
:=
NewNginxImage
...
@@ -1124,7 +1124,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
...
@@ -1124,7 +1124,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
By
(
"Updating Pods in reverse ordinal order"
)
By
(
"Updating Pods in reverse ordinal order"
)
pods
=
sst
.
GetPodList
(
ss
)
pods
=
sst
.
GetPodList
(
ss
)
sst
.
SortStatefulPods
(
pods
)
sst
.
SortStatefulPods
(
pods
)
err
=
sst
.
RestorePodH
ttp
Probe
(
ss
,
&
pods
.
Items
[
1
])
err
=
sst
.
RestorePodH
TTP
Probe
(
ss
,
&
pods
.
Items
[
1
])
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
ss
,
pods
=
sst
.
WaitForPodReady
(
ss
,
pods
.
Items
[
1
]
.
Name
)
ss
,
pods
=
sst
.
WaitForPodReady
(
ss
,
pods
.
Items
[
1
]
.
Name
)
ss
,
pods
=
sst
.
WaitForRollingUpdate
(
ss
)
ss
,
pods
=
sst
.
WaitForRollingUpdate
(
ss
)
...
@@ -1150,7 +1150,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
...
@@ -1150,7 +1150,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
}
}
By
(
"Rolling back to a previous revision"
)
By
(
"Rolling back to a previous revision"
)
err
=
sst
.
BreakPodH
ttp
Probe
(
ss
,
&
pods
.
Items
[
1
])
err
=
sst
.
BreakPodH
TTP
Probe
(
ss
,
&
pods
.
Items
[
1
])
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
ss
,
pods
=
sst
.
WaitForPodNotReady
(
ss
,
pods
.
Items
[
1
]
.
Name
)
ss
,
pods
=
sst
.
WaitForPodNotReady
(
ss
,
pods
.
Items
[
1
]
.
Name
)
priorRevision
:=
currentRevision
priorRevision
:=
currentRevision
...
@@ -1169,7 +1169,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
...
@@ -1169,7 +1169,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
By
(
"Rolling back update in reverse ordinal order"
)
By
(
"Rolling back update in reverse ordinal order"
)
pods
=
sst
.
GetPodList
(
ss
)
pods
=
sst
.
GetPodList
(
ss
)
sst
.
SortStatefulPods
(
pods
)
sst
.
SortStatefulPods
(
pods
)
sst
.
RestorePodH
ttp
Probe
(
ss
,
&
pods
.
Items
[
1
])
sst
.
RestorePodH
TTP
Probe
(
ss
,
&
pods
.
Items
[
1
])
ss
,
pods
=
sst
.
WaitForPodReady
(
ss
,
pods
.
Items
[
1
]
.
Name
)
ss
,
pods
=
sst
.
WaitForPodReady
(
ss
,
pods
.
Items
[
1
]
.
Name
)
ss
,
pods
=
sst
.
WaitForRollingUpdate
(
ss
)
ss
,
pods
=
sst
.
WaitForRollingUpdate
(
ss
)
Expect
(
ss
.
Status
.
CurrentRevision
)
.
To
(
Equal
(
priorRevision
),
Expect
(
ss
.
Status
.
CurrentRevision
)
.
To
(
Equal
(
priorRevision
),
...
...
test/e2e/framework/statefulset_utils.go
View file @
20cece67
...
@@ -43,11 +43,11 @@ import (
...
@@ -43,11 +43,11 @@ import (
)
)
const
(
const
(
//
P
oll interval for StatefulSet tests
//
StatefulSetPoll is a p
oll interval for StatefulSet tests
StatefulSetPoll
=
10
*
time
.
Second
StatefulSetPoll
=
10
*
time
.
Second
//
T
imeout interval for StatefulSet operations
//
StatefulSetTimeout is a t
imeout interval for StatefulSet operations
StatefulSetTimeout
=
10
*
time
.
Minute
StatefulSetTimeout
=
10
*
time
.
Minute
//
T
imeout for stateful pods to change state
//
StatefulPodTimeout is a t
imeout for stateful pods to change state
StatefulPodTimeout
=
5
*
time
.
Minute
StatefulPodTimeout
=
5
*
time
.
Minute
)
)
...
@@ -468,16 +468,15 @@ func (s *StatefulSetTester) WaitForPartitionedRollingUpdate(set *apps.StatefulSe
...
@@ -468,16 +468,15 @@ func (s *StatefulSetTester) WaitForPartitionedRollingUpdate(set *apps.StatefulSe
}
}
}
}
return
false
,
nil
return
false
,
nil
}
else
{
}
for
i
:=
int
(
*
set
.
Spec
.
Replicas
)
-
1
;
i
>=
partition
;
i
--
{
for
i
:=
int
(
*
set
.
Spec
.
Replicas
)
-
1
;
i
>=
partition
;
i
--
{
if
pods
.
Items
[
i
]
.
Labels
[
apps
.
StatefulSetRevisionLabel
]
!=
set
.
Status
.
UpdateRevision
{
if
pods
.
Items
[
i
]
.
Labels
[
apps
.
StatefulSetRevisionLabel
]
!=
set
.
Status
.
UpdateRevision
{
Logf
(
"Waiting for Pod %s/%s to have revision %s update revision %s"
,
Logf
(
"Waiting for Pod %s/%s to have revision %s update revision %s"
,
pods
.
Items
[
i
]
.
Namespace
,
pods
.
Items
[
i
]
.
Namespace
,
pods
.
Items
[
i
]
.
Name
,
pods
.
Items
[
i
]
.
Name
,
set
.
Status
.
UpdateRevision
,
set
.
Status
.
UpdateRevision
,
pods
.
Items
[
i
]
.
Labels
[
apps
.
StatefulSetRevisionLabel
])
pods
.
Items
[
i
]
.
Labels
[
apps
.
StatefulSetRevisionLabel
])
return
false
,
nil
return
false
,
nil
}
}
}
}
}
return
true
,
nil
return
true
,
nil
...
@@ -485,7 +484,7 @@ func (s *StatefulSetTester) WaitForPartitionedRollingUpdate(set *apps.StatefulSe
...
@@ -485,7 +484,7 @@ func (s *StatefulSetTester) WaitForPartitionedRollingUpdate(set *apps.StatefulSe
return
set
,
pods
return
set
,
pods
}
}
// WaitForRunningAndReady waits for numStatefulPods in ss to be Running and not Ready.
// WaitForRunningAnd
Not
Ready waits for numStatefulPods in ss to be Running and not Ready.
func
(
s
*
StatefulSetTester
)
WaitForRunningAndNotReady
(
numStatefulPods
int32
,
ss
*
apps
.
StatefulSet
)
{
func
(
s
*
StatefulSetTester
)
WaitForRunningAndNotReady
(
numStatefulPods
int32
,
ss
*
apps
.
StatefulSet
)
{
s
.
WaitForRunning
(
numStatefulPods
,
0
,
ss
)
s
.
WaitForRunning
(
numStatefulPods
,
0
,
ss
)
}
}
...
@@ -502,15 +501,15 @@ var httpProbe = &v1.Probe{
...
@@ -502,15 +501,15 @@ var httpProbe = &v1.Probe{
FailureThreshold
:
1
,
FailureThreshold
:
1
,
}
}
// SetH
ttp
Probe sets the pod template's ReadinessProbe for Nginx StatefulSet containers.
// SetH
TTP
Probe sets the pod template's ReadinessProbe for Nginx StatefulSet containers.
// This probe can then be controlled with BreakH
ttpProbe() and RestoreHttp
Probe().
// This probe can then be controlled with BreakH
TTPProbe() and RestoreHTTP
Probe().
// Note that this cannot be used together with PauseNewPods().
// Note that this cannot be used together with PauseNewPods().
func
(
s
*
StatefulSetTester
)
SetH
ttp
Probe
(
ss
*
apps
.
StatefulSet
)
{
func
(
s
*
StatefulSetTester
)
SetH
TTP
Probe
(
ss
*
apps
.
StatefulSet
)
{
ss
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
ReadinessProbe
=
httpProbe
ss
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
ReadinessProbe
=
httpProbe
}
}
// BreakH
ttp
Probe breaks the readiness probe for Nginx StatefulSet containers in ss.
// BreakH
TTP
Probe breaks the readiness probe for Nginx StatefulSet containers in ss.
func
(
s
*
StatefulSetTester
)
BreakH
ttp
Probe
(
ss
*
apps
.
StatefulSet
)
error
{
func
(
s
*
StatefulSetTester
)
BreakH
TTP
Probe
(
ss
*
apps
.
StatefulSet
)
error
{
path
:=
httpProbe
.
HTTPGet
.
Path
path
:=
httpProbe
.
HTTPGet
.
Path
if
path
==
""
{
if
path
==
""
{
return
fmt
.
Errorf
(
"Path expected to be not empty: %v"
,
path
)
return
fmt
.
Errorf
(
"Path expected to be not empty: %v"
,
path
)
...
@@ -520,8 +519,8 @@ func (s *StatefulSetTester) BreakHttpProbe(ss *apps.StatefulSet) error {
...
@@ -520,8 +519,8 @@ func (s *StatefulSetTester) BreakHttpProbe(ss *apps.StatefulSet) error {
return
s
.
ExecInStatefulPods
(
ss
,
cmd
)
return
s
.
ExecInStatefulPods
(
ss
,
cmd
)
}
}
// BreakPodH
ttp
Probe breaks the readiness probe for Nginx StatefulSet containers in one pod.
// BreakPodH
TTP
Probe breaks the readiness probe for Nginx StatefulSet containers in one pod.
func
(
s
*
StatefulSetTester
)
BreakPodH
ttp
Probe
(
ss
*
apps
.
StatefulSet
,
pod
*
v1
.
Pod
)
error
{
func
(
s
*
StatefulSetTester
)
BreakPodH
TTP
Probe
(
ss
*
apps
.
StatefulSet
,
pod
*
v1
.
Pod
)
error
{
path
:=
httpProbe
.
HTTPGet
.
Path
path
:=
httpProbe
.
HTTPGet
.
Path
if
path
==
""
{
if
path
==
""
{
return
fmt
.
Errorf
(
"Path expected to be not empty: %v"
,
path
)
return
fmt
.
Errorf
(
"Path expected to be not empty: %v"
,
path
)
...
@@ -533,8 +532,8 @@ func (s *StatefulSetTester) BreakPodHttpProbe(ss *apps.StatefulSet, pod *v1.Pod)
...
@@ -533,8 +532,8 @@ func (s *StatefulSetTester) BreakPodHttpProbe(ss *apps.StatefulSet, pod *v1.Pod)
return
err
return
err
}
}
// RestoreH
ttp
Probe restores the readiness probe for Nginx StatefulSet containers in ss.
// RestoreH
TTP
Probe restores the readiness probe for Nginx StatefulSet containers in ss.
func
(
s
*
StatefulSetTester
)
RestoreH
ttp
Probe
(
ss
*
apps
.
StatefulSet
)
error
{
func
(
s
*
StatefulSetTester
)
RestoreH
TTP
Probe
(
ss
*
apps
.
StatefulSet
)
error
{
path
:=
httpProbe
.
HTTPGet
.
Path
path
:=
httpProbe
.
HTTPGet
.
Path
if
path
==
""
{
if
path
==
""
{
return
fmt
.
Errorf
(
"Path expected to be not empty: %v"
,
path
)
return
fmt
.
Errorf
(
"Path expected to be not empty: %v"
,
path
)
...
@@ -544,8 +543,8 @@ func (s *StatefulSetTester) RestoreHttpProbe(ss *apps.StatefulSet) error {
...
@@ -544,8 +543,8 @@ func (s *StatefulSetTester) RestoreHttpProbe(ss *apps.StatefulSet) error {
return
s
.
ExecInStatefulPods
(
ss
,
cmd
)
return
s
.
ExecInStatefulPods
(
ss
,
cmd
)
}
}
// RestorePodH
ttp
Probe restores the readiness probe for Nginx StatefulSet containers in pod.
// RestorePodH
TTP
Probe restores the readiness probe for Nginx StatefulSet containers in pod.
func
(
s
*
StatefulSetTester
)
RestorePodH
ttp
Probe
(
ss
*
apps
.
StatefulSet
,
pod
*
v1
.
Pod
)
error
{
func
(
s
*
StatefulSetTester
)
RestorePodH
TTP
Probe
(
ss
*
apps
.
StatefulSet
,
pod
*
v1
.
Pod
)
error
{
path
:=
httpProbe
.
HTTPGet
.
Path
path
:=
httpProbe
.
HTTPGet
.
Path
if
path
==
""
{
if
path
==
""
{
return
fmt
.
Errorf
(
"Path expected to be not empty: %v"
,
path
)
return
fmt
.
Errorf
(
"Path expected to be not empty: %v"
,
path
)
...
@@ -574,7 +573,7 @@ func hasPauseProbe(pod *v1.Pod) bool {
...
@@ -574,7 +573,7 @@ func hasPauseProbe(pod *v1.Pod) bool {
// PauseNewPods adds an always-failing ReadinessProbe to the StatefulSet PodTemplate.
// PauseNewPods adds an always-failing ReadinessProbe to the StatefulSet PodTemplate.
// This causes all newly-created Pods to stay Unready until they are manually resumed
// This causes all newly-created Pods to stay Unready until they are manually resumed
// with ResumeNextPod().
// with ResumeNextPod().
// Note that this cannot be used together with SetH
ttp
Probe().
// Note that this cannot be used together with SetH
TTP
Probe().
func
(
s
*
StatefulSetTester
)
PauseNewPods
(
ss
*
apps
.
StatefulSet
)
{
func
(
s
*
StatefulSetTester
)
PauseNewPods
(
ss
*
apps
.
StatefulSet
)
{
ss
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
ReadinessProbe
=
pauseProbe
ss
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
ReadinessProbe
=
pauseProbe
}
}
...
@@ -655,7 +654,7 @@ func (s *StatefulSetTester) WaitForStatusReplicas(ss *apps.StatefulSet, expected
...
@@ -655,7 +654,7 @@ func (s *StatefulSetTester) WaitForStatusReplicas(ss *apps.StatefulSet, expected
}
}
// CheckServiceName asserts that the ServiceName for ss is equivalent to expectedServiceName.
// CheckServiceName asserts that the ServiceName for ss is equivalent to expectedServiceName.
func
(
p
*
StatefulSetTester
)
CheckServiceName
(
ss
*
apps
.
StatefulSet
,
expectedServiceName
string
)
error
{
func
(
s
*
StatefulSetTester
)
CheckServiceName
(
ss
*
apps
.
StatefulSet
,
expectedServiceName
string
)
error
{
Logf
(
"Checking if statefulset spec.serviceName is %s"
,
expectedServiceName
)
Logf
(
"Checking if statefulset spec.serviceName is %s"
,
expectedServiceName
)
if
expectedServiceName
!=
ss
.
Spec
.
ServiceName
{
if
expectedServiceName
!=
ss
.
Spec
.
ServiceName
{
...
@@ -869,6 +868,7 @@ func (sp statefulPodsByOrdinal) Less(i, j int) bool {
...
@@ -869,6 +868,7 @@ func (sp statefulPodsByOrdinal) Less(i, j int) bool {
type
updateStatefulSetFunc
func
(
*
apps
.
StatefulSet
)
type
updateStatefulSetFunc
func
(
*
apps
.
StatefulSet
)
// UpdateStatefulSetWithRetries updates statfulset template with retries.
func
UpdateStatefulSetWithRetries
(
c
clientset
.
Interface
,
namespace
,
name
string
,
applyUpdate
updateStatefulSetFunc
)
(
statefulSet
*
apps
.
StatefulSet
,
err
error
)
{
func
UpdateStatefulSetWithRetries
(
c
clientset
.
Interface
,
namespace
,
name
string
,
applyUpdate
updateStatefulSetFunc
)
(
statefulSet
*
apps
.
StatefulSet
,
err
error
)
{
statefulSets
:=
c
.
AppsV1
()
.
StatefulSets
(
namespace
)
statefulSets
:=
c
.
AppsV1
()
.
StatefulSets
(
namespace
)
var
updateErr
error
var
updateErr
error
...
...
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