Skip to content

Commit 20cece6

Browse files
authored
Merge pull request kubernetes#76006 from atoato88/fix-golint-e2e-framework-s
Fix golint failures of e2e/framework/statefulset_utils.go
2 parents 63ae373 + b0a4d7c commit 20cece6

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

test/e2e/apps/statefulset.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ var _ = SIGDescribe("StatefulSet", func() {
278278
By("Creating a new StatefulSet")
279279
ss := framework.NewStatefulSet("ss2", ns, headlessSvcName, 3, nil, nil, labels)
280280
sst := framework.NewStatefulSetTester(c)
281-
sst.SetHttpProbe(ss)
281+
sst.SetHTTPProbe(ss)
282282
ss.Spec.UpdateStrategy = apps.StatefulSetUpdateStrategy{
283283
Type: apps.RollingUpdateStatefulSetStrategyType,
284284
RollingUpdate: func() *apps.RollingUpdateStatefulSetStrategy {
@@ -489,7 +489,7 @@ var _ = SIGDescribe("StatefulSet", func() {
489489
By("Creating a new StatefulSet")
490490
ss := framework.NewStatefulSet("ss2", ns, headlessSvcName, 3, nil, nil, labels)
491491
sst := framework.NewStatefulSetTester(c)
492-
sst.SetHttpProbe(ss)
492+
sst.SetHTTPProbe(ss)
493493
ss.Spec.UpdateStrategy = apps.StatefulSetUpdateStrategy{
494494
Type: apps.OnDeleteStatefulSetStrategyType,
495495
}
@@ -581,22 +581,22 @@ var _ = SIGDescribe("StatefulSet", func() {
581581
By("Creating stateful set " + ssName + " in namespace " + ns)
582582
ss := framework.NewStatefulSet(ssName, ns, headlessSvcName, 1, nil, nil, psLabels)
583583
sst := framework.NewStatefulSetTester(c)
584-
sst.SetHttpProbe(ss)
584+
sst.SetHTTPProbe(ss)
585585
ss, err = c.AppsV1().StatefulSets(ns).Create(ss)
586586
Expect(err).NotTo(HaveOccurred())
587587

588588
By("Waiting until all stateful set " + ssName + " replicas will be running in namespace " + ns)
589589
sst.WaitForRunningAndReady(*ss.Spec.Replicas, ss)
590590

591591
By("Confirming that stateful set scale up will halt with unhealthy stateful pod")
592-
sst.BreakHttpProbe(ss)
592+
sst.BreakHTTPProbe(ss)
593593
sst.WaitForRunningAndNotReady(*ss.Spec.Replicas, ss)
594594
sst.WaitForStatusReadyReplicas(ss, 0)
595595
sst.UpdateReplicas(ss, 3)
596596
sst.ConfirmStatefulPodCount(1, ss, 10*time.Second, true)
597597

598598
By("Scaling up stateful set " + ssName + " to 3 replicas and waiting until all of them will be running in namespace " + ns)
599-
sst.RestoreHttpProbe(ss)
599+
sst.RestoreHTTPProbe(ss)
600600
sst.WaitForRunningAndReady(3, ss)
601601

602602
By("Verifying that stateful set " + ssName + " was scaled up in order")
@@ -622,14 +622,14 @@ var _ = SIGDescribe("StatefulSet", func() {
622622
})
623623
Expect(err).NotTo(HaveOccurred())
624624

625-
sst.BreakHttpProbe(ss)
625+
sst.BreakHTTPProbe(ss)
626626
sst.WaitForStatusReadyReplicas(ss, 0)
627627
sst.WaitForRunningAndNotReady(3, ss)
628628
sst.UpdateReplicas(ss, 0)
629629
sst.ConfirmStatefulPodCount(3, ss, 10*time.Second, true)
630630

631631
By("Scaling down stateful set " + ssName + " to 0 replicas and waiting until none of pods will run in namespace" + ns)
632-
sst.RestoreHttpProbe(ss)
632+
sst.RestoreHTTPProbe(ss)
633633
sst.Scale(ss, 0)
634634

635635
By("Verifying that stateful set " + ssName + " was scaled down in reverse order")
@@ -662,33 +662,33 @@ var _ = SIGDescribe("StatefulSet", func() {
662662
ss := framework.NewStatefulSet(ssName, ns, headlessSvcName, 1, nil, nil, psLabels)
663663
ss.Spec.PodManagementPolicy = apps.ParallelPodManagement
664664
sst := framework.NewStatefulSetTester(c)
665-
sst.SetHttpProbe(ss)
665+
sst.SetHTTPProbe(ss)
666666
ss, err := c.AppsV1().StatefulSets(ns).Create(ss)
667667
Expect(err).NotTo(HaveOccurred())
668668

669669
By("Waiting until all stateful set " + ssName + " replicas will be running in namespace " + ns)
670670
sst.WaitForRunningAndReady(*ss.Spec.Replicas, ss)
671671

672672
By("Confirming that stateful set scale up will not halt with unhealthy stateful pod")
673-
sst.BreakHttpProbe(ss)
673+
sst.BreakHTTPProbe(ss)
674674
sst.WaitForRunningAndNotReady(*ss.Spec.Replicas, ss)
675675
sst.WaitForStatusReadyReplicas(ss, 0)
676676
sst.UpdateReplicas(ss, 3)
677677
sst.ConfirmStatefulPodCount(3, ss, 10*time.Second, false)
678678

679679
By("Scaling up stateful set " + ssName + " to 3 replicas and waiting until all of them will be running in namespace " + ns)
680-
sst.RestoreHttpProbe(ss)
680+
sst.RestoreHTTPProbe(ss)
681681
sst.WaitForRunningAndReady(3, ss)
682682

683683
By("Scale down will not halt with unhealthy stateful pod")
684-
sst.BreakHttpProbe(ss)
684+
sst.BreakHTTPProbe(ss)
685685
sst.WaitForStatusReadyReplicas(ss, 0)
686686
sst.WaitForRunningAndNotReady(3, ss)
687687
sst.UpdateReplicas(ss, 0)
688688
sst.ConfirmStatefulPodCount(0, ss, 10*time.Second, false)
689689

690690
By("Scaling down stateful set " + ssName + " to 0 replicas and waiting until none of pods will run in namespace" + ns)
691-
sst.RestoreHttpProbe(ss)
691+
sst.RestoreHTTPProbe(ss)
692692
sst.Scale(ss, 0)
693693
sst.WaitForStatusReplicas(ss, 0)
694694
})
@@ -788,7 +788,7 @@ var _ = SIGDescribe("StatefulSet", func() {
788788
By("Creating statefulset " + ssName + " in namespace " + ns)
789789
ss := framework.NewStatefulSet(ssName, ns, headlessSvcName, 1, nil, nil, labels)
790790
sst := framework.NewStatefulSetTester(c)
791-
sst.SetHttpProbe(ss)
791+
sst.SetHTTPProbe(ss)
792792
ss, err := c.AppsV1().StatefulSets(ns).Create(ss)
793793
Expect(err).NotTo(HaveOccurred())
794794
sst.WaitForRunningAndReady(*ss.Spec.Replicas, ss)
@@ -1083,7 +1083,7 @@ func pollReadWithTimeout(statefulPod statefulPodTester, statefulPodNumber int, k
10831083
// PVCs and one using no storage.
10841084
func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
10851085
sst := framework.NewStatefulSetTester(c)
1086-
sst.SetHttpProbe(ss)
1086+
sst.SetHTTPProbe(ss)
10871087
ss, err := c.AppsV1().StatefulSets(ns).Create(ss)
10881088
Expect(err).NotTo(HaveOccurred())
10891089
sst.WaitForRunningAndReady(*ss.Spec.Replicas, ss)
@@ -1102,7 +1102,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
11021102
currentRevision))
11031103
}
11041104
sst.SortStatefulPods(pods)
1105-
err = sst.BreakPodHttpProbe(ss, &pods.Items[1])
1105+
err = sst.BreakPodHTTPProbe(ss, &pods.Items[1])
11061106
Expect(err).NotTo(HaveOccurred())
11071107
ss, pods = sst.WaitForPodNotReady(ss, pods.Items[1].Name)
11081108
newImage := NewNginxImage
@@ -1124,7 +1124,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
11241124
By("Updating Pods in reverse ordinal order")
11251125
pods = sst.GetPodList(ss)
11261126
sst.SortStatefulPods(pods)
1127-
err = sst.RestorePodHttpProbe(ss, &pods.Items[1])
1127+
err = sst.RestorePodHTTPProbe(ss, &pods.Items[1])
11281128
Expect(err).NotTo(HaveOccurred())
11291129
ss, pods = sst.WaitForPodReady(ss, pods.Items[1].Name)
11301130
ss, pods = sst.WaitForRollingUpdate(ss)
@@ -1150,7 +1150,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
11501150
}
11511151

11521152
By("Rolling back to a previous revision")
1153-
err = sst.BreakPodHttpProbe(ss, &pods.Items[1])
1153+
err = sst.BreakPodHTTPProbe(ss, &pods.Items[1])
11541154
Expect(err).NotTo(HaveOccurred())
11551155
ss, pods = sst.WaitForPodNotReady(ss, pods.Items[1].Name)
11561156
priorRevision := currentRevision
@@ -1169,7 +1169,7 @@ func rollbackTest(c clientset.Interface, ns string, ss *apps.StatefulSet) {
11691169
By("Rolling back update in reverse ordinal order")
11701170
pods = sst.GetPodList(ss)
11711171
sst.SortStatefulPods(pods)
1172-
sst.RestorePodHttpProbe(ss, &pods.Items[1])
1172+
sst.RestorePodHTTPProbe(ss, &pods.Items[1])
11731173
ss, pods = sst.WaitForPodReady(ss, pods.Items[1].Name)
11741174
ss, pods = sst.WaitForRollingUpdate(ss)
11751175
Expect(ss.Status.CurrentRevision).To(Equal(priorRevision),

test/e2e/framework/statefulset_utils.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ import (
4343
)
4444

4545
const (
46-
// Poll interval for StatefulSet tests
46+
// StatefulSetPoll is a poll interval for StatefulSet tests
4747
StatefulSetPoll = 10 * time.Second
48-
// Timeout interval for StatefulSet operations
48+
// StatefulSetTimeout is a timeout interval for StatefulSet operations
4949
StatefulSetTimeout = 10 * time.Minute
50-
// Timeout for stateful pods to change state
50+
// StatefulPodTimeout is a timeout for stateful pods to change state
5151
StatefulPodTimeout = 5 * time.Minute
5252
)
5353

@@ -468,24 +468,23 @@ func (s *StatefulSetTester) WaitForPartitionedRollingUpdate(set *apps.StatefulSe
468468
}
469469
}
470470
return false, nil
471-
} else {
472-
for i := int(*set.Spec.Replicas) - 1; i >= partition; i-- {
473-
if pods.Items[i].Labels[apps.StatefulSetRevisionLabel] != set.Status.UpdateRevision {
474-
Logf("Waiting for Pod %s/%s to have revision %s update revision %s",
475-
pods.Items[i].Namespace,
476-
pods.Items[i].Name,
477-
set.Status.UpdateRevision,
478-
pods.Items[i].Labels[apps.StatefulSetRevisionLabel])
479-
return false, nil
480-
}
471+
}
472+
for i := int(*set.Spec.Replicas) - 1; i >= partition; i-- {
473+
if pods.Items[i].Labels[apps.StatefulSetRevisionLabel] != set.Status.UpdateRevision {
474+
Logf("Waiting for Pod %s/%s to have revision %s update revision %s",
475+
pods.Items[i].Namespace,
476+
pods.Items[i].Name,
477+
set.Status.UpdateRevision,
478+
pods.Items[i].Labels[apps.StatefulSetRevisionLabel])
479+
return false, nil
481480
}
482481
}
483482
return true, nil
484483
})
485484
return set, pods
486485
}
487486

488-
// WaitForRunningAndReady waits for numStatefulPods in ss to be Running and not Ready.
487+
// WaitForRunningAndNotReady waits for numStatefulPods in ss to be Running and not Ready.
489488
func (s *StatefulSetTester) WaitForRunningAndNotReady(numStatefulPods int32, ss *apps.StatefulSet) {
490489
s.WaitForRunning(numStatefulPods, 0, ss)
491490
}
@@ -502,15 +501,15 @@ var httpProbe = &v1.Probe{
502501
FailureThreshold: 1,
503502
}
504503

505-
// SetHttpProbe sets the pod template's ReadinessProbe for Nginx StatefulSet containers.
506-
// This probe can then be controlled with BreakHttpProbe() and RestoreHttpProbe().
504+
// SetHTTPProbe sets the pod template's ReadinessProbe for Nginx StatefulSet containers.
505+
// This probe can then be controlled with BreakHTTPProbe() and RestoreHTTPProbe().
507506
// Note that this cannot be used together with PauseNewPods().
508-
func (s *StatefulSetTester) SetHttpProbe(ss *apps.StatefulSet) {
507+
func (s *StatefulSetTester) SetHTTPProbe(ss *apps.StatefulSet) {
509508
ss.Spec.Template.Spec.Containers[0].ReadinessProbe = httpProbe
510509
}
511510

512-
// BreakHttpProbe breaks the readiness probe for Nginx StatefulSet containers in ss.
513-
func (s *StatefulSetTester) BreakHttpProbe(ss *apps.StatefulSet) error {
511+
// BreakHTTPProbe breaks the readiness probe for Nginx StatefulSet containers in ss.
512+
func (s *StatefulSetTester) BreakHTTPProbe(ss *apps.StatefulSet) error {
514513
path := httpProbe.HTTPGet.Path
515514
if path == "" {
516515
return fmt.Errorf("Path expected to be not empty: %v", path)
@@ -520,8 +519,8 @@ func (s *StatefulSetTester) BreakHttpProbe(ss *apps.StatefulSet) error {
520519
return s.ExecInStatefulPods(ss, cmd)
521520
}
522521

523-
// BreakPodHttpProbe breaks the readiness probe for Nginx StatefulSet containers in one pod.
524-
func (s *StatefulSetTester) BreakPodHttpProbe(ss *apps.StatefulSet, pod *v1.Pod) error {
522+
// BreakPodHTTPProbe breaks the readiness probe for Nginx StatefulSet containers in one pod.
523+
func (s *StatefulSetTester) BreakPodHTTPProbe(ss *apps.StatefulSet, pod *v1.Pod) error {
525524
path := httpProbe.HTTPGet.Path
526525
if path == "" {
527526
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)
533532
return err
534533
}
535534

536-
// RestoreHttpProbe restores the readiness probe for Nginx StatefulSet containers in ss.
537-
func (s *StatefulSetTester) RestoreHttpProbe(ss *apps.StatefulSet) error {
535+
// RestoreHTTPProbe restores the readiness probe for Nginx StatefulSet containers in ss.
536+
func (s *StatefulSetTester) RestoreHTTPProbe(ss *apps.StatefulSet) error {
538537
path := httpProbe.HTTPGet.Path
539538
if path == "" {
540539
return fmt.Errorf("Path expected to be not empty: %v", path)
@@ -544,8 +543,8 @@ func (s *StatefulSetTester) RestoreHttpProbe(ss *apps.StatefulSet) error {
544543
return s.ExecInStatefulPods(ss, cmd)
545544
}
546545

547-
// RestorePodHttpProbe restores the readiness probe for Nginx StatefulSet containers in pod.
548-
func (s *StatefulSetTester) RestorePodHttpProbe(ss *apps.StatefulSet, pod *v1.Pod) error {
546+
// RestorePodHTTPProbe restores the readiness probe for Nginx StatefulSet containers in pod.
547+
func (s *StatefulSetTester) RestorePodHTTPProbe(ss *apps.StatefulSet, pod *v1.Pod) error {
549548
path := httpProbe.HTTPGet.Path
550549
if path == "" {
551550
return fmt.Errorf("Path expected to be not empty: %v", path)
@@ -574,7 +573,7 @@ func hasPauseProbe(pod *v1.Pod) bool {
574573
// PauseNewPods adds an always-failing ReadinessProbe to the StatefulSet PodTemplate.
575574
// This causes all newly-created Pods to stay Unready until they are manually resumed
576575
// with ResumeNextPod().
577-
// Note that this cannot be used together with SetHttpProbe().
576+
// Note that this cannot be used together with SetHTTPProbe().
578577
func (s *StatefulSetTester) PauseNewPods(ss *apps.StatefulSet) {
579578
ss.Spec.Template.Spec.Containers[0].ReadinessProbe = pauseProbe
580579
}
@@ -655,7 +654,7 @@ func (s *StatefulSetTester) WaitForStatusReplicas(ss *apps.StatefulSet, expected
655654
}
656655

657656
// CheckServiceName asserts that the ServiceName for ss is equivalent to expectedServiceName.
658-
func (p *StatefulSetTester) CheckServiceName(ss *apps.StatefulSet, expectedServiceName string) error {
657+
func (s *StatefulSetTester) CheckServiceName(ss *apps.StatefulSet, expectedServiceName string) error {
659658
Logf("Checking if statefulset spec.serviceName is %s", expectedServiceName)
660659

661660
if expectedServiceName != ss.Spec.ServiceName {
@@ -869,6 +868,7 @@ func (sp statefulPodsByOrdinal) Less(i, j int) bool {
869868

870869
type updateStatefulSetFunc func(*apps.StatefulSet)
871870

871+
// UpdateStatefulSetWithRetries updates statfulset template with retries.
872872
func UpdateStatefulSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate updateStatefulSetFunc) (statefulSet *apps.StatefulSet, err error) {
873873
statefulSets := c.AppsV1().StatefulSets(namespace)
874874
var updateErr error

0 commit comments

Comments
 (0)