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 c3y1huang committed Sep 24, 2024
1 parent ad121f3 commit 336405d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pkg/spdk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pkg/spdk/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/spdk/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions pkg/spdk/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1228,15 +1228,15 @@ 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
if req.Labels != nil {
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)
}
}

Expand All @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 336405d

Please sign in to comment.