feat: Errorf usage

Signed-off-by: haoyun <yun.hao@daocloud.io>
This commit is contained in:
haoyun
2021-12-13 14:31:53 +08:00
parent a04656c1dd
commit c0d07094be
30 changed files with 80 additions and 80 deletions

View File

@@ -193,7 +193,7 @@ func getNextDeviceID(tx *bolt.Tx) (uint32, error) {
}
if seq >= maxDeviceID {
return 0, errors.Errorf("dm-meta: couldn't find free device key")
return 0, errors.New("dm-meta: couldn't find free device key")
}
id := uint32(seq)

View File

@@ -48,7 +48,7 @@ func NewPoolDevice(ctx context.Context, config *Config) (*PoolDevice, error) {
version, err := dmsetup.Version()
if err != nil {
log.G(ctx).Errorf("dmsetup not available")
log.G(ctx).Error("dmsetup not available")
return nil, err
}
@@ -491,7 +491,7 @@ func (p *PoolDevice) GetUsage(deviceName string) (int64, error) {
}
if len(status.Params) == 0 {
return 0, errors.Errorf("failed to get the number of used blocks, unexpected output from dmsetup status")
return 0, errors.New("failed to get the number of used blocks, unexpected output from dmsetup status")
}
count, err := strconv.ParseInt(status.Params[0], 10, 64)

View File

@@ -307,7 +307,7 @@ func (s *Snapshotter) removeDevice(ctx context.Context, key string) error {
deviceName := s.getDeviceName(snapID)
if !s.config.AsyncRemove {
if err := s.pool.RemoveDevice(ctx, deviceName); err != nil {
log.G(ctx).WithError(err).Errorf("failed to remove device")
log.G(ctx).WithError(err).Error("failed to remove device")
// Tell snapshot GC continue to collect other snapshots.
// Otherwise, one snapshot collection failure will stop
// the GC, and all snapshots won't be collected even though
@@ -318,7 +318,7 @@ func (s *Snapshotter) removeDevice(ctx context.Context, key string) error {
// The asynchronous cleanup will do the real device remove work.
log.G(ctx).WithField("device", deviceName).Debug("async remove")
if err := s.pool.MarkDeviceState(ctx, deviceName, Removed); err != nil {
log.G(ctx).WithError(err).Errorf("failed to mark device as removed")
log.G(ctx).WithError(err).Error("failed to mark device as removed")
return err
}
}
@@ -571,7 +571,7 @@ func (s *Snapshotter) Cleanup(ctx context.Context) error {
}
return nil
}); err != nil {
log.G(ctx).WithError(err).Errorf("failed to query devices from metastore")
log.G(ctx).WithError(err).Error("failed to query devices from metastore")
return err
}