@@ -31,7 +31,7 @@ import (
31
31
"k8s.io/apimachinery/pkg/util/wait"
32
32
clientset "k8s.io/client-go/kubernetes"
33
33
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
34
- e2efwk "k8s.io/kubernetes/test/e2e/framework"
34
+ "k8s.io/kubernetes/test/e2e/framework"
35
35
"k8s.io/kubernetes/test/e2e/manifest"
36
36
)
37
37
@@ -41,37 +41,37 @@ func CreateStatefulSet(c clientset.Interface, manifestPath, ns string) *appsv1.S
41
41
return filepath .Join (manifestPath , file )
42
42
}
43
43
44
- e2efwk .Logf ("Parsing statefulset from %v" , mkpath ("statefulset.yaml" ))
44
+ framework .Logf ("Parsing statefulset from %v" , mkpath ("statefulset.yaml" ))
45
45
ss , err := manifest .StatefulSetFromManifest (mkpath ("statefulset.yaml" ), ns )
46
- e2efwk .ExpectNoError (err )
47
- e2efwk .Logf ("Parsing service from %v" , mkpath ("service.yaml" ))
46
+ framework .ExpectNoError (err )
47
+ framework .Logf ("Parsing service from %v" , mkpath ("service.yaml" ))
48
48
svc , err := manifest .SvcFromManifest (mkpath ("service.yaml" ))
49
- e2efwk .ExpectNoError (err )
49
+ framework .ExpectNoError (err )
50
50
51
- e2efwk .Logf (fmt .Sprintf ("creating " + ss .Name + " service" ))
51
+ framework .Logf (fmt .Sprintf ("creating " + ss .Name + " service" ))
52
52
_ , err = c .CoreV1 ().Services (ns ).Create (svc )
53
- e2efwk .ExpectNoError (err )
53
+ framework .ExpectNoError (err )
54
54
55
- e2efwk .Logf (fmt .Sprintf ("creating statefulset %v/%v with %d replicas and selector %+v" , ss .Namespace , ss .Name , * (ss .Spec .Replicas ), ss .Spec .Selector ))
55
+ framework .Logf (fmt .Sprintf ("creating statefulset %v/%v with %d replicas and selector %+v" , ss .Namespace , ss .Name , * (ss .Spec .Replicas ), ss .Spec .Selector ))
56
56
_ , err = c .AppsV1 ().StatefulSets (ns ).Create (ss )
57
- e2efwk .ExpectNoError (err )
57
+ framework .ExpectNoError (err )
58
58
WaitForRunningAndReady (c , * ss .Spec .Replicas , ss )
59
59
return ss
60
60
}
61
61
62
62
// GetPodList gets the current Pods in ss.
63
63
func GetPodList (c clientset.Interface , ss * appsv1.StatefulSet ) * v1.PodList {
64
64
selector , err := metav1 .LabelSelectorAsSelector (ss .Spec .Selector )
65
- e2efwk .ExpectNoError (err )
65
+ framework .ExpectNoError (err )
66
66
podList , err := c .CoreV1 ().Pods (ss .Namespace ).List (metav1.ListOptions {LabelSelector : selector .String ()})
67
- e2efwk .ExpectNoError (err )
67
+ framework .ExpectNoError (err )
68
68
return podList
69
69
}
70
70
71
71
// DeleteAllStatefulSets deletes all StatefulSet API Objects in Namespace ns.
72
72
func DeleteAllStatefulSets (c clientset.Interface , ns string ) {
73
73
ssList , err := c .AppsV1 ().StatefulSets (ns ).List (metav1.ListOptions {LabelSelector : labels .Everything ().String ()})
74
- e2efwk .ExpectNoError (err )
74
+ framework .ExpectNoError (err )
75
75
76
76
// Scale down each statefulset, then delete it completely.
77
77
// Deleting a pvc without doing this will leak volumes, #25101.
@@ -83,7 +83,7 @@ func DeleteAllStatefulSets(c clientset.Interface, ns string) {
83
83
errList = append (errList , fmt .Sprintf ("%v" , err ))
84
84
}
85
85
WaitForStatusReplicas (c , ss , 0 )
86
- e2efwk .Logf ("Deleting statefulset %v" , ss .Name )
86
+ framework .Logf ("Deleting statefulset %v" , ss .Name )
87
87
// Use OrphanDependents=false so it's deleted synchronously.
88
88
// We already made sure the Pods are gone inside Scale().
89
89
if err := c .AppsV1 ().StatefulSets (ss .Namespace ).Delete (ss .Name , & metav1.DeleteOptions {OrphanDependents : new (bool )}); err != nil {
@@ -97,13 +97,13 @@ func DeleteAllStatefulSets(c clientset.Interface, ns string) {
97
97
pvcPollErr := wait .PollImmediate (StatefulSetPoll , StatefulSetTimeout , func () (bool , error ) {
98
98
pvcList , err := c .CoreV1 ().PersistentVolumeClaims (ns ).List (metav1.ListOptions {LabelSelector : labels .Everything ().String ()})
99
99
if err != nil {
100
- e2efwk .Logf ("WARNING: Failed to list pvcs, retrying %v" , err )
100
+ framework .Logf ("WARNING: Failed to list pvcs, retrying %v" , err )
101
101
return false , nil
102
102
}
103
103
for _ , pvc := range pvcList .Items {
104
104
pvNames .Insert (pvc .Spec .VolumeName )
105
105
// TODO: Double check that there are no pods referencing the pvc
106
- e2efwk .Logf ("Deleting pvc: %v with volume %v" , pvc .Name , pvc .Spec .VolumeName )
106
+ framework .Logf ("Deleting pvc: %v with volume %v" , pvc .Name , pvc .Spec .VolumeName )
107
107
if err := c .CoreV1 ().PersistentVolumeClaims (ns ).Delete (pvc .Name , nil ); err != nil {
108
108
return false , nil
109
109
}
@@ -117,7 +117,7 @@ func DeleteAllStatefulSets(c clientset.Interface, ns string) {
117
117
pollErr := wait .PollImmediate (StatefulSetPoll , StatefulSetTimeout , func () (bool , error ) {
118
118
pvList , err := c .CoreV1 ().PersistentVolumes ().List (metav1.ListOptions {LabelSelector : labels .Everything ().String ()})
119
119
if err != nil {
120
- e2efwk .Logf ("WARNING: Failed to list pvs, retrying %v" , err )
120
+ framework .Logf ("WARNING: Failed to list pvs, retrying %v" , err )
121
121
return false , nil
122
122
}
123
123
waitingFor := []string {}
@@ -129,14 +129,14 @@ func DeleteAllStatefulSets(c clientset.Interface, ns string) {
129
129
if len (waitingFor ) == 0 {
130
130
return true , nil
131
131
}
132
- e2efwk .Logf ("Still waiting for pvs of statefulset to disappear:\n %v" , strings .Join (waitingFor , "\n " ))
132
+ framework .Logf ("Still waiting for pvs of statefulset to disappear:\n %v" , strings .Join (waitingFor , "\n " ))
133
133
return false , nil
134
134
})
135
135
if pollErr != nil {
136
136
errList = append (errList , fmt .Sprintf ("Timeout waiting for pv provisioner to delete pvs, this might mean the test leaked pvs." ))
137
137
}
138
138
if len (errList ) != 0 {
139
- e2efwk .ExpectNoError (fmt .Errorf ("%v" , strings .Join (errList , "\n " )))
139
+ framework .ExpectNoError (fmt .Errorf ("%v" , strings .Join (errList , "\n " )))
140
140
}
141
141
}
142
142
@@ -145,7 +145,7 @@ func Scale(c clientset.Interface, ss *appsv1.StatefulSet, count int32) (*appsv1.
145
145
name := ss .Name
146
146
ns := ss .Namespace
147
147
148
- e2efwk .Logf ("Scaling statefulset %s to %d" , name , count )
148
+ framework .Logf ("Scaling statefulset %s to %d" , name , count )
149
149
ss = update (c , ns , name , func (ss * appsv1.StatefulSet ) { * (ss .Spec .Replicas ) = count })
150
150
151
151
var statefulPodList * v1.PodList
@@ -178,7 +178,7 @@ func UpdateReplicas(c clientset.Interface, ss *appsv1.StatefulSet, count int32)
178
178
func Restart (c clientset.Interface , ss * appsv1.StatefulSet ) {
179
179
oldReplicas := * (ss .Spec .Replicas )
180
180
ss , err := Scale (c , ss , 0 )
181
- e2efwk .ExpectNoError (err )
181
+ framework .ExpectNoError (err )
182
182
// Wait for controller to report the desired number of Pods.
183
183
// This way we know the controller has observed all Pod deletions
184
184
// before we scale it back up.
@@ -191,7 +191,7 @@ func CheckHostname(c clientset.Interface, ss *appsv1.StatefulSet) error {
191
191
cmd := "printf $(hostname)"
192
192
podList := GetPodList (c , ss )
193
193
for _ , statefulPod := range podList .Items {
194
- hostname , err := e2efwk .RunHostCmdWithRetries (statefulPod .Namespace , statefulPod .Name , cmd , StatefulSetPoll , StatefulPodTimeout )
194
+ hostname , err := framework .RunHostCmdWithRetries (statefulPod .Namespace , statefulPod .Name , cmd , StatefulSetPoll , StatefulPodTimeout )
195
195
if err != nil {
196
196
return err
197
197
}
@@ -221,7 +221,7 @@ func CheckMount(c clientset.Interface, ss *appsv1.StatefulSet, mountPath string)
221
221
222
222
// CheckServiceName asserts that the ServiceName for ss is equivalent to expectedServiceName.
223
223
func CheckServiceName (ss * appsv1.StatefulSet , expectedServiceName string ) error {
224
- e2efwk .Logf ("Checking if statefulset spec.serviceName is %s" , expectedServiceName )
224
+ framework .Logf ("Checking if statefulset spec.serviceName is %s" , expectedServiceName )
225
225
226
226
if expectedServiceName != ss .Spec .ServiceName {
227
227
return fmt .Errorf ("wrong service name governing statefulset. Expected %s got %s" ,
@@ -235,8 +235,8 @@ func CheckServiceName(ss *appsv1.StatefulSet, expectedServiceName string) error
235
235
func ExecInStatefulPods (c clientset.Interface , ss * appsv1.StatefulSet , cmd string ) error {
236
236
podList := GetPodList (c , ss )
237
237
for _ , statefulPod := range podList .Items {
238
- stdout , err := e2efwk .RunHostCmdWithRetries (statefulPod .Namespace , statefulPod .Name , cmd , StatefulSetPoll , StatefulPodTimeout )
239
- e2efwk .Logf ("stdout of %v on %v: %v" , cmd , statefulPod .Name , stdout )
238
+ stdout , err := framework .RunHostCmdWithRetries (statefulPod .Namespace , statefulPod .Name , cmd , StatefulSetPoll , StatefulPodTimeout )
239
+ framework .Logf ("stdout of %v on %v: %v" , cmd , statefulPod .Name , stdout )
240
240
if err != nil {
241
241
return err
242
242
}
@@ -249,17 +249,17 @@ func update(c clientset.Interface, ns, name string, update func(ss *appsv1.State
249
249
for i := 0 ; i < 3 ; i ++ {
250
250
ss , err := c .AppsV1 ().StatefulSets (ns ).Get (name , metav1.GetOptions {})
251
251
if err != nil {
252
- e2efwk .Failf ("failed to get statefulset %q: %v" , name , err )
252
+ framework .Failf ("failed to get statefulset %q: %v" , name , err )
253
253
}
254
254
update (ss )
255
255
ss , err = c .AppsV1 ().StatefulSets (ns ).Update (ss )
256
256
if err == nil {
257
257
return ss
258
258
}
259
259
if ! apierrors .IsConflict (err ) && ! apierrors .IsServerTimeout (err ) {
260
- e2efwk .Failf ("failed to update statefulset %q: %v" , name , err )
260
+ framework .Failf ("failed to update statefulset %q: %v" , name , err )
261
261
}
262
262
}
263
- e2efwk .Failf ("too many retries draining statefulset %q" , name )
263
+ framework .Failf ("too many retries draining statefulset %q" , name )
264
264
return nil
265
265
}
0 commit comments