From e70120f08380a19ce20d8a8ecac2eaffa9d3ada6 Mon Sep 17 00:00:00 2001 From: SataQiu <1527062125@qq.com> Date: Wed, 11 Dec 2019 10:33:21 +0800 Subject: [PATCH] fix staticcheck failures of e2e/storage/utils e2e/storage/vsphere --- hack/.staticcheck_failures | 2 -- test/e2e/storage/utils/utils.go | 2 +- test/e2e/storage/vsphere/pv_reclaimpolicy.go | 2 +- test/e2e/storage/vsphere/vsphere_scale.go | 1 + test/e2e/storage/vsphere/vsphere_volume_datastore.go | 1 + test/e2e/storage/vsphere/vsphere_volume_fstype.go | 1 + test/e2e/storage/vsphere/vsphere_volume_vsan_policy.go | 1 + test/e2e/storage/vsphere/vsphere_zone_support.go | 7 ++++--- 8 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hack/.staticcheck_failures b/hack/.staticcheck_failures index 867909bc808..880223e95de 100644 --- a/hack/.staticcheck_failures +++ b/hack/.staticcheck_failures @@ -67,8 +67,6 @@ test/e2e/autoscaling test/e2e/instrumentation/logging/stackdriver test/e2e/instrumentation/monitoring test/e2e/manifest -test/e2e/storage/utils -test/e2e/storage/vsphere test/images/agnhost/dns test/images/agnhost/inclusterclient test/images/agnhost/net/nat diff --git a/test/e2e/storage/utils/utils.go b/test/e2e/storage/utils/utils.go index dcabf7a4561..bc7ca07c67a 100644 --- a/test/e2e/storage/utils/utils.go +++ b/test/e2e/storage/utils/utils.go @@ -644,7 +644,7 @@ func genBinDataFromSeed(len int, seed int64) []byte { binData := make([]byte, len) rand.Seed(seed) - len, err := rand.Read(binData) + _, err := rand.Read(binData) if err != nil { fmt.Printf("Error: %v\n", err) } diff --git a/test/e2e/storage/vsphere/pv_reclaimpolicy.go b/test/e2e/storage/vsphere/pv_reclaimpolicy.go index b89c32bac20..a63a48973ee 100644 --- a/test/e2e/storage/vsphere/pv_reclaimpolicy.go +++ b/test/e2e/storage/vsphere/pv_reclaimpolicy.go @@ -245,7 +245,7 @@ func deletePVCAfterBind(c clientset.Interface, ns string, pvc *v1.PersistentVolu ginkgo.By("delete pvc") framework.ExpectNoError(e2epv.DeletePersistentVolumeClaim(c, pvc.Name, ns), "Failed to delete PVC ", pvc.Name) - pvc, err = c.CoreV1().PersistentVolumeClaims(ns).Get(pvc.Name, metav1.GetOptions{}) + _, err = c.CoreV1().PersistentVolumeClaims(ns).Get(pvc.Name, metav1.GetOptions{}) if !apierrs.IsNotFound(err) { framework.ExpectNoError(err) } diff --git a/test/e2e/storage/vsphere/vsphere_scale.go b/test/e2e/storage/vsphere/vsphere_scale.go index 79d0c31065d..0cea1e348ae 100644 --- a/test/e2e/storage/vsphere/vsphere_scale.go +++ b/test/e2e/storage/vsphere/vsphere_scale.go @@ -157,6 +157,7 @@ var _ = utils.SIGDescribe("vcp at scale [Feature:vsphere] ", func() { } } podList, err := client.CoreV1().Pods(namespace).List(metav1.ListOptions{}) + framework.ExpectNoError(err, "Failed to list pods") for _, pod := range podList.Items { pvcClaimList = append(pvcClaimList, getClaimsForPod(&pod, volumesPerPod)...) ginkgo.By("Deleting pod") diff --git a/test/e2e/storage/vsphere/vsphere_volume_datastore.go b/test/e2e/storage/vsphere/vsphere_volume_datastore.go index 4b0ad53917c..9d941192ba0 100644 --- a/test/e2e/storage/vsphere/vsphere_volume_datastore.go +++ b/test/e2e/storage/vsphere/vsphere_volume_datastore.go @@ -92,5 +92,6 @@ func invokeInvalidDatastoreTestNeg(client clientset.Interface, namespace string, framework.ExpectError(err) eventList, err := client.CoreV1().Events(pvclaim.Namespace).List(metav1.ListOptions{}) + framework.ExpectNoError(err) return fmt.Errorf("Failure message: %+q", eventList.Items[0].Message) } diff --git a/test/e2e/storage/vsphere/vsphere_volume_fstype.go b/test/e2e/storage/vsphere/vsphere_volume_fstype.go index e49670637c0..14d539f1050 100644 --- a/test/e2e/storage/vsphere/vsphere_volume_fstype.go +++ b/test/e2e/storage/vsphere/vsphere_volume_fstype.go @@ -130,6 +130,7 @@ func invokeTestForInvalidFstype(f *framework.Framework, client clientset.Interfa framework.ExpectError(err) eventList, err := client.CoreV1().Events(namespace).List(metav1.ListOptions{}) + framework.ExpectNoError(err) // Detach and delete volume detachVolume(f, client, pod, persistentvolumes[0].Spec.VsphereVolume.VolumePath) diff --git a/test/e2e/storage/vsphere/vsphere_volume_vsan_policy.go b/test/e2e/storage/vsphere/vsphere_volume_vsan_policy.go index fd65df42fb8..48ac5c8f931 100644 --- a/test/e2e/storage/vsphere/vsphere_volume_vsan_policy.go +++ b/test/e2e/storage/vsphere/vsphere_volume_vsan_policy.go @@ -321,6 +321,7 @@ func invokeInvalidPolicyTestNeg(client clientset.Interface, namespace string, sc framework.ExpectError(err) eventList, err := client.CoreV1().Events(pvclaim.Namespace).List(metav1.ListOptions{}) + framework.ExpectNoError(err) return fmt.Errorf("Failure message: %+q", eventList.Items[0].Message) } diff --git a/test/e2e/storage/vsphere/vsphere_zone_support.go b/test/e2e/storage/vsphere/vsphere_zone_support.go index 9adf6e386fb..a290649f298 100644 --- a/test/e2e/storage/vsphere/vsphere_zone_support.go +++ b/test/e2e/storage/vsphere/vsphere_zone_support.go @@ -439,6 +439,8 @@ func verifyPodAndPvcCreationFailureOnWaitForFirstConsumerMode(client clientset.I framework.ExpectError(err) eventList, err := client.CoreV1().Events(pvclaim.Namespace).List(metav1.ListOptions{}) + framework.ExpectNoError(err) + // Look for PVC ProvisioningFailed event and return the message. for _, event := range eventList.Items { if event.Source.Component == "persistentvolume-controller" && event.Reason == volumeevents.ProvisioningFailed { @@ -484,14 +486,13 @@ func verifyPVCCreationFails(client clientset.Interface, namespace string, scPara framework.ExpectNoError(err) defer e2epv.DeletePersistentVolumeClaim(client, pvclaim.Name, namespace) - var pvclaims []*v1.PersistentVolumeClaim - pvclaims = append(pvclaims, pvclaim) - ginkgo.By("Waiting for claim to be in bound phase") err = e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, client, pvclaim.Namespace, pvclaim.Name, framework.Poll, 2*time.Minute) framework.ExpectError(err) eventList, err := client.CoreV1().Events(pvclaim.Namespace).List(metav1.ListOptions{}) + framework.ExpectNoError(err) + framework.Logf("Failure message : %+q", eventList.Items[0].Message) return fmt.Errorf("Failure message: %+q", eventList.Items[0].Message) }