Skip to content

Commit

Permalink
fix: non-constant format string in call to ...
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit authored and mergify[bot] committed Sep 8, 2024
1 parent 16ad6a9 commit 1f4d35d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 27 deletions.
3 changes: 1 addition & 2 deletions app/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"context"
"crypto/tls"
"fmt"
"net"
"net/http"
_ "net/http/pprof" // for runtime profiling
Expand Down Expand Up @@ -189,7 +188,7 @@ func start(c *cli.Context) (err error) {
debugHandler := http.DefaultServeMux
logrus.Infof("Debug pprof server listening on %s", debugAddress)
if err := http.ListenAndServe(debugAddress, debugHandler); err != nil && err != http.ErrServerClosed {
logrus.Errorf(fmt.Sprintf("ListenAndServe: %s", err))
logrus.Errorf("ListenAndServe: %s", err)
}
}()

Expand Down
18 changes: 9 additions & 9 deletions pkg/proxy/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

func (p *Proxy) CleanupBackupMountPoints(ctx context.Context, req *emptypb.Empty) (resp *emptypb.Empty, err error) {
if err := backupstore.CleanUpAllMounts(); err != nil {
return &emptypb.Empty{}, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to unmount all mount points").Error())
return &emptypb.Empty{}, grpcstatus.Errorf(grpccodes.Internal, "failed to unmount all mount points: %v", err)
}
return &emptypb.Empty{}, nil
}
Expand All @@ -48,7 +48,7 @@ func (p *Proxy) SnapshotBackup(ctx context.Context, req *rpc.EngineSnapshotBacku

credential, err := butil.GetBackupCredential(req.BackupTarget)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, errors.Wrapf(err, "failed to get backup credential").Error())
return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, "failed to get backup credential: %v", err)
}

labels := getLabels(req.Labels)
Expand Down Expand Up @@ -93,7 +93,7 @@ func (ops V1DataEngineProxyOps) SnapshotBackup(ctx context.Context, req *rpc.Eng
func (ops V2DataEngineProxyOps) SnapshotBackup(ctx context.Context, req *rpc.EngineSnapshotBackupRequest, credential map[string]string, labels []string) (resp *rpc.EngineSnapshotBackupProxyResponse, err error) {
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.ProxyEngineRequest.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.ProxyEngineRequest.Address, err)
}
defer c.Close()

Expand Down Expand Up @@ -223,13 +223,13 @@ func (ops V1DataEngineProxyOps) SnapshotBackupStatus(ctx context.Context, req *r
func (ops V2DataEngineProxyOps) SnapshotBackupStatus(ctx context.Context, req *rpc.EngineSnapshotBackupStatusRequest) (resp *rpc.EngineSnapshotBackupStatusProxyResponse, err error) {
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.ProxyEngineRequest.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.ProxyEngineRequest.Address, err)
}
defer c.Close()

status, err := c.EngineBackupStatus(req.BackupName, req.ProxyEngineRequest.EngineName, req.ReplicaAddress)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get backup status").Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get backup status: %v", err)
}

return &rpc.EngineSnapshotBackupStatusProxyResponse{
Expand Down Expand Up @@ -257,7 +257,7 @@ func (p *Proxy) BackupRestore(ctx context.Context, req *rpc.EngineBackupRestoreR

credential, err := butil.GetBackupCredential(req.Target)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, errors.Wrapf(err, "failed to get backup credential").Error())
return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, "failed to get backup credential: %v", err)
}

resp = &rpc.EngineBackupRestoreProxyResponse{
Expand Down Expand Up @@ -297,7 +297,7 @@ func (ops V1DataEngineProxyOps) BackupRestore(ctx context.Context, req *rpc.Engi
func (ops V2DataEngineProxyOps) BackupRestore(ctx context.Context, req *rpc.EngineBackupRestoreRequest, credential map[string]string) error {
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
if err != nil {
return grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.ProxyEngineRequest.Address).Error())
return grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.ProxyEngineRequest.Address, err)
}
defer c.Close()

Expand Down Expand Up @@ -358,13 +358,13 @@ func (ops V1DataEngineProxyOps) BackupRestoreStatus(ctx context.Context, req *rp
func (ops V2DataEngineProxyOps) BackupRestoreStatus(ctx context.Context, req *rpc.ProxyEngineRequest) (resp *rpc.EngineBackupRestoreStatusProxyResponse, err error) {
c, err := getSPDKClientFromAddress(req.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.Address, err)
}
defer c.Close()

recv, err := c.EngineRestoreStatus(req.EngineName)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get restore status").Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get restore status: %v", err)
}

resp = &rpc.EngineBackupRestoreStatusProxyResponse{
Expand Down
14 changes: 7 additions & 7 deletions pkg/proxy/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ func (ops V1DataEngineProxyOps) ReplicaAdd(ctx context.Context, req *rpc.EngineR
func (ops V2DataEngineProxyOps) ReplicaAdd(ctx context.Context, req *rpc.EngineReplicaAddRequest) (resp *emptypb.Empty, err error) {
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.ProxyEngineRequest.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.ProxyEngineRequest.Address, err)
}
defer c.Close()

replicaAddress := strings.TrimPrefix(req.ReplicaAddress, "tcp://")

err = c.EngineReplicaAdd(req.ProxyEngineRequest.EngineName, req.ReplicaName, replicaAddress)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to add replica %v", replicaAddress).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to add replica %v: %v", replicaAddress, err)
}
return &emptypb.Empty{}, nil
}
Expand Down Expand Up @@ -147,7 +147,7 @@ func replicaModeToGRPCReplicaMode(mode spdktypes.Mode) enginerpc.ReplicaMode {
func (ops V2DataEngineProxyOps) ReplicaList(ctx context.Context, req *rpc.ProxyEngineRequest) (resp *rpc.EngineReplicaListProxyResponse, err error) {
c, err := getSPDKClientFromAddress(req.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.Address, err)
}
defer c.Close()

Expand Down Expand Up @@ -224,13 +224,13 @@ func (ops V1DataEngineProxyOps) ReplicaRebuildingStatus(ctx context.Context, req
func (ops V2DataEngineProxyOps) ReplicaRebuildingStatus(ctx context.Context, req *rpc.ProxyEngineRequest) (resp *rpc.EngineReplicaRebuildStatusProxyResponse, err error) {
engineCli, err := getSPDKClientFromAddress(req.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.Address, err)
}
defer engineCli.Close()

e, err := engineCli.EngineGet(req.EngineName)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get engine %v", req.EngineName).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get engine %v: %v", req.EngineName, err)
}

