@@ -365,8 +365,9 @@ func (s *Snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
365365 return nil , err
366366 }
367367
368- if err := s . mkfs (ctx , deviceName ); err != nil {
368+ if err := mkfs (ctx , dmsetup . GetFullDevicePath ( deviceName ) ); err != nil {
369369 // Rollback thin device creation if mkfs failed
370+ log .G (ctx ).WithError (err ).Errorf ("failed to initialize thin device %q for snapshot %s" , deviceName , snap .ID )
370371 return nil , multierror .Append (err ,
371372 s .pool .RemoveDevice (ctx , deviceName ))
372373 }
@@ -393,22 +394,22 @@ func (s *Snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
393394}
394395
395396// mkfs creates ext4 filesystem on the given devmapper device
396- func ( s * Snapshotter ) mkfs (ctx context.Context , deviceName string ) error {
397+ func mkfs (ctx context.Context , path string ) error {
397398 args := []string {
398399 "-E" ,
399400 // We don't want any zeroing in advance when running mkfs on thin devices (see "man mkfs.ext4")
400401 "nodiscard,lazy_itable_init=0,lazy_journal_init=0" ,
401- dmsetup . GetFullDevicePath ( deviceName ) ,
402+ path ,
402403 }
403404
404405 log .G (ctx ).Debugf ("mkfs.ext4 %s" , strings .Join (args , " " ))
405- output , err := exec .Command ("mkfs.ext4" , args ... ).CombinedOutput ()
406+ b , err := exec .Command ("mkfs.ext4" , args ... ).CombinedOutput ()
407+ out := string (b )
406408 if err != nil {
407- log .G (ctx ).WithError (err ).Errorf ("failed to write fs:\n %s" , string (output ))
408- return err
409+ return errors .Wrapf (err , "mkfs.ext4 couldn't initialize %q: %s" , path , out )
409410 }
410411
411- log .G (ctx ).Debugf ("mkfs:\n %s" , string ( output ) )
412+ log .G (ctx ).Debugf ("mkfs:\n %s" , out )
412413 return nil
413414}
414415
0 commit comments