Skip to content

Commit

Permalink
Merge pull request alibaba#29 from Lyt99/features/upgrade-golangci-lint
Browse files Browse the repository at this point in the history
upgrade golangci-lint to v1.52.2
  • Loading branch information
BSWANG committed Apr 4, 2023
2 parents 6913d07 + eaa1c6b commit 65083d7
Show file tree
Hide file tree
Showing 27 changed files with 72 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2.5.2
with:
version: v1.50.1
version: v1.52.2
args: --timeout 300s --skip-dirs test/skoop/e2e --skip-dirs-use-default -v -E goconst -E gofmt -E ineffassign -E goimports -E revive -E misspell -E vet -E deadcode

shellcheck:
Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/bpfutil/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func GetCommString(comm [20]int8) string {
return strings.TrimSpace(string(buf))
}

func GetTCPState(no uint8) string {
func GetTCPState(_ uint8) string {

return "UNKNOW"
}
4 changes: 2 additions & 2 deletions pkg/exporter/cmd/eventserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func NewEServer(ctx context.Context, config EventConfig) *EServer {
return es
}

func (e *EServer) WatchEvent(req *proto.WatchRequest, srv proto.Inspector_WatchEventServer) error {
func (e *EServer) WatchEvent(_ *proto.WatchRequest, srv proto.Inspector_WatchEventServer) error {
client := getPeerClient(srv.Context())
datach := make(chan proto.RawEvent)
slog.Ctx(e.ctx).Info("watch event income", "client", client)
Expand All @@ -99,7 +99,7 @@ func (e *EServer) WatchEvent(req *proto.WatchRequest, srv proto.Inspector_WatchE
return nil
}

func (e *EServer) QueryMetric(ctx context.Context, req *proto.QueryMetricRequest) (*proto.QueryMetricResponse, error) {
func (e *EServer) QueryMetric(_ context.Context, _ *proto.QueryMetricRequest) (*proto.QueryMetricResponse, error) {
res := &proto.QueryMetricResponse{}
return res, nil
}
Expand Down
36 changes: 18 additions & 18 deletions pkg/exporter/nettop/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nettop

import (
"context"
fmt "fmt"
"fmt"
"net"
"net/url"
"os"
Expand Down Expand Up @@ -168,93 +168,93 @@ func NewRemoteRuntimeService(endpoint string, connectionTimeout time.Duration) (
}

// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
func (r *remoteRuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) {
func (r *remoteRuntimeService) Attach(_ *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) {
return nil, nil
}

// CheckpointContainer triggers a checkpoint of the given CheckpointContainerRequest
func (r *remoteRuntimeService) CheckpointContainer(options *runtimeapi.CheckpointContainerRequest) error {
func (r *remoteRuntimeService) CheckpointContainer(_ *runtimeapi.CheckpointContainerRequest) error {
return nil
}

// ContainerStats returns the stats of the container.
func (r *remoteRuntimeService) ContainerStats(containerID string) (*runtimeapi.ContainerStats, error) {
func (r *remoteRuntimeService) ContainerStats(_ string) (*runtimeapi.ContainerStats, error) {
return nil, nil
}

// CreateContainer creates a new container in the specified PodSandbox.
func (r *remoteRuntimeService) CreateContainer(podSandBoxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error) {
func (r *remoteRuntimeService) CreateContainer(_ string, _ *runtimeapi.ContainerConfig, _ *runtimeapi.PodSandboxConfig) (string, error) {
return "", nil
}

// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.
func (r *remoteRuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) {
func (r *remoteRuntimeService) Exec(_ *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) {
return nil, nil
}

// ExecSync executes a command in the container, and returns the stdout output.
// If command exits with a non-zero exit code, an error is returned.
func (r *remoteRuntimeService) ExecSync(containerID string, cmd []string, timeout time.Duration) (stdout []byte, stderr []byte, err error) {
func (r *remoteRuntimeService) ExecSync(_ string, _ []string, _ time.Duration) (stdout []byte, stderr []byte, err error) {
return nil, nil, nil
}

func (r *remoteRuntimeService) GetContainerEvents(containerEventsCh chan *runtimeapi.ContainerEventResponse) error {
func (r *remoteRuntimeService) GetContainerEvents(_ chan *runtimeapi.ContainerEventResponse) error {
return nil
}

// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
func (r *remoteRuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
func (r *remoteRuntimeService) PortForward(_ *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
return nil, nil
}

// RemoveContainer removes the container. If the container is running, the container
// should be forced to removal.
func (r *remoteRuntimeService) RemoveContainer(containerID string) (err error) {
func (r *remoteRuntimeService) RemoveContainer(_ string) (err error) {
return nil
}

// RemovePodSandbox removes the sandbox. If there are any containers in the
// sandbox, they should be forcibly removed.
func (r *remoteRuntimeService) RemovePodSandbox(podSandBoxID string) (err error) {
func (r *remoteRuntimeService) RemovePodSandbox(_ string) (err error) {
return nil
}

// ReopenContainerLog reopens the container log file.
func (r *remoteRuntimeService) ReopenContainerLog(containerID string) (err error) {
func (r *remoteRuntimeService) ReopenContainerLog(_ string) (err error) {
return nil
}

// RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
// the sandbox is in ready state.
func (r *remoteRuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig, runtimeHandler string) (string, error) {
func (r *remoteRuntimeService) RunPodSandbox(_ *runtimeapi.PodSandboxConfig, _ string) (string, error) {
return "", nil
}

// StartContainer starts the container.
func (r *remoteRuntimeService) StartContainer(containerID string) (err error) {
func (r *remoteRuntimeService) StartContainer(_ string) (err error) {
return nil
}

// StopContainer stops a running container with a grace period (i.e., timeout).
func (r *remoteRuntimeService) StopContainer(containerID string, timeout int64) (err error) {
func (r *remoteRuntimeService) StopContainer(_ string, _ int64) (err error) {
return nil
}

// StopPodSandbox stops the sandbox. If there are any running containers in the
// sandbox, they should be forced to termination.
func (r *remoteRuntimeService) StopPodSandbox(podSandBoxID string) (err error) {
func (r *remoteRuntimeService) StopPodSandbox(_ string) (err error) {
return nil
}

// UpdateContainerResources updates a containers resource config
func (r *remoteRuntimeService) UpdateContainerResources(containerID string, resources *runtimeapi.ContainerResources) (err error) {
func (r *remoteRuntimeService) UpdateContainerResources(_ string, _ *runtimeapi.ContainerResources) (err error) {
return nil
}

// UpdateRuntimeConfig updates the config of a runtime service. The only
// update payload currently supported is the pod CIDR assigned to a node,
// and the runtime service just proxies it down to the network plugin.
func (r *remoteRuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig) (err error) {
func (r *remoteRuntimeService) UpdateRuntimeConfig(_ *runtimeapi.RuntimeConfig) (err error) {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/nettop/netns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import (
"testing"
)

func TestFindNsInum(t *testing.T) {
func TestFindNsInum(_ *testing.T) {
}
2 changes: 1 addition & 1 deletion pkg/exporter/probe/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func init() {
availmprobes["virtcmdlatency"] = tracevirtcmdlat.GetProbe()
}

func ListMetricProbes(ctx context.Context, avail bool) (probelist []string) {
func ListMetricProbes(_ context.Context, _ bool) (probelist []string) {
for k := range availmprobes {
probelist = append(probelist, k)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/probe/procio/procio.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *ProcIO) Collect(ctx context.Context) (map[string]map[uint32]uint64, err
return collect(ctx, ets)
}

func collect(ctx context.Context, nslist []*nettop.Entity) (map[string]map[uint32]uint64, error) {
func collect(_ context.Context, _ []*nettop.Entity) (map[string]map[uint32]uint64, error) {
resMap := make(map[string]map[uint32]uint64)
for _, stat := range IOMetrics {
resMap[metricUniqueID("io", stat)] = map[uint32]uint64{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/probe/procnetdev/procnetdev.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func metricUniqueID(subject string, m string) string {
return fmt.Sprintf("%s%s", subject, strings.ToLower(m))
}

func collect(ctx context.Context, nslist []*nettop.Entity) (map[string]map[uint32]uint64, error) {
func collect(_ context.Context, nslist []*nettop.Entity) (map[string]map[uint32]uint64, error) {
resMap := make(map[string]map[uint32]uint64)
for _, mname := range NetdevMetrics {
resMap[metricUniqueID("netdev", mname)] = map[uint32]uint64{}
Expand Down
6 changes: 3 additions & 3 deletions pkg/exporter/probe/procnetstat/procnetstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ func collect(ctx context.Context, nslist []*nettop.Entity) (map[string]map[uint3
extstats := stats[ProtocolTCPExt]
for _, stat := range TCPExtMetrics {
if _, ok := extstats[stat]; ok {
if data, err := strconv.ParseUint(extstats[stat], 10, 64); err != nil {
data, err := strconv.ParseUint(extstats[stat], 10, 64)
if err != nil {
slog.Ctx(ctx).Warn("collect", "mod", MODULE_NAME, "ignore", stat, "err", err)
continue
} else {
resMap[metricUniqueID("tcpext", stat)][uint32(et.GetNetns())] += data
}
resMap[metricUniqueID("tcpext", stat)][uint32(et.GetNetns())] += data
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/exporter/probe/procsnmp/procsnmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ func collect(ctx context.Context, entitys []*nettop.Entity) (map[string]map[uint
for k, v := range stat {
mkey := metricUniqueID(proto, k)
slog.Ctx(ctx).Debug("store metric", "metric", mkey, "pid", pid, "nsinum", nsinum, "value", v)
if data, err := strconv.ParseInt(v, 10, 64); err != nil {
data, err := strconv.ParseInt(v, 10, 64)
if err != nil {
slog.Ctx(ctx).Debug("parse netstat value", "metric", mkey, "pid", pid, "nsinum", nsinum, "value", v, "err", err)
continue
} else {
// ignore unaware metric
if _, ok := res[mkey]; ok {
res[mkey][uint32(nsinum)] = uint64(data)
}
}
// ignore unaware metric
if _, ok := res[mkey]; ok {
res[mkey][uint32(nsinum)] = uint64(data)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/probe/procsock/procsock.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type tcpsockstat struct {
Mem int
}

func collect(ctx context.Context, nslist []*nettop.Entity) (resMap map[string]map[uint32]uint64, err error) {
func collect(_ context.Context, nslist []*nettop.Entity) (resMap map[string]map[uint32]uint64, err error) {
resMap = make(map[string]map[uint32]uint64)
for _, stat := range TCPSockStatMetrics {
resMap[metricUniqueID("sock", stat)] = map[uint32]uint64{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/probe/procsoftnet/procsoftnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func metricUniqueID(subject string, m string) string {
return fmt.Sprintf("%s%s", subject, strings.ToLower(m))
}

func collect(ctx context.Context, nslist []*nettop.Entity) (map[string]map[uint32]uint64, error) {
func collect(_ context.Context, nslist []*nettop.Entity) (map[string]map[uint32]uint64, error) {
resMap := make(map[string]map[uint32]uint64)

for idx := range SoftnetMetrics {
Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/probe/tracekernel/tracekernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (p *KernelLatencyProbe) GetMetricNames() []string {
return metrics
}

func (p *KernelLatencyProbe) Collect(ctx context.Context) (map[string]map[uint32]uint64, error) {
func (p *KernelLatencyProbe) Collect(_ context.Context) (map[string]map[uint32]uint64, error) {
return metricsMap, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (p *NetifTxlatencyProbe) GetMetricNames() []string {
return metrics
}

func (p *NetifTxlatencyProbe) Collect(ctx context.Context) (map[string]map[uint32]uint64, error) {
func (p *NetifTxlatencyProbe) Collect(_ context.Context) (map[string]map[uint32]uint64, error) {
ets := nettop.GetAllEntity()
resMap := map[string]map[uint32]uint64{}

Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/probe/tracenetsoftirq/tracenetsoftirq.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (p *NetSoftirqProbe) GetMetricNames() []string {
return metrics
}

func (p *NetSoftirqProbe) Collect(ctx context.Context) (map[string]map[uint32]uint64, error) {
func (p *NetSoftirqProbe) Collect(_ context.Context) (map[string]map[uint32]uint64, error) {

return metricsMap, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/probe/tracesocketlatency/socketlatency.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (p *SocketLatencyProbe) Start(ctx context.Context) {
p.startEventPoll(ctx)
}

func (p *SocketLatencyProbe) Collect(ctx context.Context) (map[string]map[uint32]uint64, error) {
func (p *SocketLatencyProbe) Collect(_ context.Context) (map[string]map[uint32]uint64, error) {
res := map[string]map[uint32]uint64{}
for _, mtr := range socketlatencyMetrics {
res[mtr] = map[uint32]uint64{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/probe/tracevirtcmdlat/tracevirtcmdlat.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (p *VirtcmdLatencyProbe) Close() error {
return nil
}

func (p *VirtcmdLatencyProbe) Collect(ctx context.Context) (map[string]map[uint32]uint64, error) {
func (p *VirtcmdLatencyProbe) Collect(_ context.Context) (map[string]map[uint32]uint64, error) {
return metricsMap, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/skoop/assertions/netstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (na *NetstackAssertion) AssertDefaultAccept() {
}
}

func (na *NetstackAssertion) checkNetfilterResult(verdict netstack.Verdict, err error) bool {
func (na *NetstackAssertion) checkNetfilterResult(_ netstack.Verdict, err error) bool {
if err != nil {
if err == netstack.ErrIPTablesUnsupported {
na.AddSuspicion(model.SuspicionLevelWarning,
Expand Down
5 changes: 1 addition & 4 deletions pkg/skoop/cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ func NewSkoopCmd() *cobra.Command {
if err := context.SkoopContext.BuildCluster(); err != nil {
return err
}
if err := context.SkoopContext.BuildTask(); err != nil {
return err
}
return nil
return context.SkoopContext.BuildTask()
},
RunE: func(cmd *cobra.Command, args []string) error {
prvd, err := provider.GetProvider(context.SkoopContext.ClusterConfig().CloudProvider)
Expand Down
2 changes: 1 addition & 1 deletion pkg/skoop/model/netnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type GenericNetNode struct {
NetNode *NetNode
}

func (n *GenericNetNode) Send(dst Endpoint, protocol Protocol) ([]Transmission, error) {
func (n *GenericNetNode) Send(_ Endpoint, _ Protocol) ([]Transmission, error) {
return nil, fmt.Errorf("non pod/node address as source is not supported")
}

Expand Down
Loading

0 comments on commit 65083d7

Please sign in to comment.