Skip to content

Commit

Permalink
Merge pull request #1082 from marquiz/devel/golangci-lint
Browse files Browse the repository at this point in the history
Bump golangci-lint to v1.55.2
  • Loading branch information
klihub committed Jan 5, 2024
2 parents da26501 + 72f5096 commit e129402
Show file tree
Hide file tree
Showing 43 changed files with 190 additions and 194 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/common-verify-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
id: go

- name: Install golangci-lint
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2

- name: Gofmt
run: make format
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewResourceManagerAgent() (ResourceManagerAgent, error) {
return nil, agentError("failed to initialize gRPC server")
}

if a.updater, err = newConfigUpdater(opts.resmgrSocket); err != nil {
if a.updater, err = newConfigUpdater(); err != nil {
return nil, agentError("failed to initialize config updater instance: %v", err)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/config-updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type updater struct {
cfgErr error
}

func newConfigUpdater(socket string) (configUpdater, error) {
func newConfigUpdater() (configUpdater, error) {
u := &updater{Logger: log.NewLogger("config-updater")}

c, err := newResmgrCli(opts.resmgrSocket)
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func patchNodeStatus(cli *k8sclient.Clientset, fields map[string]string) error {
}

// patchAdjustmentStatus is a helper for patching the status of a Adjustment CRD.
func patchAdjustmentStatus(cli *resmgr.CriresmgrV1alpha1Client, status *resmgrStatus, names ...string) error {
func patchAdjustmentStatus(_ *resmgr.CriresmgrV1alpha1Client, _ *resmgrStatus, _ ...string) error {
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/agent/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ type grpcServer struct {
}

// GetNode gets K8s node object.
func (g *grpcServer) GetNode(ctx context.Context, req *v1.GetNodeRequest) (*v1.GetNodeReply, error) {
func (g *grpcServer) GetNode(_ context.Context, req *v1.GetNodeRequest) (*v1.GetNodeReply, error) {
g.Debug("received GetNodeRequest: %v", req)
rpl := &v1.GetNodeReply{}

Expand All @@ -129,7 +129,7 @@ func (g *grpcServer) GetNode(ctx context.Context, req *v1.GetNodeRequest) (*v1.G
}

// PatchNode patches the K8s node object.
func (g *grpcServer) PatchNode(ctx context.Context, req *v1.PatchNodeRequest) (*v1.PatchNodeReply, error) {
func (g *grpcServer) PatchNode(_ context.Context, req *v1.PatchNodeRequest) (*v1.PatchNodeReply, error) {
g.Debug("received PatchNodeRequest: %v", req)
rpl := &v1.PatchNodeReply{}

Expand All @@ -145,7 +145,7 @@ func (g *grpcServer) PatchNode(ctx context.Context, req *v1.PatchNodeRequest) (*
}

// UpdateNodeCapacity updates capacity in Node status
func (g *grpcServer) UpdateNodeCapacity(ctx context.Context, req *v1.UpdateNodeCapacityRequest) (*v1.UpdateNodeCapacityReply, error) {
func (g *grpcServer) UpdateNodeCapacity(_ context.Context, req *v1.UpdateNodeCapacityRequest) (*v1.UpdateNodeCapacityReply, error) {
g.Debug("received UpdateNodeCapacityRequest: %v", req)

rpl := &v1.UpdateNodeCapacityReply{}
Expand All @@ -172,7 +172,7 @@ func (g *grpcServer) UpdateNodeCapacity(ctx context.Context, req *v1.UpdateNodeC
}

// HealthCheck checks if the agent is in healthy state
func (g *grpcServer) HealthCheck(ctx context.Context, req *v1.HealthCheckRequest) (*v1.HealthCheckReply, error) {
func (g *grpcServer) HealthCheck(_ context.Context, req *v1.HealthCheckRequest) (*v1.HealthCheckReply, error) {
g.Debug("received HealthCheckRequest: %v", req)

reply := &v1.HealthCheckReply{}
Expand Down
8 changes: 4 additions & 4 deletions pkg/cgroups/cgroupblkio.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,18 @@ func ResetBlkioParameters(cgroupsDir string, blockIO OciBlockIOParameters) error

// resetDevRates adds wanted rate parameters to new and resets unwated rates
func resetDevRates(old, wanted []OciDeviceRate) []OciDeviceRate {
new := []OciDeviceRate{}
rates := []OciDeviceRate{}
seenDev := map[devMajMin]bool{}
for _, rdp := range wanted {
new = append(new, rdp)
rates = append(rates, rdp)
seenDev[devMajMin{rdp.Major, rdp.Minor}] = true
}
for _, rdp := range old {
if !seenDev[devMajMin{rdp.Major, rdp.Minor}] {
new = append(new, OciDeviceRate{rdp.Major, rdp.Minor, 0})
rates = append(rates, OciDeviceRate{rdp.Major, rdp.Minor, 0})
}
}
return new
return rates
}

// GetBlkioParameters returns OCI BlockIO parameters from files in cgroups blkio controller directory.
Expand Down
5 changes: 2 additions & 3 deletions pkg/cgroups/cgroupid.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ func (cgid *CgroupID) Find(id uint64) (string, error) {
return "", err
} else if !found {
return "", fmt.Errorf("cgroupid %v not found", id)
} else {
cgid.cache[id] = p
return p, nil
}
cgid.cache[id] = p
return p, nil
}
66 changes: 33 additions & 33 deletions pkg/cri/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,191 +254,191 @@ func (c *client) dialNotify(socket string) {
c.options.DialNotify(socket, uid, gid, mode, nil)
}

func (c *client) Version(ctx context.Context, in *criv1.VersionRequest, opts ...grpc.CallOption) (*criv1.VersionResponse, error) {
func (c *client) Version(ctx context.Context, in *criv1.VersionRequest, _ ...grpc.CallOption) (*criv1.VersionResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.Version(ctx, in)
}

func (c *client) RunPodSandbox(ctx context.Context, in *criv1.RunPodSandboxRequest, opts ...grpc.CallOption) (*criv1.RunPodSandboxResponse, error) {
func (c *client) RunPodSandbox(ctx context.Context, in *criv1.RunPodSandboxRequest, _ ...grpc.CallOption) (*criv1.RunPodSandboxResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.RunPodSandbox(ctx, in)
}

func (c *client) StopPodSandbox(ctx context.Context, in *criv1.StopPodSandboxRequest, opts ...grpc.CallOption) (*criv1.StopPodSandboxResponse, error) {
func (c *client) StopPodSandbox(ctx context.Context, in *criv1.StopPodSandboxRequest, _ ...grpc.CallOption) (*criv1.StopPodSandboxResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.StopPodSandbox(ctx, in)
}

func (c *client) RemovePodSandbox(ctx context.Context, in *criv1.RemovePodSandboxRequest, opts ...grpc.CallOption) (*criv1.RemovePodSandboxResponse, error) {
func (c *client) RemovePodSandbox(ctx context.Context, in *criv1.RemovePodSandboxRequest, _ ...grpc.CallOption) (*criv1.RemovePodSandboxResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.RemovePodSandbox(ctx, in)
}

func (c *client) PodSandboxStatus(ctx context.Context, in *criv1.PodSandboxStatusRequest, opts ...grpc.CallOption) (*criv1.PodSandboxStatusResponse, error) {
func (c *client) PodSandboxStatus(ctx context.Context, in *criv1.PodSandboxStatusRequest, _ ...grpc.CallOption) (*criv1.PodSandboxStatusResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.PodSandboxStatus(ctx, in)
}

func (c *client) ListPodSandbox(ctx context.Context, in *criv1.ListPodSandboxRequest, opts ...grpc.CallOption) (*criv1.ListPodSandboxResponse, error) {
func (c *client) ListPodSandbox(ctx context.Context, in *criv1.ListPodSandboxRequest, _ ...grpc.CallOption) (*criv1.ListPodSandboxResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.ListPodSandbox(ctx, in)
}

func (c *client) CreateContainer(ctx context.Context, in *criv1.CreateContainerRequest, opts ...grpc.CallOption) (*criv1.CreateContainerResponse, error) {
func (c *client) CreateContainer(ctx context.Context, in *criv1.CreateContainerRequest, _ ...grpc.CallOption) (*criv1.CreateContainerResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.CreateContainer(ctx, in)
}

func (c *client) StartContainer(ctx context.Context, in *criv1.StartContainerRequest, opts ...grpc.CallOption) (*criv1.StartContainerResponse, error) {
func (c *client) StartContainer(ctx context.Context, in *criv1.StartContainerRequest, _ ...grpc.CallOption) (*criv1.StartContainerResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.StartContainer(ctx, in)
}

func (c *client) StopContainer(ctx context.Context, in *criv1.StopContainerRequest, opts ...grpc.CallOption) (*criv1.StopContainerResponse, error) {
func (c *client) StopContainer(ctx context.Context, in *criv1.StopContainerRequest, _ ...grpc.CallOption) (*criv1.StopContainerResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.StopContainer(ctx, in)
}

func (c *client) RemoveContainer(ctx context.Context, in *criv1.RemoveContainerRequest, opts ...grpc.CallOption) (*criv1.RemoveContainerResponse, error) {
func (c *client) RemoveContainer(ctx context.Context, in *criv1.RemoveContainerRequest, _ ...grpc.CallOption) (*criv1.RemoveContainerResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.RemoveContainer(ctx, in)
}

func (c *client) ListContainers(ctx context.Context, in *criv1.ListContainersRequest, opts ...grpc.CallOption) (*criv1.ListContainersResponse, error) {
func (c *client) ListContainers(ctx context.Context, in *criv1.ListContainersRequest, _ ...grpc.CallOption) (*criv1.ListContainersResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.ListContainers(ctx, in)
}

func (c *client) ContainerStatus(ctx context.Context, in *criv1.ContainerStatusRequest, opts ...grpc.CallOption) (*criv1.ContainerStatusResponse, error) {
func (c *client) ContainerStatus(ctx context.Context, in *criv1.ContainerStatusRequest, _ ...grpc.CallOption) (*criv1.ContainerStatusResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.ContainerStatus(ctx, in)
}

func (c *client) UpdateContainerResources(ctx context.Context, in *criv1.UpdateContainerResourcesRequest, opts ...grpc.CallOption) (*criv1.UpdateContainerResourcesResponse, error) {
func (c *client) UpdateContainerResources(ctx context.Context, in *criv1.UpdateContainerResourcesRequest, _ ...grpc.CallOption) (*criv1.UpdateContainerResourcesResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.UpdateContainerResources(ctx, in)
}

func (c *client) ReopenContainerLog(ctx context.Context, in *criv1.ReopenContainerLogRequest, opts ...grpc.CallOption) (*criv1.ReopenContainerLogResponse, error) {
func (c *client) ReopenContainerLog(ctx context.Context, in *criv1.ReopenContainerLogRequest, _ ...grpc.CallOption) (*criv1.ReopenContainerLogResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.ReopenContainerLog(ctx, in)
}

func (c *client) ExecSync(ctx context.Context, in *criv1.ExecSyncRequest, opts ...grpc.CallOption) (*criv1.ExecSyncResponse, error) {
func (c *client) ExecSync(ctx context.Context, in *criv1.ExecSyncRequest, _ ...grpc.CallOption) (*criv1.ExecSyncResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.ExecSync(ctx, in)
}

func (c *client) Exec(ctx context.Context, in *criv1.ExecRequest, opts ...grpc.CallOption) (*criv1.ExecResponse, error) {
func (c *client) Exec(ctx context.Context, in *criv1.ExecRequest, _ ...grpc.CallOption) (*criv1.ExecResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.Exec(ctx, in)
}

func (c *client) Attach(ctx context.Context, in *criv1.AttachRequest, opts ...grpc.CallOption) (*criv1.AttachResponse, error) {
func (c *client) Attach(ctx context.Context, in *criv1.AttachRequest, _ ...grpc.CallOption) (*criv1.AttachResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.Attach(ctx, in)
}

func (c *client) PortForward(ctx context.Context, in *criv1.PortForwardRequest, opts ...grpc.CallOption) (*criv1.PortForwardResponse, error) {
func (c *client) PortForward(ctx context.Context, in *criv1.PortForwardRequest, _ ...grpc.CallOption) (*criv1.PortForwardResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.PortForward(ctx, in)
}

func (c *client) ContainerStats(ctx context.Context, in *criv1.ContainerStatsRequest, opts ...grpc.CallOption) (*criv1.ContainerStatsResponse, error) {
func (c *client) ContainerStats(ctx context.Context, in *criv1.ContainerStatsRequest, _ ...grpc.CallOption) (*criv1.ContainerStatsResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.ContainerStats(ctx, in)
}

func (c *client) ListContainerStats(ctx context.Context, in *criv1.ListContainerStatsRequest, opts ...grpc.CallOption) (*criv1.ListContainerStatsResponse, error) {
func (c *client) ListContainerStats(ctx context.Context, in *criv1.ListContainerStatsRequest, _ ...grpc.CallOption) (*criv1.ListContainerStatsResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.ListContainerStats(ctx, in)
}

func (c *client) PodSandboxStats(ctx context.Context, in *criv1.PodSandboxStatsRequest, opts ...grpc.CallOption) (*criv1.PodSandboxStatsResponse, error) {
func (c *client) PodSandboxStats(ctx context.Context, in *criv1.PodSandboxStatsRequest, _ ...grpc.CallOption) (*criv1.PodSandboxStatsResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.PodSandboxStats(ctx, in)
}

func (c *client) ListPodSandboxStats(ctx context.Context, in *criv1.ListPodSandboxStatsRequest, opts ...grpc.CallOption) (*criv1.ListPodSandboxStatsResponse, error) {
func (c *client) ListPodSandboxStats(ctx context.Context, in *criv1.ListPodSandboxStatsRequest, _ ...grpc.CallOption) (*criv1.ListPodSandboxStatsResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.ListPodSandboxStats(ctx, in)
}

func (c *client) UpdateRuntimeConfig(ctx context.Context, in *criv1.UpdateRuntimeConfigRequest, opts ...grpc.CallOption) (*criv1.UpdateRuntimeConfigResponse, error) {
func (c *client) UpdateRuntimeConfig(ctx context.Context, in *criv1.UpdateRuntimeConfigRequest, _ ...grpc.CallOption) (*criv1.UpdateRuntimeConfigResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}

return c.client.UpdateRuntimeConfig(ctx, in)
}

func (c *client) Status(ctx context.Context, in *criv1.StatusRequest, opts ...grpc.CallOption) (*criv1.StatusResponse, error) {
func (c *client) Status(ctx context.Context, in *criv1.StatusRequest, _ ...grpc.CallOption) (*criv1.StatusResponse, error) {
if err := c.checkRuntimeService(); err != nil {
return nil, err
}
Expand All @@ -447,56 +447,56 @@ func (c *client) Status(ctx context.Context, in *criv1.StatusRequest, opts ...gr
}

/*
func (c *client) CheckpointContainer(ctx context.Context, in *criv1.CheckpointContainerRequest, opts ...grpc.CallOption) (*criv1.CheckpointContainerResponse, error) {
func (c *client) CheckpointContainer(ctx context.Context, in *criv1.CheckpointContainerRequest, _ ...grpc.CallOption) (*criv1.CheckpointContainerResponse, error) {
return nil, fmt.Errorf("unimplemented by CRI RuntimeService")
}
func (c *client) GetContainerEvents(ctx context.Context, in *criv1.GetContainerEventsRequest, opts ...grpc.CallOption) (criv1.RuntimeService_GetContainerEventsClient, error) {
func (c *client) GetContainerEvents(ctx context.Context, in *criv1.GetContainerEventsRequest, _ ...grpc.CallOption) (criv1.RuntimeService_GetContainerEventsClient, error) {
return nil, fmt.Errorf("unimplemented by CRI RuntimeService")
}
func (c *client) ListMetricDescriptors(ctx context.Context, in *criv1.ListMetricDescriptorsRequest, opts ...grpc.CallOption) (*criv1.ListMetricDescriptorsResponse, error) {
func (c *client) ListMetricDescriptors(ctx context.Context, in *criv1.ListMetricDescriptorsRequest, _ ...grpc.CallOption) (*criv1.ListMetricDescriptorsResponse, error) {
return nil, fmt.Errorf("unimplemented by CRI RuntimeService")
}
func (c *client) ListPodSandboxMetrics(ctx context.Context, in *criv1.ListPodSandboxMetricsRequest, opts ...grpc.CallOption) (*criv1.ListPodSandboxMetricsResponse, error) {
func (c *client) ListPodSandboxMetrics(ctx context.Context, in *criv1.ListPodSandboxMetricsRequest, _ ...grpc.CallOption) (*criv1.ListPodSandboxMetricsResponse, error) {
return nil, fmt.Errorf("unimplemented by CRI RuntimeService")
}
*/

func (c *client) ListImages(ctx context.Context, in *criv1.ListImagesRequest, opts ...grpc.CallOption) (*criv1.ListImagesResponse, error) {
func (c *client) ListImages(ctx context.Context, in *criv1.ListImagesRequest, _ ...grpc.CallOption) (*criv1.ListImagesResponse, error) {
if err := c.checkImageService(); err != nil {
return nil, err
}

return c.client.ListImages(ctx, in)
}

func (c *client) ImageStatus(ctx context.Context, in *criv1.ImageStatusRequest, opts ...grpc.CallOption) (*criv1.ImageStatusResponse, error) {
func (c *client) ImageStatus(ctx context.Context, in *criv1.ImageStatusRequest, _ ...grpc.CallOption) (*criv1.ImageStatusResponse, error) {
if err := c.checkImageService(); err != nil {
return nil, err
}

return c.client.ImageStatus(ctx, in)
}

func (c *client) PullImage(ctx context.Context, in *criv1.PullImageRequest, opts ...grpc.CallOption) (*criv1.PullImageResponse, error) {
func (c *client) PullImage(ctx context.Context, in *criv1.PullImageRequest, _ ...grpc.CallOption) (*criv1.PullImageResponse, error) {
if err := c.checkImageService(); err != nil {
return nil, err
}

return c.client.PullImage(ctx, in)
}

func (c *client) RemoveImage(ctx context.Context, in *criv1.RemoveImageRequest, opts ...grpc.CallOption) (*criv1.RemoveImageResponse, error) {
func (c *client) RemoveImage(ctx context.Context, in *criv1.RemoveImageRequest, _ ...grpc.CallOption) (*criv1.RemoveImageResponse, error) {
if err := c.checkImageService(); err != nil {
return nil, err
}

return c.client.RemoveImage(ctx, in)
}

func (c *client) ImageFsInfo(ctx context.Context, in *criv1.ImageFsInfoRequest, opts ...grpc.CallOption) (*criv1.ImageFsInfoResponse, error) {
func (c *client) ImageFsInfo(ctx context.Context, in *criv1.ImageFsInfoRequest, _ ...grpc.CallOption) (*criv1.ImageFsInfoResponse, error) {
if err := c.checkImageService(); err != nil {
return nil, err
}
Expand Down

0 comments on commit e129402

Please sign in to comment.