Skip to content
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/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.54
version: v1.60
args: -E=gofmt,unused,ineffassign,revive,misspell,exportloopref,asciicheck,bodyclose,contextcheck --timeout=30m0s
verify-helm:
name: Verify Helm
Expand Down
30 changes: 15 additions & 15 deletions pkg/nfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
if v != "" {
var err error
if mountPermissions, err = strconv.ParseUint(v, 8, 32); err != nil {
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid mountPermissions %s in storage class", v))
return nil, status.Errorf(codes.InvalidArgument, "invalid mountPermissions %s in storage class", v)
}
}
default:
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid parameter %q in storage class", k))
return nil, status.Errorf(codes.InvalidArgument, "invalid parameter %q in storage class", k)
}
}

Expand All @@ -168,24 +168,24 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}
// Mount nfs base share so we can create a subdirectory
if err = cs.internalMount(ctx, nfsVol, parameters, volCap); err != nil {
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err.Error())
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err)
}
defer func() {
if err = cs.internalUnmount(ctx, nfsVol); err != nil {
klog.Warningf("failed to unmount nfs server: %v", err.Error())
klog.Warningf("failed to unmount nfs server: %v", err)
}
}()

// Create subdirectory under base-dir
internalVolumePath := getInternalVolumePath(cs.Driver.workingMountDir, nfsVol)
if err = os.MkdirAll(internalVolumePath, 0777); err != nil {
return nil, status.Errorf(codes.Internal, "failed to make subdirectory: %v", err.Error())
return nil, status.Errorf(codes.Internal, "failed to make subdirectory: %v", err)
}

if mountPermissions > 0 {
// Reset directory permissions because of umask problems
if err = os.Chmod(internalVolumePath, os.FileMode(mountPermissions)); err != nil {
klog.Warningf("failed to chmod subdirectory: %v", err.Error())
klog.Warningf("failed to chmod subdirectory: %v", err)
}
}

Expand Down Expand Up @@ -245,19 +245,19 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
// check whether volumeID is in the cache
cache, err := cs.Driver.volDeletionCache.Get(volumeID, azcache.CacheReadTypeDefault)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Errorf(codes.Internal, "%v", err)
}
if cache != nil {
klog.V(2).Infof("DeleteVolume: volume %s is already deleted", volumeID)
return &csi.DeleteVolumeResponse{}, nil
}
// mount nfs base share so we can delete the subdirectory
if err = cs.internalMount(ctx, nfsVol, nil, volCap); err != nil {
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err.Error())
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err)
}
defer func() {
if err = cs.internalUnmount(ctx, nfsVol); err != nil {
klog.Warningf("failed to unmount nfs server: %v", err.Error())
klog.Warningf("failed to unmount nfs server: %v", err)
}
}()

Expand All @@ -269,7 +269,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
parentDir := filepath.Dir(archivedInternalVolumePath)
klog.V(2).Infof("DeleteVolume: subdirectory(%s) contains '/', make sure the parent directory(%s) exists", nfsVol.subDir, parentDir)
if err = os.MkdirAll(parentDir, 0777); err != nil {
return nil, status.Errorf(codes.Internal, "create parent directory(%s) of %s failed with %v", parentDir, archivedInternalVolumePath, err.Error())
return nil, status.Errorf(codes.Internal, "create parent directory(%s) of %s failed with %v", parentDir, archivedInternalVolumePath, err)
}
}

Expand All @@ -278,12 +278,12 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
if cs.Driver.removeArchivedVolumePath {
klog.V(2).Infof("removing archived subdirectory at %v", archivedInternalVolumePath)
if err = os.RemoveAll(archivedInternalVolumePath); err != nil {
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err.Error())
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err)
}
klog.V(2).Infof("removed archived subdirectory at %v", archivedInternalVolumePath)
}
if err = os.Rename(internalVolumePath, archivedInternalVolumePath); err != nil {
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error())
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err)
}
// make sure internalVolumePath does not exist with 1 minute timeout
if err = waitForPathNotExistWithTimeout(internalVolumePath, time.Minute); err != nil {
Expand All @@ -294,7 +294,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
// delete subdirectory under base-dir
klog.V(2).Infof("removing subdirectory at %v", internalVolumePath)
if err = os.RemoveAll(internalVolumePath); err != nil {
return nil, status.Errorf(codes.Internal, "delete subdirectory(%s) failed with %v", internalVolumePath, err.Error())
return nil, status.Errorf(codes.Internal, "delete subdirectory(%s) failed with %v", internalVolumePath, err)
}
}
} else {
Expand Down Expand Up @@ -455,7 +455,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
internalVolumePath := getInternalVolumePath(cs.Driver.workingMountDir, vol)
klog.V(2).Infof("Removing snapshot archive at %v", internalVolumePath)
if err = os.RemoveAll(internalVolumePath); err != nil {
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err.Error())
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err)
}

