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 committed Sep 24, 2024
1 parent cf5477c commit beb5498
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)

Check warning on line 153 in pkg/spdk/disk.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/disk.go#L153

Added line #L153 was not covered by tests
}
}
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)

Check warning on line 187 in pkg/spdk/disk.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/disk.go#L187

Added line #L187 was not covered by tests
}

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)

Check warning on line 1665 in pkg/spdk/engine.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/engine.go#L1665

Added line #L1665 was not covered by tests
}
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)

Check warning on line 1714 in pkg/spdk/engine.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/engine.go#L1714

Added line #L1714 was not covered by tests
}

replicaServiceCli, err := GetServiceClient(replicaAddress)
if err != nil {
return nil, grpcstatus.Errorf(grpccodes.Internal, err.Error())
return nil, grpcstatus.Errorf(grpccodes.Internal, "%v", err)

Check warning on line 1719 in pkg/spdk/engine.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/engine.go#L1719

Added line #L1719 was not covered by tests
}
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)

Check warning on line 1894 in pkg/spdk/replica.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/replica.go#L1894

Added line #L1894 was not covered by tests
}

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)

Check warning on line 1900 in pkg/spdk/replica.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/replica.go#L1900

Added line #L1900 was not covered by tests
}

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)

Check warning on line 1906 in pkg/spdk/replica.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/replica.go#L1906

Added line #L1906 was not covered by tests
}

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)

Check warning on line 1930 in pkg/spdk/replica.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/replica.go#L1930

Added line #L1930 was not covered by tests
}
} 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)

Check warning on line 1231 in pkg/spdk/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/server.go#L1231

Added line #L1231 was not covered by tests
}

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)

Check warning on line 1239 in pkg/spdk/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/server.go#L1239

Added line #L1239 was not covered by tests
}
}

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)

Check warning on line 1258 in pkg/spdk/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/server.go#L1258

Added line #L1258 was not covered by tests
}

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)

Check warning on line 1288 in pkg/spdk/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/server.go#L1288

Added line #L1288 was not covered by tests
}

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)

Check warning on line 1374 in pkg/spdk/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/server.go#L1374

Added line #L1374 was not covered by tests
}
return resp, nil
}
Expand Down

0 comments on commit beb5498

Please sign in to comment.