Skip to content

Commit 36b2914

Browse files
authored
Merge pull request kubernetes#81809 from oomichi/replace-e2elog-framework-p
Use log functions of core framework on p*
2 parents 32d8b50 + 0adcf14 commit 36b2914

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

test/e2e/framework/pods.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
3434
"k8s.io/kubernetes/pkg/kubelet/events"
3535
"k8s.io/kubernetes/pkg/kubelet/sysctl"
36-
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
3736
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
3837

3938
"github.com/onsi/ginkgo"
@@ -151,11 +150,11 @@ func (c *PodClient) Update(name string, updateFn func(pod *v1.Pod)) {
151150
updateFn(pod)
152151
_, err = c.PodInterface.Update(pod)
153152
if err == nil {
154-
e2elog.Logf("Successfully updated pod %q", name)
153+
Logf("Successfully updated pod %q", name)
155154
return true, nil
156155
}
157156
if errors.IsConflict(err) {
158-
e2elog.Logf("Conflicting update to pod %q, re-get and re-update: %v", name, err)
157+
Logf("Conflicting update to pod %q, re-get and re-update: %v", name, err)
159158
return false, nil
160159
}
161160
return false, fmt.Errorf("failed to update pod %q: %v", name, err)
@@ -173,7 +172,7 @@ func (c *PodClient) DeleteSync(name string, options *metav1.DeleteOptions, timeo
173172
func (c *PodClient) DeleteSyncInNamespace(name string, namespace string, options *metav1.DeleteOptions, timeout time.Duration) {
174173
err := c.Delete(name, options)
175174
if err != nil && !errors.IsNotFound(err) {
176-
e2elog.Failf("Failed to delete pod %q: %v", name, err)
175+
Failf("Failed to delete pod %q: %v", name, err)
177176
}
178177
gomega.Expect(e2epod.WaitForPodToDisappear(c.f.ClientSet, namespace, name, labels.Everything(),
179178
2*time.Second, timeout)).To(gomega.Succeed(), "wait for pod %q to disappear", name)

test/e2e/framework/pv_util.go

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
clientset "k8s.io/client-go/kubernetes"
3232
storageutil "k8s.io/kubernetes/pkg/apis/storage/v1/util"
3333
"k8s.io/kubernetes/pkg/volume/util"
34-
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
3534
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
3635
imageutils "k8s.io/kubernetes/test/utils/image"
3736
)
@@ -140,15 +139,15 @@ func PVPVCCleanup(c clientset.Interface, ns string, pv *v1.PersistentVolume, pvc
140139
errs = append(errs, fmt.Errorf("failed to delete PVC %q: %v", pvc.Name, err))
141140
}
142141
} else {
143-
e2elog.Logf("pvc is nil")
142+
Logf("pvc is nil")
144143
}
145144
if pv != nil {
146145
err := DeletePersistentVolume(c, pv.Name)
147146
if err != nil {
148147
errs = append(errs, fmt.Errorf("failed to delete PV %q: %v", pv.Name, err))
149148
}
150149
} else {
151-
e2elog.Logf("pv is nil")
150+
Logf("pv is nil")
152151
}
153152
return errs
154153
}
@@ -182,7 +181,7 @@ func PVPVCMapCleanup(c clientset.Interface, ns string, pvols PVMap, claims PVCMa
182181
// DeletePersistentVolume deletes the PV.
183182
func DeletePersistentVolume(c clientset.Interface, pvName string) error {
184183
if c != nil && len(pvName) > 0 {
185-
e2elog.Logf("Deleting PersistentVolume %q", pvName)
184+
Logf("Deleting PersistentVolume %q", pvName)
186185
err := c.CoreV1().PersistentVolumes().Delete(pvName, nil)
187186
if err != nil && !apierrs.IsNotFound(err) {
188187
return fmt.Errorf("PV Delete API error: %v", err)
@@ -194,7 +193,7 @@ func DeletePersistentVolume(c clientset.Interface, pvName string) error {
194193
// DeletePersistentVolumeClaim deletes the Claim.
195194
func DeletePersistentVolumeClaim(c clientset.Interface, pvcName string, ns string) error {
196195
if c != nil && len(pvcName) > 0 {
197-
e2elog.Logf("Deleting PersistentVolumeClaim %q", pvcName)
196+
Logf("Deleting PersistentVolumeClaim %q", pvcName)
198197
err := c.CoreV1().PersistentVolumeClaims(ns).Delete(pvcName, nil)
199198
if err != nil && !apierrs.IsNotFound(err) {
200199
return fmt.Errorf("PVC Delete API error: %v", err)
@@ -208,14 +207,14 @@ func DeletePersistentVolumeClaim(c clientset.Interface, pvcName string, ns strin
208207
// phase value to expect for the pv bound to the to-be-deleted claim.
209208
func DeletePVCandValidatePV(c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume, expectPVPhase v1.PersistentVolumePhase) error {
210209
pvname := pvc.Spec.VolumeName
211-
e2elog.Logf("Deleting PVC %v to trigger reclamation of PV %v", pvc.Name, pvname)
210+
Logf("Deleting PVC %v to trigger reclamation of PV %v", pvc.Name, pvname)
212211
err := DeletePersistentVolumeClaim(c, pvc.Name, ns)
213212
if err != nil {
214213
return err
215214
}
216215

217216
// Wait for the PV's phase to return to be `expectPVPhase`
218-
e2elog.Logf("Waiting for reclaim process to complete.")
217+
Logf("Waiting for reclaim process to complete.")
219218
err = WaitForPersistentVolumePhase(expectPVPhase, c, pv.Name, Poll, PVReclaimingTimeout)
220219
if err != nil {
221220
return fmt.Errorf("pv %q phase did not become %v: %v", pv.Name, expectPVPhase, err)
@@ -240,7 +239,7 @@ func DeletePVCandValidatePV(c clientset.Interface, ns string, pvc *v1.Persistent
240239
}
241240
}
242241

243-
e2elog.Logf("PV %v now in %q phase", pv.Name, expectPVPhase)
242+
Logf("PV %v now in %q phase", pv.Name, expectPVPhase)
244243
return nil
245244
}
246245

@@ -357,7 +356,7 @@ func CreatePVPVC(c clientset.Interface, pvConfig PersistentVolumeConfig, pvcConf
357356
if preBind {
358357
preBindMsg = " pre-bound"
359358
}
360-
e2elog.Logf("Creating a PV followed by a%s PVC", preBindMsg)
359+
Logf("Creating a PV followed by a%s PVC", preBindMsg)
361360

362361
// make the pv and pvc definitions
363362
pv := MakePersistentVolume(pvConfig)
@@ -430,7 +429,7 @@ func CreatePVsPVCs(numpvs, numpvcs int, c clientset.Interface, ns string, pvConf
430429
// WaitOnPVandPVC waits for the pv and pvc to bind to each other.
431430
func WaitOnPVandPVC(c clientset.Interface, ns string, pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim) error {
432431
// Wait for newly created PVC to bind to the PV
433-
e2elog.Logf("Waiting for PV %v to bind to PVC %v", pv.Name, pvc.Name)
432+
Logf("Waiting for PV %v to bind to PVC %v", pv.Name, pvc.Name)
434433
err := WaitForPersistentVolumeClaimPhase(v1.ClaimBound, c, ns, pvc.Name, Poll, ClaimBindingTimeout)
435434
if err != nil {
436435
return fmt.Errorf("PVC %q did not become Bound: %v", pvc.Name, err)
@@ -486,8 +485,8 @@ func WaitAndVerifyBinds(c clientset.Interface, ns string, pvols PVMap, claims PV
486485
for pvName := range pvols {
487486
err := WaitForPersistentVolumePhase(v1.VolumeBound, c, pvName, Poll, PVBindingTimeout)
488487
if err != nil && len(pvols) > len(claims) {
489-
e2elog.Logf("WARN: pv %v is not bound after max wait", pvName)
490-
e2elog.Logf(" This may be ok since there are more pvs than pvcs")
488+
Logf("WARN: pv %v is not bound after max wait", pvName)
489+
Logf(" This may be ok since there are more pvs than pvcs")
491490
continue
492491
}
493492
if err != nil {
@@ -527,7 +526,7 @@ func testPodSuccessOrFail(c clientset.Interface, ns string, pod *v1.Pod) error {
527526
if err := e2epod.WaitForPodSuccessInNamespace(c, pod.Name, ns); err != nil {
528527
return fmt.Errorf("pod %q failed to reach Success: %v", pod.Name, err)
529528
}
530-
e2elog.Logf("Pod %v succeeded ", pod.Name)
529+
Logf("Pod %v succeeded ", pod.Name)
531530
return nil
532531
}
533532

@@ -543,15 +542,15 @@ func DeletePodWithWait(f *Framework, c clientset.Interface, pod *v1.Pod) error {
543542
// DeletePodWithWaitByName deletes the named and namespaced pod and waits for the pod to be terminated. Resilient to the pod
544543
// not existing.
545544
func DeletePodWithWaitByName(f *Framework, c clientset.Interface, podName, podNamespace string) error {
546-
e2elog.Logf("Deleting pod %q in namespace %q", podName, podNamespace)
545+
Logf("Deleting pod %q in namespace %q", podName, podNamespace)
547546
err := c.CoreV1().Pods(podNamespace).Delete(podName, nil)
548547
if err != nil {
549548
if apierrs.IsNotFound(err) {
550549
return nil // assume pod was already deleted
551550
}
552551
return fmt.Errorf("pod Delete API error: %v", err)
553552
}
554-
e2elog.Logf("Wait up to %v for pod %q to be fully deleted", PodDeleteTimeout, podName)
553+
Logf("Wait up to %v for pod %q to be fully deleted", PodDeleteTimeout, podName)
555554
err = f.WaitForPodNotFound(podName, PodDeleteTimeout)
556555
if err != nil {
557556
return fmt.Errorf("pod %q was not deleted: %v", podName, err)
@@ -563,7 +562,7 @@ func DeletePodWithWaitByName(f *Framework, c clientset.Interface, podName, podNa
563562
// Note: need named return value so that the err assignment in the defer sets the returned error.
564563
// Has been shown to be necessary using Go 1.7.
565564
func CreateWaitAndDeletePod(f *Framework, c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim) (err error) {
566-
e2elog.Logf("Creating nfs test pod")
565+
Logf("Creating nfs test pod")
567566
pod := MakeWritePod(ns, pvc)
568567
runPod, err := c.CoreV1().Pods(ns).Create(pod)
569568
if err != nil {
@@ -663,7 +662,7 @@ func MakePersistentVolumeClaim(cfg PersistentVolumeClaimConfig, ns string) *v1.P
663662
}
664663

665664
if cfg.VolumeMode != nil && *cfg.VolumeMode == "" {
666-
e2elog.Logf("Warning: Making PVC: VolumeMode specified as invalid empty string, treating as nil")
665+
Logf("Warning: Making PVC: VolumeMode specified as invalid empty string, treating as nil")
667666
cfg.VolumeMode = nil
668667
}
669668

@@ -693,10 +692,10 @@ func createPDWithRetry(zone string) (string, error) {
693692
for start := time.Now(); time.Since(start) < pdRetryTimeout; time.Sleep(pdRetryPollTime) {
694693
newDiskName, err = createPD(zone)
695694
if err != nil {
696-
e2elog.Logf("Couldn't create a new PD, sleeping 5 seconds: %v", err)
695+
Logf("Couldn't create a new PD, sleeping 5 seconds: %v", err)
697696
continue
698697
}
699-
e2elog.Logf("Successfully created a new PD: %q.", newDiskName)
698+
Logf("Successfully created a new PD: %q.", newDiskName)
700699
return newDiskName, nil
701700
}
702701
return "", err
@@ -718,10 +717,10 @@ func DeletePDWithRetry(diskName string) error {
718717
for start := time.Now(); time.Since(start) < pdRetryTimeout; time.Sleep(pdRetryPollTime) {
719718
err = deletePD(diskName)
720719
if err != nil {
721-
e2elog.Logf("Couldn't delete PD %q, sleeping %v: %v", diskName, pdRetryPollTime, err)
720+
Logf("Couldn't delete PD %q, sleeping %v: %v", diskName, pdRetryPollTime, err)
722721
continue
723722
}
724-
e2elog.Logf("Successfully deleted PD %q.", diskName)
723+
Logf("Successfully deleted PD %q.", diskName)
725724
return nil
726725
}
727726
return fmt.Errorf("unable to delete PD %q: %v", diskName, err)
@@ -1096,7 +1095,7 @@ func GetDefaultStorageClassName(c clientset.Interface) (string, error) {
10961095
if len(scName) == 0 {
10971096
return "", fmt.Errorf("No default storage class found")
10981097
}
1099-
e2elog.Logf("Default storage class: %q", scName)
1098+
Logf("Default storage class: %q", scName)
11001099
return scName, nil
11011100
}
11021101

0 commit comments

Comments
 (0)