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 version to v1.21.0 #741

Merged
merged 1 commit into from
Dec 12, 2019
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ go: 1.12.x

env:
global:
- GOLANGCI_VERSION=v1.17.0
- GOLANGCI_VERSION=v1.21.0
- GOSEC_VERSION=2.0.0
- TEST_COVERAGE=stdout
- GO_METALINTER_THREADS=1
Expand Down
1 change: 0 additions & 1 deletion cmd/cephcsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ var (
)

func init() {

// common flags
flag.StringVar(&conf.Vtype, "type", "", "driver type [rbd|cephfs|liveness]")
flag.StringVar(&conf.Endpoint, "endpoint", "unix://tmp/csi.sock", "CSI endpoint")
Expand Down
4 changes: 0 additions & 4 deletions e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func waitForDeploymentComplete(name, ns string, c clientset.Interface, t int) er
}

func execCommandInPod(f *framework.Framework, c, ns string, opt *metav1.ListOptions) (string, string) {

cmd := []string{"/bin/sh", "-c", c}
podList, err := f.PodClientNS(ns).List(*opt)
framework.ExpectNoError(err)
Expand Down Expand Up @@ -523,7 +522,6 @@ func unmarshal(fileName string, obj interface{}) error {
// createPVCAndApp creates pvc and pod
// if name is not empty same will be set as pvc and app name
func createPVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolumeClaim, app *v1.Pod) error {

if name != "" {
pvc.Name = name
app.Name = name
Expand All @@ -540,7 +538,6 @@ func createPVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolu
// deletePVCAndApp delete pvc and pod
// if name is not empty same will be set as pvc and app name
func deletePVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolumeClaim, app *v1.Pod) error {

if name != "" {
pvc.Name = name
app.Name = name
Expand Down Expand Up @@ -731,7 +728,6 @@ func validateNormalUserPVCAccess(pvcPath string, f *framework.Framework) {
// }

func listRBDImages(f *framework.Framework) []string {

opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools",
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/cephfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(

// ExpandVolume expand CephFS Volumes on demand based on resizer request
func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {

if err := cs.validateExpandVolumeRequest(req); err != nil {
klog.Errorf("ControllerExpandVolumeRequest validation failed: %v", err)
return nil, err
Expand Down Expand Up @@ -335,5 +334,4 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
CapacityBytes: RoundOffSize,
NodeExpansionRequired: false,
}, nil

}
1 change: 0 additions & 1 deletion pkg/cephfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func NewNodeServer(d *csicommon.CSIDriver, t string) *NodeServer {
// Run start a non-blocking grpc controller,node and identityserver for
// ceph CSI driver which can serve multiple parallel requests
func (fs *Driver) Run(conf *util.Config, cachePersister util.CachePersister) {

// Configuration
PluginFolder = conf.PluginPath

Expand Down
1 change: 0 additions & 1 deletion pkg/cephfs/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func (*NodeServer) mount(ctx context.Context, volOptions *volumeOptions, req *cs
// NodePublishVolume mounts the volume mounted to the staging path to the target
// path
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {

mountOptions := []string{"bind"}
if err := util.ValidateNodePublishVolumeRequest(req); err != nil {
return nil, err
Expand Down
1 change: 0 additions & 1 deletion pkg/csi-common/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceC
}

d.cap = csc

}

// AddVolumeCapabilityAccessModes stores volume access modes
Expand Down
3 changes: 0 additions & 3 deletions pkg/csi-common/nodeserver-default.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func (ns *DefaultNodeServer) NodeGetCapabilities(ctx context.Context, req *csi.N

// NodeGetVolumeStats returns volume stats
func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {

var err error
targetPath := req.GetVolumePath()
if targetPath == "" {
Expand Down Expand Up @@ -144,7 +143,6 @@ func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.No
if !ok {
klog.Errorf(util.Log(ctx, "failed to fetch available inodes"))
return nil, status.Error(codes.Unknown, "failed to fetch available inodes")

}
inodesFree, ok := (*(volMetrics.InodesFree)).AsInt64()
if !ok {
Expand All @@ -171,5 +169,4 @@ func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.No
},
},
}, nil

}
2 changes: 0 additions & 2 deletions pkg/csi-common/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ type nonBlockingGRPCServer struct {

// Start start service on endpoint
func (s *nonBlockingGRPCServer) Start(endpoint, hstOptions string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, metrics bool) {

s.wg.Add(1)
go s.serve(endpoint, hstOptions, ids, cs, ns, metrics)
}
Expand All @@ -77,7 +76,6 @@ func (s *nonBlockingGRPCServer) ForceStop() {
}

func (s *nonBlockingGRPCServer) serve(endpoint, hstOptions string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, metrics bool) {

proto, addr, err := parseEndpoint(endpoint)
if err != nil {
klog.Fatal(err.Error())
Expand Down
1 change: 0 additions & 1 deletion pkg/csi-common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func panicHandler(ctx context.Context, req interface{}, info *grpc.UnaryServerIn
klog.Errorf("panic occurred: %v", r)
debug.PrintStack()
err = status.Errorf(codes.Internal, "panic %v", r)

}
}()
return handler(ctx, req)
Expand Down
1 change: 0 additions & 1 deletion pkg/liveness/liveness.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var (
)

func getLiveness(timeout time.Duration, csiConn *grpc.ClientConn) {

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

Expand Down
1 change: 0 additions & 1 deletion pkg/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func (cs *ControllerServer) parseVolCreateRequest(ctx context.Context, req *csi.

// CreateVolume creates the volume in backend
func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {

if err := cs.validateVolumeReq(ctx, req); err != nil {
return nil, err
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/rbd/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ func (ns *NodeServer) createStageMountPoint(ctx context.Context, mountPath strin
// NodePublishVolume mounts the volume mounted to the device path to the target
// path
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {

err := util.ValidateNodePublishVolumeRequest(req)
if err != nil {
return nil, err
Expand Down Expand Up @@ -408,7 +407,6 @@ func (ns *NodeServer) createTargetMountPath(ctx context.Context, mountPath strin
}
}
return notMnt, err

}

// NodeUnpublishVolume unmounts the volume from the target path
Expand Down
4 changes: 0 additions & 4 deletions pkg/util/nodecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func (nc *NodeCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) e
}
}
return err

}
return nil
}
Expand All @@ -93,12 +92,10 @@ func decodeObj(fpath, pattern string, file os.FileInfo, destObj interface{}) err
if err = decoder.Decode(destObj); err != nil {
if err = fp.Close(); err != nil {
return errors.Wrapf(err, "failed to close file %s", file.Name())

}
return errors.Wrapf(err, "node-cache: couldn't decode file %s", file.Name())
}
return nil

}

// Create creates the metadata file in cache directory with identifier name
Expand Down Expand Up @@ -161,7 +158,6 @@ func (nc *NodeCache) Delete(identifier string) error {
}

return errors.Wrapf(err, "node-cache: error removing file %s", file)

}
klog.V(4).Infof("node-cache: successfully deleted metadata storage file at: %+v\n", file)
return nil
Expand Down
1 change: 0 additions & 1 deletion pkg/util/voljournal.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ func reserveOMapName(ctx context.Context, monitors string, cr *Credentials, pool
}

return "", errors.New("uuid conflicts exceeds retry threshold")

}

/*
Expand Down
7 changes: 7 additions & 0 deletions scripts/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ linters-settings:
# make an issue if func has more lines of code than this setting and
# it has naked returns; default is 30
max-func-lines: 30
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
# TODO: decrease complexity with refacoring the code
min-complexity: 40

linters:
enable-all: true
Expand All @@ -149,3 +153,6 @@ linters:
- dupl
- gochecknoinits
- gochecknoglobals
- godox
- wsl
- funlen