diff --git a/pkg/spdk/disk.go b/pkg/spdk/disk.go index 32952493..c84cf722 100644 --- a/pkg/spdk/disk.go +++ b/pkg/spdk/disk.go @@ -150,7 +150,7 @@ func svcDiskGet(spdkClient *spdkclient.Client, diskName, diskPath, diskDriver st bdevs, err := disk.DiskGet(spdkClient, diskName, diskPath, diskDriver, 0) if err != nil { if !jsonrpc.IsJSONRPCRespErrorNoSuchDevice(err) { - return nil, grpcstatus.Errorf(grpccodes.Internal, errors.Wrapf(err, "failed to get bdev with name %v", diskName).Error()) + return nil, grpcstatus.Errorf(grpccodes.Internal, "failed to get bdev with name %v: %v", diskName, err) } } if len(bdevs) == 0 { @@ -184,7 +184,7 @@ func svcDiskGet(spdkClient *spdkclient.Client, diskName, diskPath, diskDriver st } if targetBdev == nil { - return nil, grpcstatus.Errorf(grpccodes.NotFound, errors.Wrapf(err, "failed to get disk bdev for disk %v", diskName).Error()) + return nil, grpcstatus.Errorf(grpccodes.NotFound, "failed to get disk bdev for disk %v: %v", diskName, err) } return lvstoreToDisk(spdkClient, diskPath, targetBdev.Name, "", exactDiskDriver) diff --git a/pkg/spdk/engine.go b/pkg/spdk/engine.go index 0b16d556..8146a1a2 100644 --- a/pkg/spdk/engine.go +++ b/pkg/spdk/engine.go @@ -1662,7 +1662,7 @@ func (e *Engine) BackupCreate(backupName, volumeName, engineName, snapshotName, replicaServiceCli, err := GetServiceClient(replicaAddress) if err != nil { - return nil, grpcstatus.Errorf(grpccodes.Internal, err.Error()) + return nil, grpcstatus.Errorf(grpccodes.Internal, "%v", err) } defer func() { if errClose := replicaServiceCli.Close(); errClose != nil { @@ -1711,12 +1711,12 @@ func (e *Engine) BackupStatus(backupName, replicaAddress string) (*spdkrpc.Backu } if !found { - return nil, grpcstatus.Errorf(grpccodes.NotFound, fmt.Sprintf("replica address %s is not found in engine %s for getting backup %v status", replicaAddress, e.Name, backupName)) + return nil, grpcstatus.Errorf(grpccodes.NotFound, "replica address %s is not found in engine %s for getting backup %v status", replicaAddress, e.Name, backupName) } replicaServiceCli, err := GetServiceClient(replicaAddress) if err != nil { - return nil, grpcstatus.Errorf(grpccodes.Internal, err.Error()) + return nil, grpcstatus.Errorf(grpccodes.Internal, "%v", err) } defer func() { if errClose := replicaServiceCli.Close(); errClose != nil { diff --git a/pkg/spdk/replica.go b/pkg/spdk/replica.go index 8fbc0463..387f6770 100644 --- a/pkg/spdk/replica.go +++ b/pkg/spdk/replica.go @@ -1891,19 +1891,19 @@ func (r *Replica) BackupRestore(spdkClient *spdkclient.Client, backupUrl, snapsh backupType, err := butil.CheckBackupType(backupUrl) if err != nil { err = errors.Wrapf(err, "failed to check the type for restoring backup %v", backupUrl) - return grpcstatus.Errorf(grpccodes.InvalidArgument, err.Error()) + return grpcstatus.Errorf(grpccodes.InvalidArgument, "%v", err) } err = butil.SetupCredential(backupType, credential) if err != nil { err = errors.Wrapf(err, "failed to setup credential for restoring backup %v", backupUrl) - return grpcstatus.Errorf(grpccodes.Internal, err.Error()) + return grpcstatus.Errorf(grpccodes.Internal, "%v", err) } backupName, _, _, err := backupstore.DecodeBackupURL(util.UnescapeURL(backupUrl)) if err != nil { err = errors.Wrapf(err, "failed to decode backup url %v", backupUrl) - return grpcstatus.Errorf(grpccodes.InvalidArgument, err.Error()) + return grpcstatus.Errorf(grpccodes.InvalidArgument, "%v", err) } if r.restore == nil { @@ -1927,7 +1927,7 @@ func (r *Replica) BackupRestore(spdkClient *spdkclient.Client, backupUrl, snapsh r.restore, err = NewRestore(spdkClient, lvolName, snapshotName, backupUrl, backupName, r) if err != nil { err = errors.Wrap(err, "failed to start new restore") - return grpcstatus.Errorf(grpccodes.Internal, err.Error()) + return grpcstatus.Errorf(grpccodes.Internal, "%v", err) } } else { r.log.Infof("Resetting the restore for backup %v", backupUrl) diff --git a/pkg/spdk/server.go b/pkg/spdk/server.go index cae62835..7d0b2658 100644 --- a/pkg/spdk/server.go +++ b/pkg/spdk/server.go @@ -1228,7 +1228,7 @@ func (s *Server) ReplicaBackupCreate(ctx context.Context, req *spdkrpc.BackupCre err = butil.SetupCredential(backupType, req.Credential) if err != nil { err = errors.Wrapf(err, "failed to setup credential of backup target %v for backup %v", req.BackupTarget, backupName) - return nil, grpcstatus.Errorf(grpccodes.Internal, err.Error()) + return nil, grpcstatus.Errorf(grpccodes.Internal, "%v", err) } var labelMap map[string]string @@ -1236,7 +1236,7 @@ func (s *Server) ReplicaBackupCreate(ctx context.Context, req *spdkrpc.BackupCre labelMap, err = util.ParseLabels(req.Labels) if err != nil { err = errors.Wrapf(err, "failed to parse backup labels for backup %v", backupName) - return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, err.Error()) + return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, "%v", err) } } @@ -1255,7 +1255,7 @@ func (s *Server) ReplicaBackupCreate(ctx context.Context, req *spdkrpc.BackupCre backup, err := NewBackup(s.spdkClient, backupName, req.VolumeName, req.SnapshotName, replica, s.portAllocator) if err != nil { err = errors.Wrapf(err, "failed to create backup instance %v for volume %v", backupName, req.VolumeName) - return nil, grpcstatus.Errorf(grpccodes.Internal, err.Error()) + return nil, grpcstatus.Errorf(grpccodes.Internal, "%v", err) } config := &backupstore.DeltaBackupConfig{ @@ -1285,7 +1285,7 @@ func (s *Server) ReplicaBackupCreate(ctx context.Context, req *spdkrpc.BackupCre if err := backup.BackupCreate(config); err != nil { delete(s.backupMap, backupName) err = errors.Wrapf(err, "failed to create backup %v for volume %v", backupName, req.VolumeName) - return nil, grpcstatus.Errorf(grpccodes.Internal, err.Error()) + return nil, grpcstatus.Errorf(grpccodes.Internal, "%v", err) } return &spdkrpc.BackupCreateResponse{ @@ -1371,7 +1371,7 @@ func (s *Server) EngineRestoreStatus(ctx context.Context, req *spdkrpc.RestoreSt resp, err := e.RestoreStatus() if err != nil { err = errors.Wrapf(err, "failed to get restore status for engine %v", req.EngineName) - return nil, grpcstatus.Errorf(grpccodes.Internal, err.Error()) + return nil, grpcstatus.Errorf(grpccodes.Internal, "%v", err) } return resp, nil }