Skip to content

Commit 85b7323

Browse files
authored
Merge pull request kubernetes#76705 from atoato88/fix-golint-e2e-framework-util-go-part3
Fix golint failures of e2e/framework/util.go - part3
2 parents 2ec4467 + 31046bb commit 85b7323

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

test/e2e/framework/util.go

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,8 +2412,10 @@ func (f *Framework) MatchContainerOutput(
24122412
return nil
24132413
}
24142414

2415+
// EventsLister is a func that lists events.
24152416
type EventsLister func(opts metav1.ListOptions, ns string) (*v1.EventList, error)
24162417

2418+
// DumpEventsInNamespace dumps events in the given namespace.
24172419
func DumpEventsInNamespace(eventsLister EventsLister, namespace string) {
24182420
ginkgo.By(fmt.Sprintf("Collecting events from namespace %q.", namespace))
24192421
events, err := eventsLister(metav1.ListOptions{}, namespace)
@@ -2433,6 +2435,7 @@ func DumpEventsInNamespace(eventsLister EventsLister, namespace string) {
24332435
// you may or may not see the killing/deletion/Cleanup events.
24342436
}
24352437

2438+
// DumpAllNamespaceInfo dumps events, pods and nodes information in the given namespace.
24362439
func DumpAllNamespaceInfo(c clientset.Interface, namespace string) {
24372440
DumpEventsInNamespace(func(opts metav1.ListOptions, ns string) (*v1.EventList, error) {
24382441
return c.CoreV1().Events(ns).List(opts)
@@ -2490,6 +2493,7 @@ func dumpAllNodeInfo(c clientset.Interface) {
24902493
DumpNodeDebugInfo(c, names, Logf)
24912494
}
24922495

2496+
// DumpNodeDebugInfo dumps debug information of the given nodes.
24932497
func DumpNodeDebugInfo(c clientset.Interface, nodeNames []string, logFunc func(fmt string, args ...interface{})) {
24942498
for _, n := range nodeNames {
24952499
logFunc("\nLogging node info for node %v", n)
@@ -2701,6 +2705,7 @@ func WaitForAllNodesSchedulable(c clientset.Interface, timeout time.Duration) er
27012705
})
27022706
}
27032707

2708+
// GetPodSecretUpdateTimeout reuturns the timeout duration for updating pod secret.
27042709
func GetPodSecretUpdateTimeout(c clientset.Interface) time.Duration {
27052710
// With SecretManager(ConfigMapManager), we may have to wait up to full sync period +
27062711
// TTL of secret(configmap) to elapse before the Kubelet projects the update into the
@@ -2737,10 +2742,12 @@ func getNodeTTLAnnotationValue(c clientset.Interface) (time.Duration, error) {
27372742
return time.Duration(intValue) * time.Second, nil
27382743
}
27392744

2745+
// AddOrUpdateLabelOnNode adds the given label key and value to the given node or updates value.
27402746
func AddOrUpdateLabelOnNode(c clientset.Interface, nodeName string, labelKey, labelValue string) {
27412747
ExpectNoError(testutils.AddLabelsToNode(c, nodeName, map[string]string{labelKey: labelValue}))
27422748
}
27432749

2750+
// AddOrUpdateLabelOnNodeAndReturnOldValue adds the given label key and value to the given node or updates value and returns the old label value.
27442751
func AddOrUpdateLabelOnNodeAndReturnOldValue(c clientset.Interface, nodeName string, labelKey, labelValue string) string {
27452752
var oldValue string
27462753
node, err := c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
@@ -2750,18 +2757,21 @@ func AddOrUpdateLabelOnNodeAndReturnOldValue(c clientset.Interface, nodeName str
27502757
return oldValue
27512758
}
27522759

2760+
// ExpectNodeHasLabel expects that the given node has the given label pair.
27532761
func ExpectNodeHasLabel(c clientset.Interface, nodeName string, labelKey string, labelValue string) {
27542762
ginkgo.By("verifying the node has the label " + labelKey + " " + labelValue)
27552763
node, err := c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
27562764
ExpectNoError(err)
27572765
gomega.Expect(node.Labels[labelKey]).To(gomega.Equal(labelValue))
27582766
}
27592767

2768+
// RemoveTaintOffNode removes the given taint from the given node.
27602769
func RemoveTaintOffNode(c clientset.Interface, nodeName string, taint v1.Taint) {
27612770
ExpectNoError(controller.RemoveTaintOffNode(c, nodeName, nil, &taint))
27622771
verifyThatTaintIsGone(c, nodeName, &taint)
27632772
}
27642773

2774+
// AddOrUpdateTaintOnNode adds the given taint to the given node or updates taint.
27652775
func AddOrUpdateTaintOnNode(c clientset.Interface, nodeName string, taint v1.Taint) {
27662776
ExpectNoError(controller.AddOrUpdateTaintOnNode(c, nodeName, &taint))
27672777
}
@@ -2785,6 +2795,7 @@ func verifyThatTaintIsGone(c clientset.Interface, nodeName string, taint *v1.Tai
27852795
}
27862796
}
27872797

2798+
// ExpectNodeHasTaint expects that the node has the given taint.
27882799
func ExpectNodeHasTaint(c clientset.Interface, nodeName string, taint *v1.Taint) {
27892800
ginkgo.By("verifying the node has the taint " + taint.ToString())
27902801
if has, err := NodeHasTaint(c, nodeName, taint); !has {
@@ -2793,6 +2804,7 @@ func ExpectNodeHasTaint(c clientset.Interface, nodeName string, taint *v1.Taint)
27932804
}
27942805
}
27952806

2807+
// NodeHasTaint returns true if the node has the given taint, else returns false.
27962808
func NodeHasTaint(c clientset.Interface, nodeName string, taint *v1.Taint) (bool, error) {
27972809
node, err := c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
27982810
if err != nil {
@@ -2807,7 +2819,7 @@ func NodeHasTaint(c clientset.Interface, nodeName string, taint *v1.Taint) (bool
28072819
return true, nil
28082820
}
28092821

2810-
//AddOrUpdateAvoidPodOnNode adds avoidPods annotations to node, will override if it exists
2822+
// AddOrUpdateAvoidPodOnNode adds avoidPods annotations to node, will override if it exists
28112823
func AddOrUpdateAvoidPodOnNode(c clientset.Interface, nodeName string, avoidPods v1.AvoidPods) {
28122824
err := wait.PollImmediate(Poll, SingleCallTimeout, func() (bool, error) {
28132825
node, err := c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
@@ -2838,7 +2850,7 @@ func AddOrUpdateAvoidPodOnNode(c clientset.Interface, nodeName string, avoidPods
28382850
ExpectNoError(err)
28392851
}
28402852

2841-
//RemoveAnnotationOffNode removes AvoidPods annotations from the node. It does not fail if no such annotation exists.
2853+
// RemoveAvoidPodsOffNode removes AvoidPods annotations from the node. It does not fail if no such annotation exists.
28422854
func RemoveAvoidPodsOffNode(c clientset.Interface, nodeName string) {
28432855
err := wait.PollImmediate(Poll, SingleCallTimeout, func() (bool, error) {
28442856
node, err := c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
@@ -2866,6 +2878,7 @@ func RemoveAvoidPodsOffNode(c clientset.Interface, nodeName string) {
28662878
ExpectNoError(err)
28672879
}
28682880

2881+
// ScaleResource scales resource to the given size.
28692882
func ScaleResource(
28702883
clientset clientset.Interface,
28712884
scalesGetter scaleclient.ScalesGetter,
@@ -2885,7 +2898,7 @@ func ScaleResource(
28852898
return WaitForControlledPodsRunning(clientset, ns, name, kind)
28862899
}
28872900

2888-
// Wait up to 10 minutes for pods to become Running.
2901+
// WaitForControlledPodsRunning waits up to 10 minutes for pods to become Running.
28892902
func WaitForControlledPodsRunning(c clientset.Interface, ns, name string, kind schema.GroupKind) error {
28902903
rtObject, err := getRuntimeObjectForKind(c, kind, ns, name)
28912904
if err != nil {
@@ -2906,7 +2919,7 @@ func WaitForControlledPodsRunning(c clientset.Interface, ns, name string, kind s
29062919
return nil
29072920
}
29082921

2909-
// Wait up to PodListTimeout for getting pods of the specified controller name and return them.
2922+
// WaitForControlledPods waits up to PodListTimeout for getting pods of the specified controller name and return them.
29102923
func WaitForControlledPods(c clientset.Interface, ns, name string, kind schema.GroupKind) (pods *v1.PodList, err error) {
29112924
rtObject, err := getRuntimeObjectForKind(c, kind, ns, name)
29122925
if err != nil {
@@ -2919,7 +2932,7 @@ func WaitForControlledPods(c clientset.Interface, ns, name string, kind schema.G
29192932
return WaitForPodsWithLabel(c, ns, selector)
29202933
}
29212934

2922-
// Wait for all matching pods to become scheduled and at least one
2935+
// WaitForPodsWithLabelScheduled waits for all matching pods to become scheduled and at least one
29232936
// matching pod exists. Return the list of matching pods.
29242937
func WaitForPodsWithLabelScheduled(c clientset.Interface, ns string, label labels.Selector) (pods *v1.PodList, err error) {
29252938
err = wait.PollImmediate(Poll, podScheduledBeforeTimeout,
@@ -2938,7 +2951,7 @@ func WaitForPodsWithLabelScheduled(c clientset.Interface, ns string, label label
29382951
return pods, err
29392952
}
29402953

2941-
// Wait up to PodListTimeout for getting pods with certain label
2954+
// WaitForPodsWithLabel waits up to PodListTimeout for getting pods with certain label
29422955
func WaitForPodsWithLabel(c clientset.Interface, ns string, label labels.Selector) (pods *v1.PodList, err error) {
29432956
for t := time.Now(); time.Since(t) < PodListTimeout; time.Sleep(Poll) {
29442957
options := metav1.ListOptions{LabelSelector: label.String()}
@@ -2959,7 +2972,7 @@ func WaitForPodsWithLabel(c clientset.Interface, ns string, label labels.Selecto
29592972
return
29602973
}
29612974

2962-
// Wait for exact amount of matching pods to become running and ready.
2975+
// WaitForPodsWithLabelRunningReady waits for exact amount of matching pods to become running and ready.
29632976
// Return the list of matching pods.
29642977
func WaitForPodsWithLabelRunningReady(c clientset.Interface, ns string, label labels.Selector, num int, timeout time.Duration) (pods *v1.PodList, err error) {
29652978
var current int
@@ -3190,6 +3203,7 @@ func waitForPodsGone(ps *testutils.PodStore, interval, timeout time.Duration) er
31903203
return err
31913204
}
31923205

3206+
// WaitForPodsReady waits for the pods to become ready.
31933207
func WaitForPodsReady(c clientset.Interface, ns, name string, minReadySeconds int) error {
31943208
label := labels.SelectorFromSet(labels.Set(map[string]string{"name": name}))
31953209
options := metav1.ListOptions{LabelSelector: label.String()}
@@ -3207,7 +3221,7 @@ func WaitForPodsReady(c clientset.Interface, ns, name string, minReadySeconds in
32073221
})
32083222
}
32093223

3210-
// WaitForNPods tries to list restarting pods using ps until it finds expect of them,
3224+
// WaitForNRestartablePods tries to list restarting pods using ps until it finds expect of them,
32113225
// returning their names if it can do so before timeout.
32123226
func WaitForNRestartablePods(ps *testutils.PodStore, expect int, timeout time.Duration) ([]string, error) {
32133227
var pods []*v1.Pod
@@ -3233,7 +3247,7 @@ func WaitForNRestartablePods(ps *testutils.PodStore, expect int, timeout time.Du
32333247
return podNames, nil
32343248
}
32353249

3236-
// FilterIrrelevantPods filters out pods that will never get recreated if deleted after termination.
3250+
// FilterNonRestartablePods filters out pods that will never get recreated if deleted after termination.
32373251
func FilterNonRestartablePods(pods []*v1.Pod) []*v1.Pod {
32383252
var results []*v1.Pod
32393253
for _, p := range pods {
@@ -3258,6 +3272,8 @@ func isNotRestartAlwaysMirrorPod(p *v1.Pod) bool {
32583272

32593273
type updateDSFunc func(*apps.DaemonSet)
32603274

3275+
// UpdateDaemonSetWithRetries updates daemonsets with the given applyUpdate func
3276+
// until it succeeds or a timeout expires.
32613277
func UpdateDaemonSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate updateDSFunc) (ds *apps.DaemonSet, err error) {
32623278
daemonsets := c.AppsV1().DaemonSets(namespace)
32633279
var updateErr error
@@ -3411,6 +3427,7 @@ func CreateExecPodOrFail(client clientset.Interface, ns, generateName string, tw
34113427
return created.Name
34123428
}
34133429

3430+
// CreatePodOrFail creates a pod with the specified containerPorts.
34143431
func CreatePodOrFail(c clientset.Interface, ns, name string, labels map[string]string, containerPorts []v1.ContainerPort) {
34153432
ginkgo.By(fmt.Sprintf("Creating pod %s in namespace %s", name, ns))
34163433
pod := &v1.Pod{
@@ -3435,6 +3452,7 @@ func CreatePodOrFail(c clientset.Interface, ns, name string, labels map[string]s
34353452
ExpectNoError(err, "failed to create pod %s in namespace %s", name, ns)
34363453
}
34373454

3455+
// DeletePodOrFail deletes the pod of the specified namespace and name.
34383456
func DeletePodOrFail(c clientset.Interface, ns, name string) {
34393457
ginkgo.By(fmt.Sprintf("Deleting pod %s in namespace %s", name, ns))
34403458
err := c.CoreV1().Pods(ns).Delete(name, nil)
@@ -3560,14 +3578,17 @@ func isNodeConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionT
35603578
return false
35613579
}
35623580

3581+
// IsNodeConditionSetAsExpected returns a wantTrue value if the node has a match to the conditionType, otherwise returns an opposite value of the wantTrue with detailed logging.
35633582
func IsNodeConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool {
35643583
return isNodeConditionSetAsExpected(node, conditionType, wantTrue, false)
35653584
}
35663585

3586+
// IsNodeConditionSetAsExpectedSilent returns a wantTrue value if the node has a match to the conditionType, otherwise returns an opposite value of the wantTrue.
35673587
func IsNodeConditionSetAsExpectedSilent(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool {
35683588
return isNodeConditionSetAsExpected(node, conditionType, wantTrue, true)
35693589
}
35703590

3591+
// IsNodeConditionUnset returns true if conditions of the given node do not have a match to the given conditionType, otherwise false.
35713592
func IsNodeConditionUnset(node *v1.Node, conditionType v1.NodeConditionType) bool {
35723593
for _, cond := range node.Status.Conditions {
35733594
if cond.Type == conditionType {
@@ -3598,7 +3619,7 @@ func WaitForNodeToBe(c clientset.Interface, name string, conditionType v1.NodeCo
35983619
return false
35993620
}
36003621

3601-
// Checks whether all registered nodes are ready.
3622+
// AllNodesReady checks whether all registered nodes are ready.
36023623
// TODO: we should change the AllNodesReady call in AfterEach to WaitForAllNodesHealthy,
36033624
// and figure out how to do it in a configurable way, as we can't expect all setups to run
36043625
// default test add-ons.
@@ -3644,7 +3665,7 @@ func AllNodesReady(c clientset.Interface, timeout time.Duration) error {
36443665
return nil
36453666
}
36463667

3647-
// checks whether all registered nodes are ready and all required Pods are running on them.
3668+
// WaitForAllNodesHealthy checks whether all registered nodes are ready and all required Pods are running on them.
36483669
func WaitForAllNodesHealthy(c clientset.Interface, timeout time.Duration) error {
36493670
Logf("Waiting up to %v for all nodes to be ready", timeout)
36503671

@@ -3712,7 +3733,7 @@ func WaitForAllNodesHealthy(c clientset.Interface, timeout time.Duration) error
37123733

37133734
}
37143735

3715-
// Filters nodes in NodeList in place, removing nodes that do not
3736+
// FilterNodes filters nodes in NodeList in place, removing nodes that do not
37163737
// satisfy the given condition
37173738
// TODO: consider merging with pkg/client/cache.NodeLister
37183739
func FilterNodes(nodeList *v1.NodeList, fn func(node v1.Node) bool) {

0 commit comments

Comments
 (0)