return &csi.DeleteSnapshotResponse{}, nil
Expand Down Expand Up @@ -620,7 +620,7 @@ func newNFSSnapshot(name string, params map[string]string, vol *nfsVolume) (*nfs
case paramShare:
baseDir = v
default:
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid parameter %q in snapshot storage class", k))
return nil, status.Errorf(codes.InvalidArgument, "invalid parameter %q in snapshot storage class", k)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/nfs/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func NewDriver(options *DriverOptions) *Driver {
}

var err error
getter := func(key string) (interface{}, error) { return nil, nil }
getter := func(_ string) (interface{}, error) { return nil, nil }
if n.volStatsCache, err = azcache.NewTimedCache(time.Duration(options.VolStatsCacheExpireInMinutes)*time.Minute, getter, false); err != nil {
klog.Fatalf("%v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/nfs/nfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewEmptyDriver(emptyField string) *Driver {
}
}
d.volumeLocks = NewVolumeLocks()
getter := func(key string) (interface{}, error) { return nil, nil }
getter := func(_ string) (interface{}, error) { return nil, nil }
d.volStatsCache, _ = azcache.NewTimedCache(time.Minute, getter, false)
return d
}
Expand Down Expand Up @@ -109,15 +109,15 @@ func TestRun(t *testing.T) {
}{
{
name: "Successful run",
testFunc: func(t *testing.T) {
testFunc: func(_ *testing.T) {
d := NewEmptyDriver("")
d.endpoint = "tcp://127.0.0.1:0"
d.Run(true)
},
},
{
name: "Successful run with node ID missing",
testFunc: func(t *testing.T) {
testFunc: func(_ *testing.T) {
d := NewEmptyDriver("")
d.endpoint = "tcp://127.0.0.1:0"
d.nodeID = ""
Expand Down
4 changes: 2 additions & 2 deletions pkg/nfs/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (ns *NodeServer) NodePublishVolume(_ context.Context, req *csi.NodePublishV
if v != "" {
var err error
if mountPermissions, err = strconv.ParseUint(v, 8, 32); err != nil {
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid mountPermissions %s", v))
return nil, status.Errorf(codes.InvalidArgument, "invalid mountPermissions %s", v)
}
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ func (ns *NodeServer) NodeGetVolumeStats(_ context.Context, req *csi.NodeGetVolu
// check if the volume stats is cached
cache, err := ns.Driver.volStatsCache.Get(req.VolumeId, azcache.CacheReadTypeDefault)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Errorf(codes.Internal, "%v", err)
}
if cache != nil {
resp := cache.(csi.NodeGetVolumeStatsResponse)
Expand Down
10 changes: 5 additions & 5 deletions pkg/nfs/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
func TestNodePublishVolume(t *testing.T) {
ns, err := getTestNodeServer()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err.Error())
}

params := map[string]string{
Expand Down Expand Up @@ -208,7 +208,7 @@ func TestNodePublishVolume(t *testing.T) {
func TestNodeUnpublishVolume(t *testing.T) {
ns, err := getTestNodeServer()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err.Error())
}

errorTarget := testutil.GetWorkDirPath("error_is_likely_target", t)
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
func TestNodeGetInfo(t *testing.T) {
ns, err := getTestNodeServer()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err.Error())
}

// Test valid request
Expand All @@ -289,7 +289,7 @@ func TestNodeGetInfo(t *testing.T) {
func TestNodeGetCapabilities(t *testing.T) {
ns, err := getTestNodeServer()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err.Error())
}

capType := &csi.NodeServiceCapability_Rpc{
Expand Down Expand Up @@ -358,7 +358,7 @@ func TestNodeGetVolumeStats(t *testing.T) {
_ = makeDir(fakePath)
ns, err := getTestNodeServer()
if err != nil {
t.Fatalf(err.Error())
t.Fatalf("%v", err.Error())
}

for _, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion pkg/nfs/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
if proto == "unix" {
addr = "/" + addr
if err := os.Remove(addr); err != nil && !os.IsNotExist(err) {
klog.Fatalf("Failed to remove %s, error: %s", addr, err.Error())
klog.Fatalf("Failed to remove %s, error: %v", addr, err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
testDriver driver.PVTestDriver
)

ginkgo.BeforeEach(func(ctx ginkgo.SpecContext) {
ginkgo.BeforeEach(func(_ ginkgo.SpecContext) {
checkPodsRestart := testCmd{
command: "sh",
args: []string{"test/utils/check_driver_pods_restart.sh"},
Expand Down
2 changes: 1 addition & 1 deletion test/utils/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
func GetWorkDirPath(dir string, t *testing.T) string {
path, err := os.Getwd()
if err != nil {
t.Fatalf("failed to get working directory: %s", err)
t.Fatalf("failed to get working directory: %v", err)
}
return fmt.Sprintf("%s%c%s", path, os.PathSeparator, dir)
}