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

update golangci-lint #190

Merged
merged 4 commits into from
Feb 22, 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
2 changes: 1 addition & 1 deletion .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
cache: false
- name: Checkout the code
uses: actions/checkout@v4
Expand Down
9 changes: 4 additions & 5 deletions cmd/podmon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import (
"context"
"flag"
"fmt"
"podmon/internal/csiapi"
"podmon/internal/k8sapi"
"podmon/internal/monitor"
"strconv"
"strings"
"sync"
"time"

"podmon/internal/csiapi"
"podmon/internal/k8sapi"
"podmon/internal/monitor"

csiext "github.com/dell/dell-csi-extensions/podmon"
"github.com/fsnotify/fsnotify"
"github.com/kubernetes-csi/csi-lib-utils/leaderelection"
Expand Down Expand Up @@ -299,7 +298,7 @@ func setupDynamicConfigUpdate() error {
}

vc.WatchConfig()
vc.OnConfigChange(func(in fsnotify.Event) {
vc.OnConfigChange(func(_ fsnotify.Event) {
log.WithField("file", *args.driverConfigParamsFile).Infof("configuration file has changed")
if err := updateConfiguration(vc); err != nil {
log.Warn(err)
Expand Down
7 changes: 3 additions & 4 deletions cmd/podmon/main_steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ import (
"context"
"fmt"
"os"
"strings"
"sync"
"time"

"podmon/internal/csiapi"
"podmon/internal/k8sapi"
"podmon/internal/monitor"
"strings"
"sync"
"time"

"github.com/cucumber/godog"
"github.com/dell/gofsutil"
Expand Down
5 changes: 2 additions & 3 deletions internal/monitor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import (
"errors"
"fmt"
"os"
"podmon/internal/k8sapi"
"strings"
"sync"
"time"

"podmon/internal/k8sapi"

"github.com/container-storage-interface/spec/lib/go/csi"
csiext "github.com/dell/dell-csi-extensions/podmon"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -419,7 +418,7 @@ func (cm *PodMonitorType) ArrayConnectivityMonitor() {
connectivityCache.ResetSampled()
// Internal function for iterating PodKeyToControllerPodInfo
// This will clean up Pods that have lost connectivity to at least one of their arrays
fnPodKeyToControllerPodInfo := func(key, value interface{}) bool {
fnPodKeyToControllerPodInfo := func(_, value interface{}) bool {
controllerPodInfo := value.(*ControllerPodInfo)
podKey := controllerPodInfo.PodKey
node := controllerPodInfo.Node
Expand Down
63 changes: 31 additions & 32 deletions internal/monitor/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import (
"crypto/sha256"
"fmt"
"os"
"strings"

"podmon/internal/utils"
"strings"

log "github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -51,7 +50,7 @@ func (d *VxflexDriver) GetDriverName() string {
}

// GetDriverMountDir returns the Vxflex private mount directory.
func (d *VxflexDriver) GetDriverMountDir(volumeHandle, pvName, podUUID string) string {
func (d *VxflexDriver) GetDriverMountDir(volumeHandle, _, _ string) string {
privateMountDir := os.Getenv("X_CSI_PRIVATE_MOUNT_DIR")
if privateMountDir == "" {
privateMountDir = "/var/lib/kubelet/plugins/vxflexos.emc.dell.com/disks"
Expand All @@ -62,14 +61,14 @@ func (d *VxflexDriver) GetDriverMountDir(volumeHandle, pvName, podUUID string) s
}

// GetDriverBlockDev Returns the block device used for a PV by a pod.
func (d *VxflexDriver) GetDriverBlockDev(volumeHandle, pvName, podUUID string) string {
func (d *VxflexDriver) GetDriverBlockDev(_, pvName, podUUID string) string {
privateBlockDev := fmt.Sprintf("/var/lib/kubelet/plugins/kubernetes.io/csi/volumeDevices/publish/%s/%s", pvName, podUUID)
log.Debugf("privateBlockDev: %s", privateBlockDev)
return privateBlockDev
}

// GetStagingMountDir Returns the staging directory used by NodeUnstage for a mount device.
func (d *VxflexDriver) GetStagingMountDir(volumeHandle, pvName string) string {
func (d *VxflexDriver) GetStagingMountDir(volumeHandle, _ string) string {
stagingMountDir := os.Getenv("X_CSI_PRIVATE_MOUNT_DIR")
if stagingMountDir == "" {
stagingMountDir = "/var/lib/kubelet/plugins/vxflexos.emc.dell.com/disks"
Expand All @@ -80,7 +79,7 @@ func (d *VxflexDriver) GetStagingMountDir(volumeHandle, pvName string) string {
}

// GetStagingMountDirAfter125 Returns the staging directory used by NodeUnstage for a mount device.
func (d *VxflexDriver) GetStagingMountDirAfter125(volumeHandle, pvName string) string {
func (d *VxflexDriver) GetStagingMountDirAfter125(volumeHandle, _ string) string {
result := sha256.Sum256([]byte(fmt.Sprintf("%s", volumeHandle)))
volSha := fmt.Sprintf("%x", result)

Expand All @@ -94,24 +93,24 @@ func (d *VxflexDriver) GetStagingMountDirAfter125(volumeHandle, pvName string) s
}

// GetStagingBlockDir Returns the staging directory used by NodeUnstage for a block device.
func (d *VxflexDriver) GetStagingBlockDir(volumeHandle, pvName string) string {
func (d *VxflexDriver) GetStagingBlockDir(_, pvName string) string {
stagingBlockDir := fmt.Sprintf("/var/lib/kubelet/plugins/kubernetes.io/csi/volumeDevices/staging/%s", pvName)
log.Debugf("stagingBlockDir: %s", stagingBlockDir)
return stagingBlockDir
}

// NodeUnpublishExcludedError filters out NodeUnpublish errors that should be excluded
func (d *VxflexDriver) NodeUnpublishExcludedError(err error) bool {
func (d *VxflexDriver) NodeUnpublishExcludedError(_ error) bool {
return false
}

// NodeUnstageExcludedError filters out NodeStage errors that should be excluded
func (d *VxflexDriver) NodeUnstageExcludedError(err error) bool {
func (d *VxflexDriver) NodeUnstageExcludedError(_ error) bool {
return false
}

// FinalCleanup handles any driver specific final cleanup.
func (d *VxflexDriver) FinalCleanup(rawBlock bool, volumeHandle, pvName, podUUID string) error {
func (d *VxflexDriver) FinalCleanup(_ bool, _, _, _ string) error {
return nil
}

Expand All @@ -124,28 +123,28 @@ func (d *UnityDriver) GetDriverName() string {
}

// GetDriverMountDir returns the Unity private mount directory.
func (d *UnityDriver) GetDriverMountDir(volumeHandle, pvName, podUUID string) string {
func (d *UnityDriver) GetDriverMountDir(_, pvName, podUUID string) string {
privateMountDir := fmt.Sprintf("/var/lib/kubelet/pods/%s/volumes/kubernetes.io~csi/%s/mount", podUUID, pvName)
log.Debugf("privateMountDir: %s", privateMountDir)
return privateMountDir
}

// GetDriverBlockDev Returns the block device used for a PV by a pod.
func (d *UnityDriver) GetDriverBlockDev(volumeHandle, pvName, podUUID string) string {
func (d *UnityDriver) GetDriverBlockDev(_, pvName, podUUID string) string {
privateBlockDev := fmt.Sprintf("/var/lib/kubelet/plugins/kubernetes.io/csi/volumeDevices/publish/%s/%s", pvName, podUUID)
log.Debugf("privateBlockDev: %s", privateBlockDev)
return privateBlockDev
}

// GetStagingMountDir Returns the staging directory used by NodeUnstage for a mount device.
func (d *UnityDriver) GetStagingMountDir(volumeHandle, pvName string) string {
func (d *UnityDriver) GetStagingMountDir(_, pvName string) string {
stagingMountDir := fmt.Sprintf("/var/lib/kubelet/plugins/kubernetes.io/csi/pv/%s/globalmount", pvName)
log.Debugf("stagingMountDev: %s", stagingMountDir)
return stagingMountDir
}

// GetStagingMountDirAfter125 Returns the staging directory used by NodeUnstage for a mount device.
func (d *UnityDriver) GetStagingMountDirAfter125(volumeHandle, pvName string) string {
func (d *UnityDriver) GetStagingMountDirAfter125(volumeHandle, _ string) string {
result := sha256.Sum256([]byte(fmt.Sprintf("%s", volumeHandle)))
volSha := fmt.Sprintf("%x", result)

Expand All @@ -155,7 +154,7 @@ func (d *UnityDriver) GetStagingMountDirAfter125(volumeHandle, pvName string) st
}

// GetStagingBlockDir Returns the staging directory used by NodeUnstage for a block device.
func (d *UnityDriver) GetStagingBlockDir(volumeHandle, pvName string) string {
func (d *UnityDriver) GetStagingBlockDir(_, pvName string) string {
stagingBlockDir := fmt.Sprintf("/var/lib/kubelet/plugins/kubernetes.io/csi/volumeDevices/staging/%s", pvName)
log.Debugf("stagingBlockDir: %s", stagingBlockDir)
return stagingBlockDir
Expand All @@ -180,7 +179,7 @@ func (d *UnityDriver) NodeUnstageExcludedError(err error) bool {
}

// FinalCleanup handles any driver specific final cleanup.
func (d *UnityDriver) FinalCleanup(rawBlock bool, volumeHandle, pvName, podUUID string) error {
func (d *UnityDriver) FinalCleanup(rawBlock bool, _, pvName, podUUID string) error {
if rawBlock { // Do this cleanup on raw device block
loopBackDev, err := getLoopBackDevice(pvName)
if err != nil || loopBackDev == "" {
Expand Down Expand Up @@ -219,7 +218,7 @@ func (d *PScaleDriver) GetDriverName() string {
}

// GetDriverMountDir returns the PowerScale private mount directory.
func (d *PScaleDriver) GetDriverMountDir(volumeHandle, pvName, podUUID string) string {
func (d *PScaleDriver) GetDriverMountDir(_, pvName, podUUID string) string {
privateMountDir := os.Getenv("X_CSI_PRIVATE_MOUNT_DIR")
if privateMountDir == "" {
privateMountDir = "/var/lib/kubelet"
Expand All @@ -230,37 +229,37 @@ func (d *PScaleDriver) GetDriverMountDir(volumeHandle, pvName, podUUID string) s
}

// GetDriverBlockDev Returns the block device used for a PV by a pod.
func (d *PScaleDriver) GetDriverBlockDev(volumeHandle, pvName, podUUID string) string {
func (d *PScaleDriver) GetDriverBlockDev(_, _, _ string) string {
return ""
}

// GetStagingMountDir Returns the staging directory used by NodeUnstage for a mount device.
func (d *PScaleDriver) GetStagingMountDir(volumeHandle, pvName string) string {
func (d *PScaleDriver) GetStagingMountDir(_, _ string) string {
return ""
}

// GetStagingMountDirAfter125 Returns the staging directory used by NodeUnstage for a mount device.
func (d *PScaleDriver) GetStagingMountDirAfter125(volumeHandle, pvName string) string {
func (d *PScaleDriver) GetStagingMountDirAfter125(_, _ string) string {
return ""
}

// GetStagingBlockDir Returns the staging directory used by NodeUnstage for a block device.
func (d *PScaleDriver) GetStagingBlockDir(volumeHandle, pvName string) string {
func (d *PScaleDriver) GetStagingBlockDir(_, _ string) string {
return ""
}

// NodeUnpublishExcludedError filters out NodeUnpublish errors that should be excluded
func (d *PScaleDriver) NodeUnpublishExcludedError(err error) bool {
func (d *PScaleDriver) NodeUnpublishExcludedError(_ error) bool {
return false
}

// NodeUnstageExcludedError filters out NodeStage errors that should be excluded
func (d *PScaleDriver) NodeUnstageExcludedError(err error) bool {
func (d *PScaleDriver) NodeUnstageExcludedError(_ error) bool {
return false
}

// FinalCleanup handles any driver specific final cleanup.
func (d *PScaleDriver) FinalCleanup(rawBlock bool, volumeHandle, pvName, podUUID string) error {
func (d *PScaleDriver) FinalCleanup(_ bool, _, _, _ string) error {
return nil
}

Expand All @@ -273,31 +272,31 @@ func (d *PStoreDriver) GetDriverName() string {
}

// GetDriverMountDir returns the mount directory used for a PV by a pod.
func (d *PStoreDriver) GetDriverMountDir(volumeHandle, pvName, podUUID string) string {
func (d *PStoreDriver) GetDriverMountDir(_, pvName, podUUID string) string {
privateMountDir := getPrivateMountDir("/var/lib/kubelet")
privateMountDir = fmt.Sprintf("%s/pods/%s/volumes/kubernetes.io~csi/%s/mount", privateMountDir, podUUID, pvName)
log.Debugf("privateMountDir: %s", privateMountDir)
return privateMountDir
}

// GetDriverBlockDev Returns the block device used for a PV by a pod.
func (d *PStoreDriver) GetDriverBlockDev(volumeHandle, pvName, podUUID string) string {
func (d *PStoreDriver) GetDriverBlockDev(_, pvName, podUUID string) string {
privateMountDir := getPrivateMountDir("/var/lib/kubelet")
privateBlockDev := fmt.Sprintf("%s/plugins/kubernetes.io/csi/volumeDevices/publish/%s/%s", privateMountDir, pvName, podUUID)
log.Debugf("privateBlockDev: %s", privateBlockDev)
return privateBlockDev
}

// GetStagingMountDir Returns the staging directory used by NodeUnstage for a mount device.
func (d *PStoreDriver) GetStagingMountDir(volumeHandle, pvName string) string {
func (d *PStoreDriver) GetStagingMountDir(_, pvName string) string {
privateMountDir := getPrivateMountDir("/var/lib/kubelet")
stagingMountDev := fmt.Sprintf("%s/plugins/kubernetes.io/csi/pv/%s/globalmount", privateMountDir, pvName)
log.Debugf("stagingMountDev: %s", stagingMountDev)
return stagingMountDev
}

// GetStagingMountDirAfter125 Returns the staging directory used by NodeUnstage for a mount device.
func (d *PStoreDriver) GetStagingMountDirAfter125(volumeHandle, pvName string) string {
func (d *PStoreDriver) GetStagingMountDirAfter125(volumeHandle, _ string) string {
result := sha256.Sum256([]byte(fmt.Sprintf("%s", volumeHandle)))
volSha := fmt.Sprintf("%x", result)

Expand All @@ -307,25 +306,25 @@ func (d *PStoreDriver) GetStagingMountDirAfter125(volumeHandle, pvName string) s
}

// GetStagingBlockDir Returns the staging directory used by NodeUnstage for a block device.
func (d *PStoreDriver) GetStagingBlockDir(volumeHandle, pvName string) string {
func (d *PStoreDriver) GetStagingBlockDir(_, pvName string) string {
privateMountDir := getPrivateMountDir("/var/lib/kubelet")
stagingBlockDir := fmt.Sprintf("%s/plugins/kubernetes.io/csi/volumeDevices/staging/%s", privateMountDir, pvName)
log.Debugf("stagingBlockDir: %s", stagingBlockDir)
return stagingBlockDir
}

// NodeUnpublishExcludedError filters out NodeUnpublish errors that should be excluded
func (d *PStoreDriver) NodeUnpublishExcludedError(err error) bool {
func (d *PStoreDriver) NodeUnpublishExcludedError(_ error) bool {
return false
}

// NodeUnstageExcludedError filters out NodeStage errors that should be excluded
func (d *PStoreDriver) NodeUnstageExcludedError(err error) bool {
func (d *PStoreDriver) NodeUnstageExcludedError(_ error) bool {
return false
}

// FinalCleanup handles any driver specific final cleanup.
func (d *PStoreDriver) FinalCleanup(rawBlock bool, volumeHandle, pvName, podUUID string) error {
func (d *PStoreDriver) FinalCleanup(_ bool, _, _, _ string) error {
return nil
}

Expand Down
11 changes: 5 additions & 6 deletions internal/monitor/integration_steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ import (
"os"
"os/exec"
"path/filepath"
"podmon/internal/k8sapi"
"podmon/test/ssh"
"strconv"
"strings"
"sync"
"time"

"podmon/internal/k8sapi"
"podmon/test/ssh"

"github.com/cucumber/godog"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -1010,7 +1009,7 @@ func (i *integration) failNodes(filter func(node corev1.Node) bool, count float6
// For CSI driver pod run the script from test host not worker node
if failureType == "driverpod" {
var cmd *exec.Cmd
cmd = exec.Command(
cmd = exec.Command( // #nosec G204
"/bin/sh", fmt.Sprintf("%s/failpods.sh", i.scriptsDir),
"--ns", i.driverType,
"--timeoutseconds", fmt.Sprintf("%d", wait),
Expand Down Expand Up @@ -1654,13 +1653,13 @@ func IntegrationTestScenarioInit(context *godog.ScenarioContext) {
if pollK8sStr := os.Getenv("POLL_K8S"); strings.ToLower(pollK8sStr) == "true" {
pollK8sEnabled = true
}
context.BeforeScenario(func(sc *godog.Scenario) {
context.BeforeScenario(func(_ *godog.Scenario) {
if pollK8sEnabled {
pollTick = time.NewTicker(k8sPollInterval)
go i.startK8sPoller()
}
})
context.AfterScenario(func(sc *godog.Scenario, err error) {
context.AfterScenario(func(_ *godog.Scenario, _ error) {
if pollK8sEnabled {
pollTick.Stop()
}
Expand Down
9 changes: 4 additions & 5 deletions internal/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ package monitor
import (
"context"
"fmt"
"podmon/internal/csiapi"
"podmon/internal/k8sapi"
"strings"
"sync"
"time"

"podmon/internal/csiapi"
"podmon/internal/k8sapi"

log "github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -162,11 +161,11 @@ func (pm *PodMonitorType) StoreNodeUID(nodeName, uid string) {
// GetNodeUID returns the node UID
func (pm *PodMonitorType) GetNodeUID(nodeName string) string {
log.Debugf("GetNodeUid added node: %s", nodeName)
any, ok := pm.NodeNameToUID.Load(nodeName)
value, ok := pm.NodeNameToUID.Load(nodeName)
if !ok {
return ""
}
uid := fmt.Sprintf("%v", any)
uid := fmt.Sprintf("%v", value)
return uid
}

Expand Down
Loading
Loading