@@ -2412,8 +2412,10 @@ func (f *Framework) MatchContainerOutput(
2412
2412
return nil
2413
2413
}
2414
2414
2415
+ // EventsLister is a func that lists events.
2415
2416
type EventsLister func (opts metav1.ListOptions , ns string ) (* v1.EventList , error )
2416
2417
2418
+ // DumpEventsInNamespace dumps events in the given namespace.
2417
2419
func DumpEventsInNamespace (eventsLister EventsLister , namespace string ) {
2418
2420
ginkgo .By (fmt .Sprintf ("Collecting events from namespace %q." , namespace ))
2419
2421
events , err := eventsLister (metav1.ListOptions {}, namespace )
@@ -2433,6 +2435,7 @@ func DumpEventsInNamespace(eventsLister EventsLister, namespace string) {
2433
2435
// you may or may not see the killing/deletion/Cleanup events.
2434
2436
}
2435
2437
2438
+ // DumpAllNamespaceInfo dumps events, pods and nodes information in the given namespace.
2436
2439
func DumpAllNamespaceInfo (c clientset.Interface , namespace string ) {
2437
2440
DumpEventsInNamespace (func (opts metav1.ListOptions , ns string ) (* v1.EventList , error ) {
2438
2441
return c .CoreV1 ().Events (ns ).List (opts )
@@ -2490,6 +2493,7 @@ func dumpAllNodeInfo(c clientset.Interface) {
2490
2493
DumpNodeDebugInfo (c , names , Logf )
2491
2494
}
2492
2495
2496
+ // DumpNodeDebugInfo dumps debug information of the given nodes.
2493
2497
func DumpNodeDebugInfo (c clientset.Interface , nodeNames []string , logFunc func (fmt string , args ... interface {})) {
2494
2498
for _ , n := range nodeNames {
2495
2499
logFunc ("\n Logging node info for node %v" , n )
@@ -2701,6 +2705,7 @@ func WaitForAllNodesSchedulable(c clientset.Interface, timeout time.Duration) er
2701
2705
})
2702
2706
}
2703
2707
2708
+ // GetPodSecretUpdateTimeout reuturns the timeout duration for updating pod secret.
2704
2709
func GetPodSecretUpdateTimeout (c clientset.Interface ) time.Duration {
2705
2710
// With SecretManager(ConfigMapManager), we may have to wait up to full sync period +
2706
2711
// 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) {
2737
2742
return time .Duration (intValue ) * time .Second , nil
2738
2743
}
2739
2744
2745
+ // AddOrUpdateLabelOnNode adds the given label key and value to the given node or updates value.
2740
2746
func AddOrUpdateLabelOnNode (c clientset.Interface , nodeName string , labelKey , labelValue string ) {
2741
2747
ExpectNoError (testutils .AddLabelsToNode (c , nodeName , map [string ]string {labelKey : labelValue }))
2742
2748
}
2743
2749
2750
+ // AddOrUpdateLabelOnNodeAndReturnOldValue adds the given label key and value to the given node or updates value and returns the old label value.
2744
2751
func AddOrUpdateLabelOnNodeAndReturnOldValue (c clientset.Interface , nodeName string , labelKey , labelValue string ) string {
2745
2752
var oldValue string
2746
2753
node , err := c .CoreV1 ().Nodes ().Get (nodeName , metav1.GetOptions {})
@@ -2750,18 +2757,21 @@ func AddOrUpdateLabelOnNodeAndReturnOldValue(c clientset.Interface, nodeName str
2750
2757
return oldValue
2751
2758
}
2752
2759
2760
+ // ExpectNodeHasLabel expects that the given node has the given label pair.
2753
2761
func ExpectNodeHasLabel (c clientset.Interface , nodeName string , labelKey string , labelValue string ) {
2754
2762
ginkgo .By ("verifying the node has the label " + labelKey + " " + labelValue )
2755
2763
node , err := c .CoreV1 ().Nodes ().Get (nodeName , metav1.GetOptions {})
2756
2764
ExpectNoError (err )
2757
2765
gomega .Expect (node .Labels [labelKey ]).To (gomega .Equal (labelValue ))
2758
2766
}
2759
2767
2768
+ // RemoveTaintOffNode removes the given taint from the given node.
2760
2769
func RemoveTaintOffNode (c clientset.Interface , nodeName string , taint v1.Taint ) {
2761
2770
ExpectNoError (controller .RemoveTaintOffNode (c , nodeName , nil , & taint ))
2762
2771
verifyThatTaintIsGone (c , nodeName , & taint )
2763
2772
}
2764
2773
2774
+ // AddOrUpdateTaintOnNode adds the given taint to the given node or updates taint.
2765
2775
func AddOrUpdateTaintOnNode (c clientset.Interface , nodeName string , taint v1.Taint ) {
2766
2776
ExpectNoError (controller .AddOrUpdateTaintOnNode (c , nodeName , & taint ))
2767
2777
}
@@ -2785,6 +2795,7 @@ func verifyThatTaintIsGone(c clientset.Interface, nodeName string, taint *v1.Tai
2785
2795
}
2786
2796
}
2787
2797
2798
+ // ExpectNodeHasTaint expects that the node has the given taint.
2788
2799
func ExpectNodeHasTaint (c clientset.Interface , nodeName string , taint * v1.Taint ) {
2789
2800
ginkgo .By ("verifying the node has the taint " + taint .ToString ())
2790
2801
if has , err := NodeHasTaint (c , nodeName , taint ); ! has {
@@ -2793,6 +2804,7 @@ func ExpectNodeHasTaint(c clientset.Interface, nodeName string, taint *v1.Taint)
2793
2804
}
2794
2805
}
2795
2806
2807
+ // NodeHasTaint returns true if the node has the given taint, else returns false.
2796
2808
func NodeHasTaint (c clientset.Interface , nodeName string , taint * v1.Taint ) (bool , error ) {
2797
2809
node , err := c .CoreV1 ().Nodes ().Get (nodeName , metav1.GetOptions {})
2798
2810
if err != nil {
@@ -2807,7 +2819,7 @@ func NodeHasTaint(c clientset.Interface, nodeName string, taint *v1.Taint) (bool
2807
2819
return true , nil
2808
2820
}
2809
2821
2810
- //AddOrUpdateAvoidPodOnNode adds avoidPods annotations to node, will override if it exists
2822
+ // AddOrUpdateAvoidPodOnNode adds avoidPods annotations to node, will override if it exists
2811
2823
func AddOrUpdateAvoidPodOnNode (c clientset.Interface , nodeName string , avoidPods v1.AvoidPods ) {
2812
2824
err := wait .PollImmediate (Poll , SingleCallTimeout , func () (bool , error ) {
2813
2825
node , err := c .CoreV1 ().Nodes ().Get (nodeName , metav1.GetOptions {})
@@ -2838,7 +2850,7 @@ func AddOrUpdateAvoidPodOnNode(c clientset.Interface, nodeName string, avoidPods
2838
2850
ExpectNoError (err )
2839
2851
}
2840
2852
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.
2842
2854
func RemoveAvoidPodsOffNode (c clientset.Interface , nodeName string ) {
2843
2855
err := wait .PollImmediate (Poll , SingleCallTimeout , func () (bool , error ) {
2844
2856
node , err := c .CoreV1 ().Nodes ().Get (nodeName , metav1.GetOptions {})
@@ -2866,6 +2878,7 @@ func RemoveAvoidPodsOffNode(c clientset.Interface, nodeName string) {
2866
2878
ExpectNoError (err )
2867
2879
}
2868
2880
2881
+ // ScaleResource scales resource to the given size.
2869
2882
func ScaleResource (
2870
2883
clientset clientset.Interface ,
2871
2884
scalesGetter scaleclient.ScalesGetter ,
@@ -2885,7 +2898,7 @@ func ScaleResource(
2885
2898
return WaitForControlledPodsRunning (clientset , ns , name , kind )
2886
2899
}
2887
2900
2888
- // Wait up to 10 minutes for pods to become Running.
2901
+ // WaitForControlledPodsRunning waits up to 10 minutes for pods to become Running.
2889
2902
func WaitForControlledPodsRunning (c clientset.Interface , ns , name string , kind schema.GroupKind ) error {
2890
2903
rtObject , err := getRuntimeObjectForKind (c , kind , ns , name )
2891
2904
if err != nil {
@@ -2906,7 +2919,7 @@ func WaitForControlledPodsRunning(c clientset.Interface, ns, name string, kind s
2906
2919
return nil
2907
2920
}
2908
2921
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.
2910
2923
func WaitForControlledPods (c clientset.Interface , ns , name string , kind schema.GroupKind ) (pods * v1.PodList , err error ) {
2911
2924
rtObject , err := getRuntimeObjectForKind (c , kind , ns , name )
2912
2925
if err != nil {
@@ -2919,7 +2932,7 @@ func WaitForControlledPods(c clientset.Interface, ns, name string, kind schema.G
2919
2932
return WaitForPodsWithLabel (c , ns , selector )
2920
2933
}
2921
2934
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
2923
2936
// matching pod exists. Return the list of matching pods.
2924
2937
func WaitForPodsWithLabelScheduled (c clientset.Interface , ns string , label labels.Selector ) (pods * v1.PodList , err error ) {
2925
2938
err = wait .PollImmediate (Poll , podScheduledBeforeTimeout ,
@@ -2938,7 +2951,7 @@ func WaitForPodsWithLabelScheduled(c clientset.Interface, ns string, label label
2938
2951
return pods , err
2939
2952
}
2940
2953
2941
- // Wait up to PodListTimeout for getting pods with certain label
2954
+ // WaitForPodsWithLabel waits up to PodListTimeout for getting pods with certain label
2942
2955
func WaitForPodsWithLabel (c clientset.Interface , ns string , label labels.Selector ) (pods * v1.PodList , err error ) {
2943
2956
for t := time .Now (); time .Since (t ) < PodListTimeout ; time .Sleep (Poll ) {
2944
2957
options := metav1.ListOptions {LabelSelector : label .String ()}
@@ -2959,7 +2972,7 @@ func WaitForPodsWithLabel(c clientset.Interface, ns string, label labels.Selecto
2959
2972
return
2960
2973
}
2961
2974
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.
2963
2976
// Return the list of matching pods.
2964
2977
func WaitForPodsWithLabelRunningReady (c clientset.Interface , ns string , label labels.Selector , num int , timeout time.Duration ) (pods * v1.PodList , err error ) {
2965
2978
var current int
@@ -3190,6 +3203,7 @@ func waitForPodsGone(ps *testutils.PodStore, interval, timeout time.Duration) er
3190
3203
return err
3191
3204
}
3192
3205
3206
+ // WaitForPodsReady waits for the pods to become ready.
3193
3207
func WaitForPodsReady (c clientset.Interface , ns , name string , minReadySeconds int ) error {
3194
3208
label := labels .SelectorFromSet (labels .Set (map [string ]string {"name" : name }))
3195
3209
options := metav1.ListOptions {LabelSelector : label .String ()}
@@ -3207,7 +3221,7 @@ func WaitForPodsReady(c clientset.Interface, ns, name string, minReadySeconds in
3207
3221
})
3208
3222
}
3209
3223
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,
3211
3225
// returning their names if it can do so before timeout.
3212
3226
func WaitForNRestartablePods (ps * testutils.PodStore , expect int , timeout time.Duration ) ([]string , error ) {
3213
3227
var pods []* v1.Pod
@@ -3233,7 +3247,7 @@ func WaitForNRestartablePods(ps *testutils.PodStore, expect int, timeout time.Du
3233
3247
return podNames , nil
3234
3248
}
3235
3249
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.
3237
3251
func FilterNonRestartablePods (pods []* v1.Pod ) []* v1.Pod {
3238
3252
var results []* v1.Pod
3239
3253
for _ , p := range pods {
@@ -3258,6 +3272,8 @@ func isNotRestartAlwaysMirrorPod(p *v1.Pod) bool {
3258
3272
3259
3273
type updateDSFunc func (* apps.DaemonSet )
3260
3274
3275
+ // UpdateDaemonSetWithRetries updates daemonsets with the given applyUpdate func
3276
+ // until it succeeds or a timeout expires.
3261
3277
func UpdateDaemonSetWithRetries (c clientset.Interface , namespace , name string , applyUpdate updateDSFunc ) (ds * apps.DaemonSet , err error ) {
3262
3278
daemonsets := c .AppsV1 ().DaemonSets (namespace )
3263
3279
var updateErr error
@@ -3411,6 +3427,7 @@ func CreateExecPodOrFail(client clientset.Interface, ns, generateName string, tw
3411
3427
return created .Name
3412
3428
}
3413
3429
3430
+ // CreatePodOrFail creates a pod with the specified containerPorts.
3414
3431
func CreatePodOrFail (c clientset.Interface , ns , name string , labels map [string ]string , containerPorts []v1.ContainerPort ) {
3415
3432
ginkgo .By (fmt .Sprintf ("Creating pod %s in namespace %s" , name , ns ))
3416
3433
pod := & v1.Pod {
@@ -3435,6 +3452,7 @@ func CreatePodOrFail(c clientset.Interface, ns, name string, labels map[string]s
3435
3452
ExpectNoError (err , "failed to create pod %s in namespace %s" , name , ns )
3436
3453
}
3437
3454
3455
+ // DeletePodOrFail deletes the pod of the specified namespace and name.
3438
3456
func DeletePodOrFail (c clientset.Interface , ns , name string ) {
3439
3457
ginkgo .By (fmt .Sprintf ("Deleting pod %s in namespace %s" , name , ns ))
3440
3458
err := c .CoreV1 ().Pods (ns ).Delete (name , nil )
@@ -3560,14 +3578,17 @@ func isNodeConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionT
3560
3578
return false
3561
3579
}
3562
3580
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.
3563
3582
func IsNodeConditionSetAsExpected (node * v1.Node , conditionType v1.NodeConditionType , wantTrue bool ) bool {
3564
3583
return isNodeConditionSetAsExpected (node , conditionType , wantTrue , false )
3565
3584
}
3566
3585
3586
+ // IsNodeConditionSetAsExpectedSilent returns a wantTrue value if the node has a match to the conditionType, otherwise returns an opposite value of the wantTrue.
3567
3587
func IsNodeConditionSetAsExpectedSilent (node * v1.Node , conditionType v1.NodeConditionType , wantTrue bool ) bool {
3568
3588
return isNodeConditionSetAsExpected (node , conditionType , wantTrue , true )
3569
3589
}
3570
3590
3591
+ // IsNodeConditionUnset returns true if conditions of the given node do not have a match to the given conditionType, otherwise false.
3571
3592
func IsNodeConditionUnset (node * v1.Node , conditionType v1.NodeConditionType ) bool {
3572
3593
for _ , cond := range node .Status .Conditions {
3573
3594
if cond .Type == conditionType {
@@ -3598,7 +3619,7 @@ func WaitForNodeToBe(c clientset.Interface, name string, conditionType v1.NodeCo
3598
3619
return false
3599
3620
}
3600
3621
3601
- // Checks whether all registered nodes are ready.
3622
+ // AllNodesReady checks whether all registered nodes are ready.
3602
3623
// TODO: we should change the AllNodesReady call in AfterEach to WaitForAllNodesHealthy,
3603
3624
// and figure out how to do it in a configurable way, as we can't expect all setups to run
3604
3625
// default test add-ons.
@@ -3644,7 +3665,7 @@ func AllNodesReady(c clientset.Interface, timeout time.Duration) error {
3644
3665
return nil
3645
3666
}
3646
3667
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.
3648
3669
func WaitForAllNodesHealthy (c clientset.Interface , timeout time.Duration ) error {
3649
3670
Logf ("Waiting up to %v for all nodes to be ready" , timeout )
3650
3671
@@ -3712,7 +3733,7 @@ func WaitForAllNodesHealthy(c clientset.Interface, timeout time.Duration) error
3712
3733
3713
3734
}
3714
3735
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
3716
3737
// satisfy the given condition
3717
3738
// TODO: consider merging with pkg/client/cache.NodeLister
3718
3739
func FilterNodes (nodeList * v1.NodeList , fn func (node v1.Node ) bool ) {
0 commit comments