Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Update golangci lint and helm version #4539

Merged
merged 15 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ rules:
- - build
- cephfs
- ci
- csi-addons
- cleanup
- deploy
- doc
Expand Down
4 changes: 2 additions & 2 deletions build.env
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GO111MODULE=on
COMMITLINT_VERSION=latest

# static checks and linters
GOLANGCI_VERSION=v1.54.1
GOLANGCI_VERSION=v1.57.2

# external snapshotter version
# Refer: https://github.com/kubernetes-csi/external-snapshotter/releases
Expand All @@ -41,7 +41,7 @@ SNAPSHOT_VERSION=v7.0.1
HELM_SCRIPT=https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3

# helm chart generation, testing and publishing
HELM_VERSION=v3.14.1
HELM_VERSION=v3.14.3

# minikube settings
MINIKUBE_VERSION=v1.32.0
Expand Down
4 changes: 2 additions & 2 deletions e2e/ceph_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
)

// #nosec because of the word `Secret`
//nolint:gosec // secret for test
const (
// ceph user names.
keyringRBDProvisionerUsername = "cephcsi-rbd-provisioner"
Expand Down Expand Up @@ -110,7 +110,7 @@ func createCephUser(f *framework.Framework, user string, caps []string) (string,
}

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)

return err
Expand Down
16 changes: 8 additions & 8 deletions e2e/cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"sync"

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"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -735,7 +735,7 @@ var _ = Describe(cephfsType, func() {
framework.Failf("failed to create PVC and Deployment: %v", err)
}
deplPods, err := listPods(f, depl.Namespace, &metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", depl.Labels["app"]),
LabelSelector: "app=" + depl.Labels["app"],
})
if err != nil {
framework.Failf("failed to list pods for Deployment: %v", err)
Expand All @@ -744,7 +744,7 @@ var _ = Describe(cephfsType, func() {
doStat := func(podName string) (string, error) {
_, stdErr, execErr := execCommandInContainerByPodName(
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,
podName,
depl.Spec.Template.Spec.Containers[0].Name,
Expand Down Expand Up @@ -808,7 +808,7 @@ var _ = Describe(cephfsType, func() {
}
// List Deployment's pods again to get name of the new pod.
deplPods, err = listPods(f, depl.Namespace, &metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", depl.Labels["app"]),
LabelSelector: "app=" + depl.Labels["app"],
})
if err != nil {
framework.Failf("failed to list pods for Deployment: %v", err)
Expand Down Expand Up @@ -1074,13 +1074,13 @@ var _ = Describe(cephfsType, func() {
}

opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name),
LabelSelector: "app=" + app.Name,
}

filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail(
f,
fmt.Sprintf("echo 'Hello World' > %s", filePath),
"echo 'Hello World' >"+filePath,
app.Namespace,
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
Expand Down Expand Up @@ -2407,13 +2407,13 @@ var _ = Describe(cephfsType, func() {
}

opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name),
LabelSelector: "app=" + app.Name,
}

filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail(
f,
fmt.Sprintf("echo 'Hello World' > %s", filePath),
"echo 'Hello World' > "+filePath,
app.Namespace,
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
Expand Down
6 changes: 3 additions & 3 deletions e2e/cephfs_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func getSnapName(snapNamespace, snapName string) (string, error) {
}
snapIDRegex := regexp.MustCompile(`(\w+\-?){5}$`)
snapID := snapIDRegex.FindString(*sc.Status.SnapshotHandle)
snapshotName := fmt.Sprintf("csi-snap-%s", snapID)
snapshotName := "csi-snap-" + snapID
framework.Logf("snapshotName= %s", snapshotName)

return snapshotName, nil
Expand Down Expand Up @@ -392,10 +392,10 @@ func validateEncryptedCephfs(f *framework.Framework, pvName, appName string) err
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)
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)
if listErr == nil {
return fmt.Errorf("error checking for cephfs fscrypt xattr on %q. listing: %s %s",
Expand Down
2 changes: 1 addition & 1 deletion e2e/deploy-vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"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"
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
Expand Down
4 changes: 2 additions & 2 deletions e2e/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func replaceNamespaceInTemplate(filePath string) (string, error) {
}

// template can contain "default" as namespace, with or without ".
templ := strings.ReplaceAll(string(read), "namespace: default", fmt.Sprintf("namespace: %s", cephCSINamespace))
templ = strings.ReplaceAll(templ, "namespace: \"default\"", fmt.Sprintf("namespace: %s", cephCSINamespace))
templ := strings.ReplaceAll(string(read), "namespace: default", "namespace: "+cephCSINamespace)
templ = strings.ReplaceAll(templ, "namespace: \"default\"", "namespace: "+cephCSINamespace)

return templ, nil
}
6 changes: 3 additions & 3 deletions e2e/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

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"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -603,13 +603,13 @@ var _ = Describe("nfs", func() {
}

opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name),
LabelSelector: "app=" + app.Name,
}

filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail(
f,
fmt.Sprintf("echo 'Hello World' > %s", filePath),
"echo 'Hello World' > "+filePath,
app.Namespace,
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
Expand Down
4 changes: 2 additions & 2 deletions e2e/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func waitForPodInRunningState(name, ns string, c kubernetes.Interface, t int, ex
case v1.PodPending:
if expectedError != "" {
events, err := c.CoreV1().Events(ns).List(ctx, metav1.ListOptions{
FieldSelector: fmt.Sprintf("involvedObject.name=%s", name),
FieldSelector: "involvedObject.name=" + name,
})
if err != nil {
return false, err
Expand Down Expand Up @@ -452,7 +452,7 @@ func deletePodWithLabel(label, ns string, skipNotFound bool) error {

// 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) {
cmd := fmt.Sprintf("sha512sum %s", filePath)
cmd := "sha512sum " + filePath
sha512sumOut, stdErr, err := execCommandInPod(f, cmd, app.Namespace, opt)
if err != nil {
return "", err
Expand Down
33 changes: 17 additions & 16 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ package e2e
import (
"context"
"fmt"
"strconv"
"strings"
"time"

"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"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -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() {
reattachPVCNamespace := fmt.Sprintf("%s-2", f.Namespace.Name)
reattachPVCNamespace := f.Namespace.Name + "-2"
pvc, err := loadPVC(pvcPath)
if err != nil {
framework.Failf("failed to load PVC: %v", err)
Expand Down Expand Up @@ -1512,7 +1513,7 @@ var _ = Describe("RBD", func() {
cmd := fmt.Sprintf("dd if=/dev/zero of=%s bs=1M count=10", devPath)

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)
if err != nil {
Expand Down Expand Up @@ -1630,10 +1631,10 @@ var _ = Describe("RBD", func() {
validateOmapCount(f, 2, rbdType, defaultRBDPool, volumesType)

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{
LabelSelector: fmt.Sprintf("app=%s", appClone.Name),
LabelSelector: "app=" + appClone.Name,
}
podList, err := e2epod.PodClientNS(f, appClone.Namespace).List(context.TODO(), opt)
if err != nil {
Expand Down Expand Up @@ -1766,7 +1767,7 @@ var _ = Describe("RBD", func() {
cmd := fmt.Sprintf("dd if=/dev/zero of=%s bs=1M count=10", devPath)

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)
if err != nil {
Expand Down Expand Up @@ -1862,14 +1863,14 @@ var _ = Describe("RBD", func() {
}

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
// from Filesystem layer to backend rbd image as part of its
// detach or SIGTERM signal handler
_, stdErr, err := execCommandInPod(
f,
fmt.Sprintf("sync %s", app.Spec.Containers[0].VolumeMounts[0].MountPath),
"sync "+app.Spec.Containers[0].VolumeMounts[0].MountPath,
app.Namespace,
&appOpt)
if err != nil || stdErr != "" {
Expand Down Expand Up @@ -1956,7 +1957,7 @@ var _ = Describe("RBD", func() {
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr, err = execCommandInPod(
f,
fmt.Sprintf("echo 'Hello World' > %s", filePath),
"echo 'Hello World' > "+filePath,
app.Namespace,
&appOpt)
if err != nil || stdErr != "" {
Expand Down Expand Up @@ -3331,13 +3332,13 @@ var _ = Describe("RBD", func() {
for i := 0; i < totalCount; i++ {
name := fmt.Sprintf("%s%d", f.UniqueName, i)
opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", name),
LabelSelector: "app=" + name,
}

filePath := appClone.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail(
f,
fmt.Sprintf("echo 'Hello World' > %s", filePath),
"echo 'Hello World' > "+filePath,
appClone.Namespace,
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
Expand Down Expand Up @@ -3961,13 +3962,13 @@ var _ = Describe("RBD", func() {
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)

opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name),
LabelSelector: "app=" + app.Name,
}

filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail(
f,
fmt.Sprintf("echo 'Hello World' > %s", filePath),
"echo 'Hello World' > "+filePath,
app.Namespace,
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
Expand Down Expand Up @@ -4350,9 +4351,9 @@ var _ = Describe("RBD", func() {
defaultSCName,
nil,
map[string]string{
"stripeUnit": fmt.Sprintf("%d", stripeUnit),
"stripeCount": fmt.Sprintf("%d", stripeCount),
"objectSize": fmt.Sprintf("%d", objectSize),
"stripeUnit": strconv.Itoa(stripeUnit),
"stripeCount": strconv.Itoa(stripeCount),
"objectSize": strconv.Itoa(objectSize),
},
deletePolicy)
if err != nil {
Expand Down
Loading