resp = &rpc.EngineReplicaRebuildStatusProxyResponse{
Expand All @@ -248,7 +248,7 @@ func (ops V2DataEngineProxyOps) ReplicaRebuildingStatus(ctx context.Context, req
tcpReplicaAddress := types.AddTcpPrefixForAddress(replicaAddress)
replicaCli, err := getSPDKClientFromAddress(replicaAddress)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from replica address %v", replicaAddress).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from replica address %v: %v", replicaAddress, err)
}
defer replicaCli.Close()

Expand Down Expand Up @@ -335,7 +335,7 @@ func (ops V1DataEngineProxyOps) ReplicaRemove(ctx context.Context, req *rpc.Engi
func (ops V2DataEngineProxyOps) ReplicaRemove(ctx context.Context, req *rpc.EngineReplicaRemoveRequest) (*emptypb.Empty, error) {
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.ProxyEngineRequest.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.ProxyEngineRequest.Address, err)
}
defer c.Close()

Expand Down
12 changes: 6 additions & 6 deletions pkg/proxy/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (ops V1DataEngineProxyOps) VolumeSnapshot(ctx context.Context, req *rpc.Eng
func (ops V2DataEngineProxyOps) VolumeSnapshot(ctx context.Context, req *rpc.EngineVolumeSnapshotRequest) (resp *rpc.EngineVolumeSnapshotProxyResponse, err error) {
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.ProxyEngineRequest.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.ProxyEngineRequest.Address, err)
}
defer c.Close()

Expand All @@ -67,7 +67,7 @@ func (ops V2DataEngineProxyOps) VolumeSnapshot(ctx context.Context, req *rpc.Eng

_, err = c.EngineSnapshotCreate(req.ProxyEngineRequest.EngineName, snapshotName)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to create snapshot %v", snapshotName).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to create snapshot %v: %v", snapshotName, err)
}
return &rpc.EngineVolumeSnapshotProxyResponse{
Snapshot: &enginerpc.VolumeSnapshotReply{
Expand Down Expand Up @@ -299,13 +299,13 @@ func (ops V1DataEngineProxyOps) SnapshotRevert(ctx context.Context, req *rpc.Eng
func (ops V2DataEngineProxyOps) SnapshotRevert(ctx context.Context, req *rpc.EngineSnapshotRevertRequest) (resp *emptypb.Empty, err error) {
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.ProxyEngineRequest.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.ProxyEngineRequest.Address, err)
}
defer c.Close()

err = c.EngineSnapshotRevert(req.ProxyEngineRequest.EngineName, req.Name)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to create snapshot %v", req.Name).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to create snapshot %v: %v", req.Name, err)
}

return &emptypb.Empty{}, nil
Expand Down Expand Up @@ -344,7 +344,7 @@ func (ops V1DataEngineProxyOps) SnapshotPurge(ctx context.Context, req *rpc.Engi
func (ops V2DataEngineProxyOps) SnapshotPurge(ctx context.Context, req *rpc.EngineSnapshotPurgeRequest) (resp *emptypb.Empty, err error) {
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.ProxyEngineRequest.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.ProxyEngineRequest.Address, err)
}
defer c.Close()

Expand Down Expand Up @@ -441,7 +441,7 @@ func (ops V1DataEngineProxyOps) SnapshotRemove(ctx context.Context, req *rpc.Eng
func (ops V2DataEngineProxyOps) SnapshotRemove(ctx context.Context, req *rpc.EngineSnapshotRemoveRequest) (resp *emptypb.Empty, err error) {
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.ProxyEngineRequest.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.ProxyEngineRequest.Address, err)
}
defer c.Close()

Expand Down
5 changes: 2 additions & 3 deletions pkg/proxy/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
eclient "github.com/longhorn/longhorn-engine/pkg/controller/client"
"github.com/longhorn/types/pkg/generated/enginerpc"
rpc "github.com/longhorn/types/pkg/generated/imrpc"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
grpccodes "google.golang.org/grpc/codes"
Expand Down Expand Up @@ -68,13 +67,13 @@ func (ops V1DataEngineProxyOps) VolumeGet(ctx context.Context, req *rpc.ProxyEng
func (ops V2DataEngineProxyOps) VolumeGet(ctx context.Context, req *rpc.ProxyEngineRequest) (resp *rpc.EngineVolumeGetProxyResponse, err error) {
c, err := getSPDKClientFromAddress(req.Address)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get SPDK client from engine address %v", req.Address).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get SPDK client from engine address %v: %v", req.Address, err)
}
defer c.Close()

recv, err := c.EngineGet(req.EngineName)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get engine %v", req.EngineName).Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get engine %v: %v", req.EngineName, err)
}

return &rpc.EngineVolumeGetProxyResponse{
Expand Down

0 comments on commit 1f4d35d

Please sign in to comment.