mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
Update golangci-lint version to v1.21.0
Signed-off-by: Woohyung Han <techhanx@gmail.com>
This commit is contained in:
parent
118f34525e
commit
8a16f740d6
@ -20,7 +20,7 @@ go: 1.12.x
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- GOLANGCI_VERSION=v1.17.0
|
- GOLANGCI_VERSION=v1.21.0
|
||||||
- GOSEC_VERSION=2.0.0
|
- GOSEC_VERSION=2.0.0
|
||||||
- TEST_COVERAGE=stdout
|
- TEST_COVERAGE=stdout
|
||||||
- GO_METALINTER_THREADS=1
|
- GO_METALINTER_THREADS=1
|
||||||
|
@ -46,7 +46,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
// common flags
|
// common flags
|
||||||
flag.StringVar(&conf.Vtype, "type", "", "driver type [rbd|cephfs|liveness]")
|
flag.StringVar(&conf.Vtype, "type", "", "driver type [rbd|cephfs|liveness]")
|
||||||
flag.StringVar(&conf.Endpoint, "endpoint", "unix://tmp/csi.sock", "CSI endpoint")
|
flag.StringVar(&conf.Endpoint, "endpoint", "unix://tmp/csi.sock", "CSI endpoint")
|
||||||
|
@ -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) {
|
func execCommandInPod(f *framework.Framework, c, ns string, opt *metav1.ListOptions) (string, string) {
|
||||||
|
|
||||||
cmd := []string{"/bin/sh", "-c", c}
|
cmd := []string{"/bin/sh", "-c", c}
|
||||||
podList, err := f.PodClientNS(ns).List(*opt)
|
podList, err := f.PodClientNS(ns).List(*opt)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
@ -523,7 +522,6 @@ func unmarshal(fileName string, obj interface{}) error {
|
|||||||
// createPVCAndApp creates pvc and pod
|
// createPVCAndApp creates pvc and pod
|
||||||
// if name is not empty same will be set as pvc and app name
|
// 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 {
|
func createPVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolumeClaim, app *v1.Pod) error {
|
||||||
|
|
||||||
if name != "" {
|
if name != "" {
|
||||||
pvc.Name = name
|
pvc.Name = name
|
||||||
app.Name = name
|
app.Name = name
|
||||||
@ -540,7 +538,6 @@ func createPVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolu
|
|||||||
// deletePVCAndApp delete pvc and pod
|
// deletePVCAndApp delete pvc and pod
|
||||||
// if name is not empty same will be set as pvc and app name
|
// 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 {
|
func deletePVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolumeClaim, app *v1.Pod) error {
|
||||||
|
|
||||||
if name != "" {
|
if name != "" {
|
||||||
pvc.Name = name
|
pvc.Name = name
|
||||||
app.Name = name
|
app.Name = name
|
||||||
@ -731,7 +728,6 @@ func validateNormalUserPVCAccess(pvcPath string, f *framework.Framework) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
func listRBDImages(f *framework.Framework) []string {
|
func listRBDImages(f *framework.Framework) []string {
|
||||||
|
|
||||||
opt := metav1.ListOptions{
|
opt := metav1.ListOptions{
|
||||||
LabelSelector: "app=rook-ceph-tools",
|
LabelSelector: "app=rook-ceph-tools",
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,6 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(
|
|||||||
|
|
||||||
// ExpandVolume expand CephFS Volumes on demand based on resizer request
|
// ExpandVolume expand CephFS Volumes on demand based on resizer request
|
||||||
func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
|
func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
|
||||||
|
|
||||||
if err := cs.validateExpandVolumeRequest(req); err != nil {
|
if err := cs.validateExpandVolumeRequest(req); err != nil {
|
||||||
klog.Errorf("ControllerExpandVolumeRequest validation failed: %v", err)
|
klog.Errorf("ControllerExpandVolumeRequest validation failed: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -335,5 +334,4 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
|
|||||||
CapacityBytes: RoundOffSize,
|
CapacityBytes: RoundOffSize,
|
||||||
NodeExpansionRequired: false,
|
NodeExpansionRequired: false,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,6 @@ func NewNodeServer(d *csicommon.CSIDriver, t string) *NodeServer {
|
|||||||
// Run start a non-blocking grpc controller,node and identityserver for
|
// Run start a non-blocking grpc controller,node and identityserver for
|
||||||
// ceph CSI driver which can serve multiple parallel requests
|
// ceph CSI driver which can serve multiple parallel requests
|
||||||
func (fs *Driver) Run(conf *util.Config, cachePersister util.CachePersister) {
|
func (fs *Driver) Run(conf *util.Config, cachePersister util.CachePersister) {
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
PluginFolder = conf.PluginPath
|
PluginFolder = conf.PluginPath
|
||||||
|
|
||||||
|
@ -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
|
// NodePublishVolume mounts the volume mounted to the staging path to the target
|
||||||
// path
|
// path
|
||||||
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
|
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
|
||||||
|
|
||||||
mountOptions := []string{"bind"}
|
mountOptions := []string{"bind"}
|
||||||
if err := util.ValidateNodePublishVolumeRequest(req); err != nil {
|
if err := util.ValidateNodePublishVolumeRequest(req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -88,7 +88,6 @@ func (d *CSIDriver) AddControllerServiceCapabilities(cl []csi.ControllerServiceC
|
|||||||
}
|
}
|
||||||
|
|
||||||
d.cap = csc
|
d.cap = csc
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddVolumeCapabilityAccessModes stores volume access modes
|
// AddVolumeCapabilityAccessModes stores volume access modes
|
||||||
|
@ -81,7 +81,6 @@ func (ns *DefaultNodeServer) NodeGetCapabilities(ctx context.Context, req *csi.N
|
|||||||
|
|
||||||
// NodeGetVolumeStats returns volume stats
|
// NodeGetVolumeStats returns volume stats
|
||||||
func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
|
func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
targetPath := req.GetVolumePath()
|
targetPath := req.GetVolumePath()
|
||||||
if targetPath == "" {
|
if targetPath == "" {
|
||||||
@ -144,7 +143,6 @@ func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.No
|
|||||||
if !ok {
|
if !ok {
|
||||||
klog.Errorf(util.Log(ctx, "failed to fetch available inodes"))
|
klog.Errorf(util.Log(ctx, "failed to fetch available inodes"))
|
||||||
return nil, status.Error(codes.Unknown, "failed to fetch available inodes")
|
return nil, status.Error(codes.Unknown, "failed to fetch available inodes")
|
||||||
|
|
||||||
}
|
}
|
||||||
inodesFree, ok := (*(volMetrics.InodesFree)).AsInt64()
|
inodesFree, ok := (*(volMetrics.InodesFree)).AsInt64()
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -171,5 +169,4 @@ func (ns *DefaultNodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.No
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ type nonBlockingGRPCServer struct {
|
|||||||
|
|
||||||
// Start start service on endpoint
|
// Start start service on endpoint
|
||||||
func (s *nonBlockingGRPCServer) Start(endpoint, hstOptions string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, metrics bool) {
|
func (s *nonBlockingGRPCServer) Start(endpoint, hstOptions string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, metrics bool) {
|
||||||
|
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
go s.serve(endpoint, hstOptions, ids, cs, ns, metrics)
|
go s.serve(endpoint, hstOptions, ids, cs, ns, metrics)
|
||||||
}
|
}
|
||||||
@ -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) {
|
func (s *nonBlockingGRPCServer) serve(endpoint, hstOptions string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, metrics bool) {
|
||||||
|
|
||||||
proto, addr, err := parseEndpoint(endpoint)
|
proto, addr, err := parseEndpoint(endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Fatal(err.Error())
|
klog.Fatal(err.Error())
|
||||||
|
@ -171,7 +171,6 @@ func panicHandler(ctx context.Context, req interface{}, info *grpc.UnaryServerIn
|
|||||||
klog.Errorf("panic occurred: %v", r)
|
klog.Errorf("panic occurred: %v", r)
|
||||||
debug.PrintStack()
|
debug.PrintStack()
|
||||||
err = status.Errorf(codes.Internal, "panic %v", r)
|
err = status.Errorf(codes.Internal, "panic %v", r)
|
||||||
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return handler(ctx, req)
|
return handler(ctx, req)
|
||||||
|
@ -38,7 +38,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func getLiveness(timeout time.Duration, csiConn *grpc.ClientConn) {
|
func getLiveness(timeout time.Duration, csiConn *grpc.ClientConn) {
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
@ -118,7 +118,6 @@ func (cs *ControllerServer) parseVolCreateRequest(ctx context.Context, req *csi.
|
|||||||
|
|
||||||
// CreateVolume creates the volume in backend
|
// CreateVolume creates the volume in backend
|
||||||
func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
|
func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
|
||||||
|
|
||||||
if err := cs.validateVolumeReq(ctx, req); err != nil {
|
if err := cs.validateVolumeReq(ctx, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -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
|
// NodePublishVolume mounts the volume mounted to the device path to the target
|
||||||
// path
|
// path
|
||||||
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
|
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
|
||||||
|
|
||||||
err := util.ValidateNodePublishVolumeRequest(req)
|
err := util.ValidateNodePublishVolumeRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -408,7 +407,6 @@ func (ns *NodeServer) createTargetMountPath(ctx context.Context, mountPath strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return notMnt, err
|
return notMnt, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeUnpublishVolume unmounts the volume from the target path
|
// NodeUnpublishVolume unmounts the volume from the target path
|
||||||
|
@ -70,7 +70,6 @@ func (nc *NodeCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -93,12 +92,10 @@ func decodeObj(fpath, pattern string, file os.FileInfo, destObj interface{}) err
|
|||||||
if err = decoder.Decode(destObj); err != nil {
|
if err = decoder.Decode(destObj); err != nil {
|
||||||
if err = fp.Close(); err != nil {
|
if err = fp.Close(); err != nil {
|
||||||
return errors.Wrapf(err, "failed to close file %s", file.Name())
|
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 errors.Wrapf(err, "node-cache: couldn't decode file %s", file.Name())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates the metadata file in cache directory with identifier name
|
// Create creates the metadata file in cache directory with identifier name
|
||||||
@ -161,7 +158,6 @@ func (nc *NodeCache) Delete(identifier string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return errors.Wrapf(err, "node-cache: error removing file %s", file)
|
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)
|
klog.V(4).Infof("node-cache: successfully deleted metadata storage file at: %+v\n", file)
|
||||||
return nil
|
return nil
|
||||||
|
@ -296,7 +296,6 @@ func reserveOMapName(ctx context.Context, monitors string, cr *Credentials, pool
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "", errors.New("uuid conflicts exceeds retry threshold")
|
return "", errors.New("uuid conflicts exceeds retry threshold")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -141,6 +141,10 @@ linters-settings:
|
|||||||
# make an issue if func has more lines of code than this setting and
|
# make an issue if func has more lines of code than this setting and
|
||||||
# it has naked returns; default is 30
|
# it has naked returns; default is 30
|
||||||
max-func-lines: 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:
|
linters:
|
||||||
enable-all: true
|
enable-all: true
|
||||||
@ -149,3 +153,6 @@ linters:
|
|||||||
- dupl
|
- dupl
|
||||||
- gochecknoinits
|
- gochecknoinits
|
||||||
- gochecknoglobals
|
- gochecknoglobals
|
||||||
|
- godox
|
||||||
|
- wsl
|
||||||
|
- funlen
|
||||||
|
Loading…
Reference in New Issue
Block a user