e2e: address golangci-lint issues

addessed golangci-lint issues in
e2e folder.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2024-04-04 10:49:32 +02:00 committed by mergify[bot]
parent a0921a2706
commit 6961b103b8
14 changed files with 68 additions and 67 deletions

View File

@ -23,7 +23,7 @@ import (
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
) )
// #nosec because of the word `Secret` //nolint:gosec // secret for test
const ( const (
// ceph user names. // ceph user names.
keyringRBDProvisionerUsername = "cephcsi-rbd-provisioner" keyringRBDProvisionerUsername = "cephcsi-rbd-provisioner"
@ -110,7 +110,7 @@ func createCephUser(f *framework.Framework, user string, caps []string) (string,
} }
func deleteCephUser(f *framework.Framework, user string) error { func deleteCephUser(f *framework.Framework, user string) error {
cmd := fmt.Sprintf("ceph auth del client.%s", user) cmd := "ceph auth del client." + user
_, _, err := execCommandInToolBoxPod(f, cmd, rookNamespace) _, _, err := execCommandInToolBoxPod(f, cmd, rookNamespace)
return err return err

View File

@ -23,7 +23,7 @@ import (
"sync" "sync"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
. "github.com/onsi/ginkgo/v2" //nolint:golint // e2e uses By() and other Ginkgo functions . "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -735,7 +735,7 @@ var _ = Describe(cephfsType, func() {
framework.Failf("failed to create PVC and Deployment: %v", err) framework.Failf("failed to create PVC and Deployment: %v", err)
} }
deplPods, err := listPods(f, depl.Namespace, &metav1.ListOptions{ deplPods, err := listPods(f, depl.Namespace, &metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", depl.Labels["app"]), LabelSelector: "app=" + depl.Labels["app"],
}) })
if err != nil { if err != nil {
framework.Failf("failed to list pods for Deployment: %v", err) framework.Failf("failed to list pods for Deployment: %v", err)
@ -744,7 +744,7 @@ var _ = Describe(cephfsType, func() {
doStat := func(podName string) (string, error) { doStat := func(podName string) (string, error) {
_, stdErr, execErr := execCommandInContainerByPodName( _, stdErr, execErr := execCommandInContainerByPodName(
f, f,
fmt.Sprintf("stat %s", depl.Spec.Template.Spec.Containers[0].VolumeMounts[0].MountPath), "stat "+depl.Spec.Template.Spec.Containers[0].VolumeMounts[0].MountPath,
depl.Namespace, depl.Namespace,
podName, podName,
depl.Spec.Template.Spec.Containers[0].Name, depl.Spec.Template.Spec.Containers[0].Name,
@ -808,7 +808,7 @@ var _ = Describe(cephfsType, func() {
} }
// List Deployment's pods again to get name of the new pod. // List Deployment's pods again to get name of the new pod.
deplPods, err = listPods(f, depl.Namespace, &metav1.ListOptions{ deplPods, err = listPods(f, depl.Namespace, &metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", depl.Labels["app"]), LabelSelector: "app=" + depl.Labels["app"],
}) })
if err != nil { if err != nil {
framework.Failf("failed to list pods for Deployment: %v", err) framework.Failf("failed to list pods for Deployment: %v", err)
@ -1074,13 +1074,13 @@ var _ = Describe(cephfsType, func() {
} }
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name), LabelSelector: "app=" + app.Name,
} }
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail( _, stdErr := execCommandInPodAndAllowFail(
f, f,
fmt.Sprintf("echo 'Hello World' > %s", filePath), "echo 'Hello World' >"+filePath,
app.Namespace, app.Namespace,
&opt) &opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
@ -2407,13 +2407,13 @@ var _ = Describe(cephfsType, func() {
} }
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name), LabelSelector: "app=" + app.Name,
} }
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail( _, stdErr := execCommandInPodAndAllowFail(
f, f,
fmt.Sprintf("echo 'Hello World' > %s", filePath), "echo 'Hello World' > "+filePath,
app.Namespace, app.Namespace,
&opt) &opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)

View File

@ -338,7 +338,7 @@ func getSnapName(snapNamespace, snapName string) (string, error) {
} }
snapIDRegex := regexp.MustCompile(`(\w+\-?){5}$`) snapIDRegex := regexp.MustCompile(`(\w+\-?){5}$`)
snapID := snapIDRegex.FindString(*sc.Status.SnapshotHandle) snapID := snapIDRegex.FindString(*sc.Status.SnapshotHandle)
snapshotName := fmt.Sprintf("csi-snap-%s", snapID) snapshotName := "csi-snap-" + snapID
framework.Logf("snapshotName= %s", snapshotName) framework.Logf("snapshotName= %s", snapshotName)
return snapshotName, nil return snapshotName, nil
@ -392,10 +392,10 @@ func validateEncryptedCephfs(f *framework.Framework, pvName, appName string) err
LabelSelector: selector, LabelSelector: selector,
} }
cmd := fmt.Sprintf("getfattr --name=ceph.fscrypt.auth --only-values %s", volumeMountPath) cmd := "getfattr --name=ceph.fscrypt.auth --only-values " + volumeMountPath
_, _, err = execCommandInContainer(f, cmd, cephCSINamespace, "csi-cephfsplugin", &opt) _, _, err = execCommandInContainer(f, cmd, cephCSINamespace, "csi-cephfsplugin", &opt)
if err != nil { if err != nil {
cmd = fmt.Sprintf("getfattr --recursive --dump %s", volumeMountPath) cmd = "getfattr --recursive --dump " + volumeMountPath
stdOut, stdErr, listErr := execCommandInContainer(f, cmd, cephCSINamespace, "csi-cephfsplugin", &opt) stdOut, stdErr, listErr := execCommandInContainer(f, cmd, cephCSINamespace, "csi-cephfsplugin", &opt)
if listErr == nil { if listErr == nil {
return fmt.Errorf("error checking for cephfs fscrypt xattr on %q. listing: %s %s", return fmt.Errorf("error checking for cephfs fscrypt xattr on %q. listing: %s %s",

View File

@ -21,7 +21,7 @@ import (
"fmt" "fmt"
"strings" "strings"
. "github.com/onsi/gomega" //nolint:golint // e2e uses Expect() and other Gomega functions . "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"

View File

@ -95,8 +95,8 @@ func replaceNamespaceInTemplate(filePath string) (string, error) {
} }
// template can contain "default" as namespace, with or without ". // template can contain "default" as namespace, with or without ".
templ := strings.ReplaceAll(string(read), "namespace: default", fmt.Sprintf("namespace: %s", cephCSINamespace)) templ := strings.ReplaceAll(string(read), "namespace: default", "namespace: "+cephCSINamespace)
templ = strings.ReplaceAll(templ, "namespace: \"default\"", fmt.Sprintf("namespace: %s", cephCSINamespace)) templ = strings.ReplaceAll(templ, "namespace: \"default\"", "namespace: "+cephCSINamespace)
return templ, nil return templ, nil
} }

View File

@ -24,7 +24,7 @@ import (
"time" "time"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
. "github.com/onsi/ginkgo/v2" //nolint:golint // e2e uses By() and other Ginkgo functions . "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors" apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -603,13 +603,13 @@ var _ = Describe("nfs", func() {
} }
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name), LabelSelector: "app=" + app.Name,
} }
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail( _, stdErr := execCommandInPodAndAllowFail(
f, f,
fmt.Sprintf("echo 'Hello World' > %s", filePath), "echo 'Hello World' > "+filePath,
app.Namespace, app.Namespace,
&opt) &opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)

View File

@ -382,7 +382,7 @@ func waitForPodInRunningState(name, ns string, c kubernetes.Interface, t int, ex
case v1.PodPending: case v1.PodPending:
if expectedError != "" { if expectedError != "" {
events, err := c.CoreV1().Events(ns).List(ctx, metav1.ListOptions{ events, err := c.CoreV1().Events(ns).List(ctx, metav1.ListOptions{
FieldSelector: fmt.Sprintf("involvedObject.name=%s", name), FieldSelector: "involvedObject.name=" + name,
}) })
if err != nil { if err != nil {
return false, err return false, err
@ -452,7 +452,7 @@ func deletePodWithLabel(label, ns string, skipNotFound bool) error {
// calculateSHA512sum returns the sha512sum of a file inside a pod. // calculateSHA512sum returns the sha512sum of a file inside a pod.
func calculateSHA512sum(f *framework.Framework, app *v1.Pod, filePath string, opt *metav1.ListOptions) (string, error) { func calculateSHA512sum(f *framework.Framework, app *v1.Pod, filePath string, opt *metav1.ListOptions) (string, error) {
cmd := fmt.Sprintf("sha512sum %s", filePath) cmd := "sha512sum " + filePath
sha512sumOut, stdErr, err := execCommandInPod(f, cmd, app.Namespace, opt) sha512sumOut, stdErr, err := execCommandInPod(f, cmd, app.Namespace, opt)
if err != nil { if err != nil {
return "", err return "", err

View File

@ -19,12 +19,13 @@ package e2e
import ( import (
"context" "context"
"fmt" "fmt"
"strconv"
"strings" "strings"
"time" "time"
"github.com/ceph/ceph-csi/internal/util" "github.com/ceph/ceph-csi/internal/util"
. "github.com/onsi/ginkgo/v2" //nolint:golint // e2e uses By() and other Ginkgo functions . "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
@ -536,7 +537,7 @@ var _ = Describe("RBD", func() {
}) })
By("reattach the old PV to a new PVC and check if PVC metadata is updated on RBD image", func() { By("reattach the old PV to a new PVC and check if PVC metadata is updated on RBD image", func() {
reattachPVCNamespace := fmt.Sprintf("%s-2", f.Namespace.Name) reattachPVCNamespace := f.Namespace.Name + "-2"
pvc, err := loadPVC(pvcPath) pvc, err := loadPVC(pvcPath)
if err != nil { if err != nil {
framework.Failf("failed to load PVC: %v", err) framework.Failf("failed to load PVC: %v", err)
@ -1512,7 +1513,7 @@ var _ = Describe("RBD", func() {
cmd := fmt.Sprintf("dd if=/dev/zero of=%s bs=1M count=10", devPath) cmd := fmt.Sprintf("dd if=/dev/zero of=%s bs=1M count=10", devPath)
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name), LabelSelector: "app=" + app.Name,
} }
podList, err := e2epod.PodClientNS(f, app.Namespace).List(context.TODO(), opt) podList, err := e2epod.PodClientNS(f, app.Namespace).List(context.TODO(), opt)
if err != nil { if err != nil {
@ -1630,10 +1631,10 @@ var _ = Describe("RBD", func() {
validateOmapCount(f, 2, rbdType, defaultRBDPool, volumesType) validateOmapCount(f, 2, rbdType, defaultRBDPool, volumesType)
filePath := appClone.Spec.Template.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" filePath := appClone.Spec.Template.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
cmd := fmt.Sprintf("echo 'Hello World' > %s", filePath) cmd := "echo 'Hello World' > " + filePath
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", appClone.Name), LabelSelector: "app=" + appClone.Name,
} }
podList, err := e2epod.PodClientNS(f, appClone.Namespace).List(context.TODO(), opt) podList, err := e2epod.PodClientNS(f, appClone.Namespace).List(context.TODO(), opt)
if err != nil { if err != nil {
@ -1766,7 +1767,7 @@ var _ = Describe("RBD", func() {
cmd := fmt.Sprintf("dd if=/dev/zero of=%s bs=1M count=10", devPath) cmd := fmt.Sprintf("dd if=/dev/zero of=%s bs=1M count=10", devPath)
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", appClone.Name), LabelSelector: "app=" + appClone.Name,
} }
podList, err := e2epod.PodClientNS(f, appClone.Namespace).List(context.TODO(), opt) podList, err := e2epod.PodClientNS(f, appClone.Namespace).List(context.TODO(), opt)
if err != nil { if err != nil {
@ -1862,14 +1863,14 @@ var _ = Describe("RBD", func() {
} }
appOpt := metav1.ListOptions{ appOpt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name), LabelSelector: "app=" + app.Name,
} }
// TODO: Remove this once we ensure that rbd-nbd can sync data // TODO: Remove this once we ensure that rbd-nbd can sync data
// from Filesystem layer to backend rbd image as part of its // from Filesystem layer to backend rbd image as part of its
// detach or SIGTERM signal handler // detach or SIGTERM signal handler
_, stdErr, err := execCommandInPod( _, stdErr, err := execCommandInPod(
f, f,
fmt.Sprintf("sync %s", app.Spec.Containers[0].VolumeMounts[0].MountPath), "sync "+app.Spec.Containers[0].VolumeMounts[0].MountPath,
app.Namespace, app.Namespace,
&appOpt) &appOpt)
if err != nil || stdErr != "" { if err != nil || stdErr != "" {
@ -1956,7 +1957,7 @@ var _ = Describe("RBD", func() {
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr, err = execCommandInPod( _, stdErr, err = execCommandInPod(
f, f,
fmt.Sprintf("echo 'Hello World' > %s", filePath), "echo 'Hello World' > "+filePath,
app.Namespace, app.Namespace,
&appOpt) &appOpt)
if err != nil || stdErr != "" { if err != nil || stdErr != "" {
@ -3331,13 +3332,13 @@ var _ = Describe("RBD", func() {
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
name := fmt.Sprintf("%s%d", f.UniqueName, i) name := fmt.Sprintf("%s%d", f.UniqueName, i)
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", name), LabelSelector: "app=" + name,
} }
filePath := appClone.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" filePath := appClone.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail( _, stdErr := execCommandInPodAndAllowFail(
f, f,
fmt.Sprintf("echo 'Hello World' > %s", filePath), "echo 'Hello World' > "+filePath,
appClone.Namespace, appClone.Namespace,
&opt) &opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
@ -3961,13 +3962,13 @@ var _ = Describe("RBD", func() {
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType) validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name), LabelSelector: "app=" + app.Name,
} }
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail( _, stdErr := execCommandInPodAndAllowFail(
f, f,
fmt.Sprintf("echo 'Hello World' > %s", filePath), "echo 'Hello World' > "+filePath,
app.Namespace, app.Namespace,
&opt) &opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
@ -4350,9 +4351,9 @@ var _ = Describe("RBD", func() {
defaultSCName, defaultSCName,
nil, nil,
map[string]string{ map[string]string{
"stripeUnit": fmt.Sprintf("%d", stripeUnit), "stripeUnit": strconv.Itoa(stripeUnit),
"stripeCount": fmt.Sprintf("%d", stripeCount), "stripeCount": strconv.Itoa(stripeCount),
"objectSize": fmt.Sprintf("%d", objectSize), "objectSize": strconv.Itoa(objectSize),
}, },
deletePolicy) deletePolicy)
if err != nil { if err != nil {

View File

@ -118,7 +118,7 @@ func createRBDStorageClass(
scOptions, parameters map[string]string, scOptions, parameters map[string]string,
policy v1.PersistentVolumeReclaimPolicy, policy v1.PersistentVolumeReclaimPolicy,
) error { ) error {
scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "storageclass.yaml") scPath := rbdExamplePath + "/" + "storageclass.yaml"
sc, err := getStorageClass(scPath) sc, err := getStorageClass(scPath)
if err != nil { if err != nil {
return fmt.Errorf("failed to get sc: %w", err) return fmt.Errorf("failed to get sc: %w", err)
@ -184,7 +184,7 @@ func createRBDStorageClass(
func createRadosNamespace(f *framework.Framework) error { func createRadosNamespace(f *framework.Framework) error {
stdOut, stdErr, err := execCommandInToolBoxPod(f, stdOut, stdErr, err := execCommandInToolBoxPod(f,
fmt.Sprintf("rbd namespace ls --pool=%s", defaultRBDPool), rookNamespace) "rbd namespace ls --pool="+defaultRBDPool, rookNamespace)
if err != nil { if err != nil {
return err return err
} }
@ -193,7 +193,7 @@ func createRadosNamespace(f *framework.Framework) error {
} }
if !strings.Contains(stdOut, radosNamespace) { if !strings.Contains(stdOut, radosNamespace) {
_, stdErr, err = execCommandInToolBoxPod(f, _, stdErr, err = execCommandInToolBoxPod(f,
fmt.Sprintf("rbd namespace create %s", rbdOptions(defaultRBDPool)), rookNamespace) "rbd namespace create "+rbdOptions(defaultRBDPool), rookNamespace)
if err != nil { if err != nil {
return err return err
} }
@ -202,7 +202,7 @@ func createRadosNamespace(f *framework.Framework) error {
} }
} }
stdOut, stdErr, err = execCommandInToolBoxPod(f, stdOut, stdErr, err = execCommandInToolBoxPod(f,
fmt.Sprintf("rbd namespace ls --pool=%s", rbdTopologyPool), rookNamespace) "rbd namespace ls --pool="+rbdTopologyPool, rookNamespace)
if err != nil { if err != nil {
return err return err
} }
@ -212,7 +212,7 @@ func createRadosNamespace(f *framework.Framework) error {
if !strings.Contains(stdOut, radosNamespace) { if !strings.Contains(stdOut, radosNamespace) {
_, stdErr, err = execCommandInToolBoxPod(f, _, stdErr, err = execCommandInToolBoxPod(f,
fmt.Sprintf("rbd namespace create %s", rbdOptions(rbdTopologyPool)), rookNamespace) "rbd namespace create "+rbdOptions(rbdTopologyPool), rookNamespace)
if err != nil { if err != nil {
return err return err
} }
@ -269,7 +269,7 @@ func getImageInfoFromPVC(pvcNamespace, pvcName string, f *framework.Framework) (
imageData = imageInfoFromPVC{ imageData = imageInfoFromPVC{
imageID: imageID, imageID: imageID,
imageName: fmt.Sprintf("csi-vol-%s", imageID), imageName: "csi-vol-" + imageID,
csiVolumeHandle: pv.Spec.CSI.VolumeHandle, csiVolumeHandle: pv.Spec.CSI.VolumeHandle,
pvName: pv.Name, pvName: pv.Name,
} }
@ -671,7 +671,7 @@ func validateEncryptedFilesystem(f *framework.Framework, rbdImageSpec, pvName, a
cmd := fmt.Sprintf("lsattr -la %s | grep -E '%s/.\\s+Encrypted'", volumeMountPath, volumeMountPath) cmd := fmt.Sprintf("lsattr -la %s | grep -E '%s/.\\s+Encrypted'", volumeMountPath, volumeMountPath)
_, _, err = execCommandInContainer(f, cmd, cephCSINamespace, "csi-rbdplugin", &opt) _, _, err = execCommandInContainer(f, cmd, cephCSINamespace, "csi-rbdplugin", &opt)
if err != nil { if err != nil {
cmd = fmt.Sprintf("lsattr -lRa %s", volumeMountPath) cmd = "lsattr -lRa " + volumeMountPath
stdOut, stdErr, listErr := execCommandInContainer(f, cmd, cephCSINamespace, "csi-rbdplugin", &opt) stdOut, stdErr, listErr := execCommandInContainer(f, cmd, cephCSINamespace, "csi-rbdplugin", &opt)
if listErr == nil { if listErr == nil {
return fmt.Errorf("error checking file encrypted attribute of %q. listing filesystem+attrs: %s %s", return fmt.Errorf("error checking file encrypted attribute of %q. listing filesystem+attrs: %s %s",
@ -697,7 +697,7 @@ func listRBDImages(f *framework.Framework, pool string) ([]string, error) {
var imgInfos []string var imgInfos []string
stdout, stdErr, err := execCommandInToolBoxPod(f, stdout, stdErr, err := execCommandInToolBoxPod(f,
fmt.Sprintf("rbd ls --format=json %s", rbdOptions(pool)), rookNamespace) "rbd ls --format=json "+rbdOptions(pool), rookNamespace)
if err != nil { if err != nil {
return imgInfos, err return imgInfos, err
} }
@ -744,7 +744,7 @@ type rbdDuImageList struct {
// getRbdDu runs 'rbd du' on the RBD image and returns a rbdDuImage struct with // getRbdDu runs 'rbd du' on the RBD image and returns a rbdDuImage struct with
// the result. // the result.
// //
//nolint:deadcode,unused // required for reclaimspace e2e. //nolint:unused // Unused code will be used in future.
func getRbdDu(f *framework.Framework, pvc *v1.PersistentVolumeClaim) (*rbdDuImage, error) { func getRbdDu(f *framework.Framework, pvc *v1.PersistentVolumeClaim) (*rbdDuImage, error) {
rdil := rbdDuImageList{} rdil := rbdDuImageList{}
@ -778,7 +778,7 @@ func getRbdDu(f *framework.Framework, pvc *v1.PersistentVolumeClaim) (*rbdDuImag
// take up any space anymore. This can be used to verify that an empty, but // take up any space anymore. This can be used to verify that an empty, but
// allocated (with zerofill) extents have been released. // allocated (with zerofill) extents have been released.
// //
//nolint:deadcode,unused // required for reclaimspace e2e. //nolint:unused // Unused code will be used in future.
func sparsifyBackingRBDImage(f *framework.Framework, pvc *v1.PersistentVolumeClaim) error { func sparsifyBackingRBDImage(f *framework.Framework, pvc *v1.PersistentVolumeClaim) error {
imageData, err := getImageInfoFromPVC(pvc.Namespace, pvc.Name, f) imageData, err := getImageInfoFromPVC(pvc.Namespace, pvc.Name, f)
if err != nil { if err != nil {
@ -802,7 +802,7 @@ func deletePool(name string, cephFS bool, f *framework.Framework) error {
// --yes-i-really-mean-it // --yes-i-really-mean-it
// ceph osd pool delete myfs-replicated myfs-replicated // ceph osd pool delete myfs-replicated myfs-replicated
// --yes-i-really-mean-it // --yes-i-really-mean-it
cmds = append(cmds, fmt.Sprintf("ceph fs fail %s", name), cmds = append(cmds, "ceph fs fail "+name,
fmt.Sprintf("ceph fs rm %s --yes-i-really-mean-it", name), fmt.Sprintf("ceph fs rm %s --yes-i-really-mean-it", name),
fmt.Sprintf("ceph osd pool delete %s-metadata %s-metadata --yes-i-really-really-mean-it", name, name), fmt.Sprintf("ceph osd pool delete %s-metadata %s-metadata --yes-i-really-really-mean-it", name, name),
fmt.Sprintf("ceph osd pool delete %s-replicated %s-replicated --yes-i-really-really-mean-it", name, name)) fmt.Sprintf("ceph osd pool delete %s-replicated %s-replicated --yes-i-really-really-mean-it", name, name))
@ -850,7 +850,7 @@ func getPVCImageInfoInPool(f *framework.Framework, pvc *v1.PersistentVolumeClaim
} }
stdOut, stdErr, err := execCommandInToolBoxPod(f, stdOut, stdErr, err := execCommandInToolBoxPod(f,
fmt.Sprintf("rbd info %s", imageSpec(pool, imageData.imageName)), rookNamespace) "rbd info "+imageSpec(pool, imageData.imageName), rookNamespace)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -1021,7 +1021,7 @@ func listRBDImagesInTrash(f *framework.Framework, poolName string) ([]trashInfo,
var trashInfos []trashInfo var trashInfos []trashInfo
stdout, stdErr, err := execCommandInToolBoxPod(f, stdout, stdErr, err := execCommandInToolBoxPod(f,
fmt.Sprintf("rbd trash ls --format=json %s", rbdOptions(poolName)), rookNamespace) "rbd trash ls --format=json "+rbdOptions(poolName), rookNamespace)
if err != nil { if err != nil {
return trashInfos, err return trashInfos, err
} }

View File

@ -22,7 +22,7 @@ import (
"strings" "strings"
"time" "time"
. "github.com/onsi/gomega" //nolint:golint // e2e uses Expect() and other Gomega functions . "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -179,7 +179,7 @@ func getDirSizeCheckCmd(dirPath string) string {
} }
func getDeviceSizeCheckCmd(devPath string) string { func getDeviceSizeCheckCmd(devPath string) string {
return fmt.Sprintf("blockdev --getsize64 %s", devPath) return "blockdev --getsize64 " + devPath
} }
func checkAppMntSize(f *framework.Framework, opt *metav1.ListOptions, size, cmd, ns string, t int) error { func checkAppMntSize(f *framework.Framework, opt *metav1.ListOptions, size, cmd, ns string, t int) error {

View File

@ -23,7 +23,7 @@ import (
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1" snapapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
snapclient "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1" snapclient "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned/typed/volumesnapshot/v1"
. "github.com/onsi/gomega" //nolint:golint // e2e uses Expect() and other Gomega functions . "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors" apierrs "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"

View File

@ -23,7 +23,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
. "github.com/onsi/ginkgo/v2" //nolint:golint // e2e uses By() and other Ginkgo functions . "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -234,7 +234,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
} }
// force an immediate write of all cached data to disk. // force an immediate write of all cached data to disk.
_, stdErr = execCommandInPodAndAllowFail(f, fmt.Sprintf("sync %s", filePath), app.Namespace, &opt) _, stdErr = execCommandInPodAndAllowFail(f, "sync "+filePath, app.Namespace, &opt)
if stdErr != "" { if stdErr != "" {
framework.Failf("failed to sync data to a disk %s", stdErr) framework.Failf("failed to sync data to a disk %s", stdErr)
} }

View File

@ -23,7 +23,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
. "github.com/onsi/ginkgo/v2" //nolint:golint // e2e uses By() and other Ginkgo functions . "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -239,13 +239,13 @@ var _ = Describe("RBD Upgrade Testing", func() {
} }
// force an immediate write of all cached data to disk. // force an immediate write of all cached data to disk.
_, stdErr = execCommandInPodAndAllowFail(f, fmt.Sprintf("sync %s", filePath), app.Namespace, &opt) _, stdErr = execCommandInPodAndAllowFail(f, "sync "+filePath, app.Namespace, &opt)
if stdErr != "" { if stdErr != "" {
framework.Failf("failed to sync data to a disk %s", stdErr) framework.Failf("failed to sync data to a disk %s", stdErr)
} }
opt = metav1.ListOptions{ opt = metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", appLabel), LabelSelector: "app=" + appLabel,
} }
framework.Logf("Calculating checksum of %s", filePath) framework.Logf("Calculating checksum of %s", filePath)
checkSum, err = calculateSHA512sum(f, app, filePath, &opt) checkSum, err = calculateSHA512sum(f, app, filePath, &opt)

View File

@ -183,9 +183,9 @@ func validateOmapCount(f *framework.Framework, count int, driver, pool, mode str
{ {
volumeMode: volumesType, volumeMode: volumesType,
driverType: rbdType, driverType: rbdType,
radosLsCmd: fmt.Sprintf("rados ls %s", rbdOptions(pool)), radosLsCmd: "rados ls " + rbdOptions(pool),
radosLsCmdFilter: fmt.Sprintf("rados ls %s | grep -v default | grep -c ^csi.volume.", rbdOptions(pool)), radosLsCmdFilter: fmt.Sprintf("rados ls %s | grep -v default | grep -c ^csi.volume.", rbdOptions(pool)),
radosLsKeysCmd: fmt.Sprintf("rados listomapkeys csi.volumes.default %s", rbdOptions(pool)), radosLsKeysCmd: "rados listomapkeys csi.volumes.default " + rbdOptions(pool),
radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.volumes.default %s | wc -l", rbdOptions(pool)), radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.volumes.default %s | wc -l", rbdOptions(pool)),
}, },
{ {
@ -201,9 +201,9 @@ func validateOmapCount(f *framework.Framework, count int, driver, pool, mode str
{ {
volumeMode: snapsType, volumeMode: snapsType,
driverType: rbdType, driverType: rbdType,
radosLsCmd: fmt.Sprintf("rados ls %s", rbdOptions(pool)), radosLsCmd: "rados ls " + rbdOptions(pool),
radosLsCmdFilter: fmt.Sprintf("rados ls %s | grep -v default | grep -c ^csi.snap.", rbdOptions(pool)), radosLsCmdFilter: fmt.Sprintf("rados ls %s | grep -v default | grep -c ^csi.snap.", rbdOptions(pool)),
radosLsKeysCmd: fmt.Sprintf("rados listomapkeys csi.snaps.default %s", rbdOptions(pool)), radosLsKeysCmd: "rados listomapkeys csi.snaps.default " + rbdOptions(pool),
radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.snaps.default %s | wc -l", rbdOptions(pool)), radosLsKeysCmdFilter: fmt.Sprintf("rados listomapkeys csi.snaps.default %s | wc -l", rbdOptions(pool)),
}, },
} }
@ -716,7 +716,7 @@ func checkDataPersist(pvcPath, appPath string, f *framework.Framework) error {
if err != nil { if err != nil {
return err return err
} }
persistData, stdErr, err := execCommandInPod(f, fmt.Sprintf("cat %s", filePath), app.Namespace, &opt) persistData, stdErr, err := execCommandInPod(f, "cat "+filePath, app.Namespace, &opt)
if err != nil { if err != nil {
return err return err
} }
@ -793,7 +793,7 @@ func checkMountOptions(pvcPath, appPath string, f *framework.Framework, mountFla
LabelSelector: "app=validate-mount-opt", LabelSelector: "app=validate-mount-opt",
} }
cmd := fmt.Sprintf("mount |grep %s", app.Spec.Containers[0].VolumeMounts[0].MountPath) cmd := "mount |grep " + app.Spec.Containers[0].VolumeMounts[0].MountPath
data, stdErr, err := execCommandInPod(f, cmd, app.Namespace, &opt) data, stdErr, err := execCommandInPod(f, cmd, app.Namespace, &opt)
if err != nil { if err != nil {
return err return err
@ -1545,7 +1545,7 @@ func validateController(
// If fetching the ServerVersion of the Kubernetes cluster fails, the calling // If fetching the ServerVersion of the Kubernetes cluster fails, the calling
// test case is marked as `FAILED` and gets aborted. // test case is marked as `FAILED` and gets aborted.
// //
//nolint:deadcode,unused // Unused code will be used in future. //nolint:unused // Unused code will be used in future.
func k8sVersionGreaterEquals(c kubernetes.Interface, major, minor int) bool { func k8sVersionGreaterEquals(c kubernetes.Interface, major, minor int) bool {
v, err := c.Discovery().ServerVersion() v, err := c.Discovery().ServerVersion()
if err != nil { if err != nil {
@ -1555,8 +1555,8 @@ func k8sVersionGreaterEquals(c kubernetes.Interface, major, minor int) bool {
// return value. // return value.
} }
maj := fmt.Sprintf("%d", major) maj := strconv.Itoa(major)
min := fmt.Sprintf("%d", minor) min := strconv.Itoa(minor)
return (v.Major > maj) || (v.Major == maj && v.Minor >= min) return (v.Major > maj) || (v.Major == maj && v.Minor >= min)
} }