Skip to content

Commit

Permalink
fix: pass ctx to all Call funcs
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Oct 9, 2023
1 parent 79f8951 commit a3b9b68
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 131 deletions.
28 changes: 14 additions & 14 deletions pkg/backend/aio.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func sortAioVolumes(volumes []*pb.AioVolume) {
}

// CreateAioVolume creates an Aio volume
func (s *Server) CreateAioVolume(_ context.Context, in *pb.CreateAioVolumeRequest) (*pb.AioVolume, error) {
func (s *Server) CreateAioVolume(ctx context.Context, in *pb.CreateAioVolumeRequest) (*pb.AioVolume, error) {
// check input correctness
if err := s.validateCreateAioVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -57,7 +57,7 @@ func (s *Server) CreateAioVolume(_ context.Context, in *pb.CreateAioVolumeReques
Filename: in.AioVolume.Filename,
}
var result spdk.BdevAioCreateResult
err := s.rpc.Call("bdev_aio_create", &params, &result)
err := s.rpc.Call(ctx, "bdev_aio_create", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -72,7 +72,7 @@ func (s *Server) CreateAioVolume(_ context.Context, in *pb.CreateAioVolumeReques
}

// DeleteAioVolume deletes an Aio volume
func (s *Server) DeleteAioVolume(_ context.Context, in *pb.DeleteAioVolumeRequest) (*emptypb.Empty, error) {
func (s *Server) DeleteAioVolume(ctx context.Context, in *pb.DeleteAioVolumeRequest) (*emptypb.Empty, error) {
// check input correctness
if err := s.validateDeleteAioVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -91,7 +91,7 @@ func (s *Server) DeleteAioVolume(_ context.Context, in *pb.DeleteAioVolumeReques
Name: resourceID,
}
var result spdk.BdevAioDeleteResult
err := s.rpc.Call("bdev_aio_delete", &params, &result)
err := s.rpc.Call(ctx, "bdev_aio_delete", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -105,7 +105,7 @@ func (s *Server) DeleteAioVolume(_ context.Context, in *pb.DeleteAioVolumeReques
}

// UpdateAioVolume updates an Aio volume
func (s *Server) UpdateAioVolume(_ context.Context, in *pb.UpdateAioVolumeRequest) (*pb.AioVolume, error) {
func (s *Server) UpdateAioVolume(ctx context.Context, in *pb.UpdateAioVolumeRequest) (*pb.AioVolume, error) {
// check input correctness
if err := s.validateUpdateAioVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -121,7 +121,7 @@ func (s *Server) UpdateAioVolume(_ context.Context, in *pb.UpdateAioVolumeReques
Filename: in.AioVolume.Filename,
}
var result spdk.BdevAioCreateResult
err := s.rpc.Call("bdev_aio_create", &params, &result)
err := s.rpc.Call(ctx, "bdev_aio_create", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -146,7 +146,7 @@ func (s *Server) UpdateAioVolume(_ context.Context, in *pb.UpdateAioVolumeReques
Name: resourceID,
}
var result1 spdk.BdevAioDeleteResult
err1 := s.rpc.Call("bdev_aio_delete", &params1, &result1)
err1 := s.rpc.Call(ctx, "bdev_aio_delete", &params1, &result1)
if err1 != nil {
return nil, err1
}
Expand All @@ -161,7 +161,7 @@ func (s *Server) UpdateAioVolume(_ context.Context, in *pb.UpdateAioVolumeReques
Filename: in.AioVolume.Filename,
}
var result2 spdk.BdevAioCreateResult
err2 := s.rpc.Call("bdev_aio_create", &params2, &result2)
err2 := s.rpc.Call(ctx, "bdev_aio_create", &params2, &result2)
if err2 != nil {
return nil, err2
}
Expand All @@ -176,7 +176,7 @@ func (s *Server) UpdateAioVolume(_ context.Context, in *pb.UpdateAioVolumeReques
}

// ListAioVolumes lists Aio volumes
func (s *Server) ListAioVolumes(_ context.Context, in *pb.ListAioVolumesRequest) (*pb.ListAioVolumesResponse, error) {
func (s *Server) ListAioVolumes(ctx context.Context, in *pb.ListAioVolumesRequest) (*pb.ListAioVolumesResponse, error) {
// check required fields
if err := fieldbehavior.ValidateRequiredFields(in); err != nil {
return nil, err
Expand All @@ -187,7 +187,7 @@ func (s *Server) ListAioVolumes(_ context.Context, in *pb.ListAioVolumesRequest)
return nil, perr
}
var result []spdk.BdevGetBdevsResult
err := s.rpc.Call("bdev_get_bdevs", nil, &result)
err := s.rpc.Call(ctx, "bdev_get_bdevs", nil, &result)
if err != nil {
return nil, err
}
Expand All @@ -209,7 +209,7 @@ func (s *Server) ListAioVolumes(_ context.Context, in *pb.ListAioVolumesRequest)
}

// GetAioVolume gets an Aio volume
func (s *Server) GetAioVolume(_ context.Context, in *pb.GetAioVolumeRequest) (*pb.AioVolume, error) {
func (s *Server) GetAioVolume(ctx context.Context, in *pb.GetAioVolumeRequest) (*pb.AioVolume, error) {
// check input correctness
if err := s.validateGetAioVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -225,7 +225,7 @@ func (s *Server) GetAioVolume(_ context.Context, in *pb.GetAioVolumeRequest) (*p
Name: resourceID,
}
var result []spdk.BdevGetBdevsResult
err := s.rpc.Call("bdev_get_bdevs", &params, &result)
err := s.rpc.Call(ctx, "bdev_get_bdevs", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -238,7 +238,7 @@ func (s *Server) GetAioVolume(_ context.Context, in *pb.GetAioVolumeRequest) (*p
}

// StatsAioVolume gets an Aio volume stats
func (s *Server) StatsAioVolume(_ context.Context, in *pb.StatsAioVolumeRequest) (*pb.StatsAioVolumeResponse, error) {
func (s *Server) StatsAioVolume(ctx context.Context, in *pb.StatsAioVolumeRequest) (*pb.StatsAioVolumeResponse, error) {
// check input correctness
if err := s.validateStatsAioVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -255,7 +255,7 @@ func (s *Server) StatsAioVolume(_ context.Context, in *pb.StatsAioVolumeRequest)
}
// See https://mholt.github.io/json-to-go/
var result spdk.BdevGetIostatResult
err := s.rpc.Call("bdev_get_iostat", &params, &result)
err := s.rpc.Call(ctx, "bdev_get_iostat", &params, &result)
if err != nil {
return nil, err
}
Expand Down
28 changes: 14 additions & 14 deletions pkg/backend/null.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func sortNullVolumes(volumes []*pb.NullVolume) {
}

// CreateNullVolume creates a Null volume instance
func (s *Server) CreateNullVolume(_ context.Context, in *pb.CreateNullVolumeRequest) (*pb.NullVolume, error) {
func (s *Server) CreateNullVolume(ctx context.Context, in *pb.CreateNullVolumeRequest) (*pb.NullVolume, error) {
// check input correctness
if err := s.validateCreateNullVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -58,7 +58,7 @@ func (s *Server) CreateNullVolume(_ context.Context, in *pb.CreateNullVolumeRequ
NumBlocks: 64,
}
var result spdk.BdevNullCreateResult
err := s.rpc.Call("bdev_null_create", &params, &result)
err := s.rpc.Call(ctx, "bdev_null_create", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -73,7 +73,7 @@ func (s *Server) CreateNullVolume(_ context.Context, in *pb.CreateNullVolumeRequ
}

// DeleteNullVolume deletes a Null volume instance
func (s *Server) DeleteNullVolume(_ context.Context, in *pb.DeleteNullVolumeRequest) (*emptypb.Empty, error) {
func (s *Server) DeleteNullVolume(ctx context.Context, in *pb.DeleteNullVolumeRequest) (*emptypb.Empty, error) {
// check input correctness
if err := s.validateDeleteNullVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -92,7 +92,7 @@ func (s *Server) DeleteNullVolume(_ context.Context, in *pb.DeleteNullVolumeRequ
Name: resourceID,
}
var result spdk.BdevNullDeleteResult
err := s.rpc.Call("bdev_null_delete", &params, &result)
err := s.rpc.Call(ctx, "bdev_null_delete", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -106,7 +106,7 @@ func (s *Server) DeleteNullVolume(_ context.Context, in *pb.DeleteNullVolumeRequ
}

// UpdateNullVolume updates a Null volume instance
func (s *Server) UpdateNullVolume(_ context.Context, in *pb.UpdateNullVolumeRequest) (*pb.NullVolume, error) {
func (s *Server) UpdateNullVolume(ctx context.Context, in *pb.UpdateNullVolumeRequest) (*pb.NullVolume, error) {
// check input correctness
if err := s.validateUpdateNullVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -122,7 +122,7 @@ func (s *Server) UpdateNullVolume(_ context.Context, in *pb.UpdateNullVolumeRequ
NumBlocks: 64,
}
var result spdk.BdevNullCreateResult
err := s.rpc.Call("bdev_null_create", &params, &result)
err := s.rpc.Call(ctx, "bdev_null_create", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -147,7 +147,7 @@ func (s *Server) UpdateNullVolume(_ context.Context, in *pb.UpdateNullVolumeRequ
Name: resourceID,
}
var result1 spdk.BdevNullDeleteResult
err1 := s.rpc.Call("bdev_null_delete", &params1, &result1)
err1 := s.rpc.Call(ctx, "bdev_null_delete", &params1, &result1)
if err1 != nil {
return nil, err1
}
Expand All @@ -162,7 +162,7 @@ func (s *Server) UpdateNullVolume(_ context.Context, in *pb.UpdateNullVolumeRequ
NumBlocks: 64,
}
var result2 spdk.BdevNullCreateResult
err2 := s.rpc.Call("bdev_null_create", &params2, &result2)
err2 := s.rpc.Call(ctx, "bdev_null_create", &params2, &result2)
if err2 != nil {
return nil, err2
}
Expand All @@ -177,7 +177,7 @@ func (s *Server) UpdateNullVolume(_ context.Context, in *pb.UpdateNullVolumeRequ
}

// ListNullVolumes lists Null volume instances
func (s *Server) ListNullVolumes(_ context.Context, in *pb.ListNullVolumesRequest) (*pb.ListNullVolumesResponse, error) {
func (s *Server) ListNullVolumes(ctx context.Context, in *pb.ListNullVolumesRequest) (*pb.ListNullVolumesResponse, error) {
// check required fields
if err := fieldbehavior.ValidateRequiredFields(in); err != nil {
return nil, err
Expand All @@ -188,7 +188,7 @@ func (s *Server) ListNullVolumes(_ context.Context, in *pb.ListNullVolumesReques
return nil, perr
}
var result []spdk.BdevGetBdevsResult
err := s.rpc.Call("bdev_get_bdevs", nil, &result)
err := s.rpc.Call(ctx, "bdev_get_bdevs", nil, &result)
if err != nil {
return nil, err
}
Expand All @@ -210,7 +210,7 @@ func (s *Server) ListNullVolumes(_ context.Context, in *pb.ListNullVolumesReques
}

// GetNullVolume gets a a Null volume instance
func (s *Server) GetNullVolume(_ context.Context, in *pb.GetNullVolumeRequest) (*pb.NullVolume, error) {
func (s *Server) GetNullVolume(ctx context.Context, in *pb.GetNullVolumeRequest) (*pb.NullVolume, error) {
// check input correctness
if err := s.validateGetNullVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -226,7 +226,7 @@ func (s *Server) GetNullVolume(_ context.Context, in *pb.GetNullVolumeRequest) (
Name: resourceID,
}
var result []spdk.BdevGetBdevsResult
err := s.rpc.Call("bdev_get_bdevs", &params, &result)
err := s.rpc.Call(ctx, "bdev_get_bdevs", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -239,7 +239,7 @@ func (s *Server) GetNullVolume(_ context.Context, in *pb.GetNullVolumeRequest) (
}

// StatsNullVolume gets a Null volume instance stats
func (s *Server) StatsNullVolume(_ context.Context, in *pb.StatsNullVolumeRequest) (*pb.StatsNullVolumeResponse, error) {
func (s *Server) StatsNullVolume(ctx context.Context, in *pb.StatsNullVolumeRequest) (*pb.StatsNullVolumeResponse, error) {
// check input correctness
if err := s.validateStatsNullVolumeRequest(in); err != nil {
return nil, err
Expand All @@ -256,7 +256,7 @@ func (s *Server) StatsNullVolume(_ context.Context, in *pb.StatsNullVolumeReques
}
// See https://mholt.github.io/json-to-go/
var result spdk.BdevGetIostatResult
err := s.rpc.Call("bdev_get_iostat", &params, &result)
err := s.rpc.Call(ctx, "bdev_get_iostat", &params, &result)
if err != nil {
return nil, err
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/backend/nvme_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func sortNvmePaths(paths []*pb.NvmePath) {
}

// CreateNvmePath creates a new Nvme path
func (s *Server) CreateNvmePath(_ context.Context, in *pb.CreateNvmePathRequest) (*pb.NvmePath, error) {
func (s *Server) CreateNvmePath(ctx context.Context, in *pb.CreateNvmePathRequest) (*pb.NvmePath, error) {
// check input correctness
if err := s.validateCreateNvmePathRequest(in); err != nil {
return nil, err
Expand Down Expand Up @@ -98,7 +98,7 @@ func (s *Server) CreateNvmePath(_ context.Context, in *pb.CreateNvmePathRequest)
Psk: psk,
}
var result []spdk.BdevNvmeAttachControllerResult
err := s.rpc.Call("bdev_nvme_attach_controller", &params, &result)
err := s.rpc.Call(ctx, "bdev_nvme_attach_controller", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -110,7 +110,7 @@ func (s *Server) CreateNvmePath(_ context.Context, in *pb.CreateNvmePathRequest)
}

// DeleteNvmePath deletes a Nvme path
func (s *Server) DeleteNvmePath(_ context.Context, in *pb.DeleteNvmePathRequest) (*emptypb.Empty, error) {
func (s *Server) DeleteNvmePath(ctx context.Context, in *pb.DeleteNvmePathRequest) (*emptypb.Empty, error) {
// check input correctness
if err := s.validateDeleteNvmePathRequest(in); err != nil {
return nil, err
Expand Down Expand Up @@ -139,7 +139,7 @@ func (s *Server) DeleteNvmePath(_ context.Context, in *pb.DeleteNvmePathRequest)
}

var result spdk.BdevNvmeDetachControllerResult
err := s.rpc.Call("bdev_nvme_detach_controller", &params, &result)
err := s.rpc.Call(ctx, "bdev_nvme_detach_controller", &params, &result)
if err != nil {
return nil, err
}
Expand All @@ -155,7 +155,7 @@ func (s *Server) DeleteNvmePath(_ context.Context, in *pb.DeleteNvmePathRequest)
}

// UpdateNvmePath updates an Nvme path
func (s *Server) UpdateNvmePath(_ context.Context, in *pb.UpdateNvmePathRequest) (*pb.NvmePath, error) {
func (s *Server) UpdateNvmePath(ctx context.Context, in *pb.UpdateNvmePathRequest) (*pb.NvmePath, error) {

Check warning on line 158 in pkg/backend/nvme_path.go

View workflow job for this annotation

GitHub Actions / call / golangci

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
// check input correctness
if err := s.validateUpdateNvmePathRequest(in); err != nil {
return nil, err
Expand All @@ -181,7 +181,7 @@ func (s *Server) UpdateNvmePath(_ context.Context, in *pb.UpdateNvmePathRequest)
}

// ListNvmePaths lists Nvme path
func (s *Server) ListNvmePaths(_ context.Context, in *pb.ListNvmePathsRequest) (*pb.ListNvmePathsResponse, error) {
func (s *Server) ListNvmePaths(ctx context.Context, in *pb.ListNvmePathsRequest) (*pb.ListNvmePathsResponse, error) {
// check required fields
if err := fieldbehavior.ValidateRequiredFields(in); err != nil {
return nil, err
Expand All @@ -192,7 +192,7 @@ func (s *Server) ListNvmePaths(_ context.Context, in *pb.ListNvmePathsRequest) (
return nil, perr
}
var result []spdk.BdevNvmeGetControllerResult
err := s.rpc.Call("bdev_nvme_get_controllers", nil, &result)
err := s.rpc.Call(ctx, "bdev_nvme_get_controllers", nil, &result)
if err != nil {
return nil, err
}
Expand All @@ -214,7 +214,7 @@ func (s *Server) ListNvmePaths(_ context.Context, in *pb.ListNvmePathsRequest) (
}

// GetNvmePath gets Nvme path
func (s *Server) GetNvmePath(_ context.Context, in *pb.GetNvmePathRequest) (*pb.NvmePath, error) {
func (s *Server) GetNvmePath(ctx context.Context, in *pb.GetNvmePathRequest) (*pb.NvmePath, error) {
// check input correctness
if err := s.validateGetNvmePathRequest(in); err != nil {
return nil, err
Expand All @@ -227,7 +227,7 @@ func (s *Server) GetNvmePath(_ context.Context, in *pb.GetNvmePathRequest) (*pb.
}

var result []spdk.BdevNvmeGetControllerResult
err := s.rpc.Call("bdev_nvme_get_controllers", nil, &result)
err := s.rpc.Call(ctx, "bdev_nvme_get_controllers", nil, &result)
if err != nil {
return nil, err
}
Expand All @@ -244,7 +244,7 @@ func (s *Server) GetNvmePath(_ context.Context, in *pb.GetNvmePathRequest) (*pb.
}

// StatsNvmePath gets Nvme path stats
func (s *Server) StatsNvmePath(_ context.Context, in *pb.StatsNvmePathRequest) (*pb.StatsNvmePathResponse, error) {
func (s *Server) StatsNvmePath(ctx context.Context, in *pb.StatsNvmePathRequest) (*pb.StatsNvmePathResponse, error) {
// check input correctness
if err := s.validateStatsNvmePathRequest(in); err != nil {
return nil, err
Expand All @@ -258,7 +258,7 @@ func (s *Server) StatsNvmePath(_ context.Context, in *pb.StatsNvmePathRequest) (
resourceID := path.Base(volume.Name)
log.Printf("TODO: send name to SPDK and get back stats: %v", resourceID)
var result spdk.NvmfGetSubsystemStatsResult
err := s.rpc.Call("nvmf_get_stats", nil, &result)
err := s.rpc.Call(ctx, "nvmf_get_stats", nil, &result)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit a3b9b68

Please sign in to comment.