devmapper: log pool status when mkfs fails
If mkfs on device mapper thin pool fails, it will show pool status as returned by dmsetup for enahnced error reporting. Signed-off-by: Alakesh Haloi <alakeshh@amazon.com>
This commit is contained in:
parent
054a3e281e
commit
5ce35ac398
@ -274,10 +274,11 @@ func Version() (string, error) {
|
|||||||
|
|
||||||
// DeviceStatus represents devmapper device status information
|
// DeviceStatus represents devmapper device status information
|
||||||
type DeviceStatus struct {
|
type DeviceStatus struct {
|
||||||
Offset int64
|
RawOutput string
|
||||||
Length int64
|
Offset int64
|
||||||
Target string
|
Length int64
|
||||||
Params []string
|
Target string
|
||||||
|
Params []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status provides status information for devmapper device
|
// Status provides status information for devmapper device
|
||||||
@ -291,6 +292,7 @@ func Status(deviceName string) (*DeviceStatus, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
status.RawOutput = output
|
||||||
|
|
||||||
// Status output format:
|
// Status output format:
|
||||||
// Offset (int64)
|
// Offset (int64)
|
||||||
|
@ -366,8 +366,13 @@ func (s *Snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := mkfs(ctx, dmsetup.GetFullDevicePath(deviceName)); err != nil {
|
if err := mkfs(ctx, dmsetup.GetFullDevicePath(deviceName)); err != nil {
|
||||||
|
status, sErr := dmsetup.Status(s.pool.poolName)
|
||||||
|
if sErr != nil {
|
||||||
|
multierror.Append(err, sErr)
|
||||||
|
}
|
||||||
|
|
||||||
// Rollback thin device creation if mkfs failed
|
// Rollback thin device creation if mkfs failed
|
||||||
log.G(ctx).WithError(err).Errorf("failed to initialize thin device %q for snapshot %s", deviceName, snap.ID)
|
log.G(ctx).WithError(err).Errorf("failed to initialize thin device %q for snapshot %s pool status %s", deviceName, snap.ID, status.RawOutput)
|
||||||
return nil, multierror.Append(err,
|
return nil, multierror.Append(err,
|
||||||
s.pool.RemoveDevice(ctx, deviceName))
|
s.pool.RemoveDevice(ctx, deviceName))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user