diff --git a/app/cmd/start.go b/app/cmd/start.go index 94dfe0127..bdf49ff42 100644 --- a/app/cmd/start.go +++ b/app/cmd/start.go @@ -3,7 +3,6 @@ package cmd import ( "context" "crypto/tls" - "fmt" "net" "net/http" _ "net/http/pprof" // for runtime profiling @@ -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) } }() diff --git a/pkg/proxy/backup.go b/pkg/proxy/backup.go index aadbc8077..29225019b 100644 --- a/pkg/proxy/backup.go +++ b/pkg/proxy/backup.go @@ -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 } @@ -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) @@ -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() @@ -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{ @@ -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{ @@ -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() @@ -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{ diff --git a/pkg/proxy/replica.go b/pkg/proxy/replica.go index f7d50b129..b78618554 100644 --- a/pkg/proxy/replica.go +++ b/pkg/proxy/replica.go @@ -73,7 +73,7 @@ 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() @@ -81,7 +81,7 @@ func (ops V2DataEngineProxyOps) ReplicaAdd(ctx context.Context, req *rpc.EngineR 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 } @@ -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() @@ -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{ @@ -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() @@ -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() diff --git a/pkg/proxy/snapshot.go b/pkg/proxy/snapshot.go index e8f7f5791..35dcb356e 100644 --- a/pkg/proxy/snapshot.go +++ b/pkg/proxy/snapshot.go @@ -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() @@ -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{ @@ -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 @@ -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() @@ -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() diff --git a/pkg/proxy/volume.go b/pkg/proxy/volume.go index fd62b8989..aa1637ab7 100644 --- a/pkg/proxy/volume.go +++ b/pkg/proxy/volume.go @@ -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" @@ -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{