mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	aufs: use a single logger
Simplify the code by using a single logger instance. While at it, use WithError in Umount. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
		
							parent
							
								
									f9dd74deee
								
							
						
					
					
						commit
						c6e2af5425
					
				
					 2 changed files with 7 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -62,6 +62,8 @@ var (
 | 
			
		|||
 | 
			
		||||
	enableDirpermLock sync.Once
 | 
			
		||||
	enableDirperm     bool
 | 
			
		||||
 | 
			
		||||
	logger = logrus.WithField("storage-driver", "aufs")
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +111,7 @@ func Init(root string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
 | 
			
		|||
 | 
			
		||||
	switch fsMagic {
 | 
			
		||||
	case graphdriver.FsMagicAufs, graphdriver.FsMagicBtrfs, graphdriver.FsMagicEcryptfs:
 | 
			
		||||
		logrus.WithField("storage-driver", "aufs").Errorf("AUFS is not supported over %s", backingFs)
 | 
			
		||||
		logger.Errorf("AUFS is not supported over %s", backingFs)
 | 
			
		||||
		return nil, graphdriver.ErrIncompatibleFS
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +145,6 @@ func Init(root string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
 | 
			
		|||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	logger := logrus.WithField("storage-driver", "aufs")
 | 
			
		||||
 | 
			
		||||
	for _, path := range []string{"mnt", "diff"} {
 | 
			
		||||
		p := filepath.Join(root, path)
 | 
			
		||||
| 
						 | 
				
			
			@ -306,10 +307,7 @@ func (a *Driver) Remove(id string) error {
 | 
			
		|||
		mountpoint = a.getMountpoint(id)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logger := logrus.WithFields(logrus.Fields{
 | 
			
		||||
		"storage-driver": "aufs",
 | 
			
		||||
		"layer":          id,
 | 
			
		||||
	})
 | 
			
		||||
	logger := logger.WithField("layer", id)
 | 
			
		||||
 | 
			
		||||
	var retries int
 | 
			
		||||
	for {
 | 
			
		||||
| 
						 | 
				
			
			@ -439,7 +437,7 @@ func (a *Driver) Put(id string) error {
 | 
			
		|||
 | 
			
		||||
	err := a.unmount(m)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logrus.WithField("storage-driver", "aufs").Debugf("Failed to unmount %s aufs: %v", id, err)
 | 
			
		||||
		logger.Debugf("Failed to unmount %s aufs: %v", id, err)
 | 
			
		||||
	}
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -597,7 +595,7 @@ func (a *Driver) Cleanup() error {
 | 
			
		|||
 | 
			
		||||
	for _, m := range dirs {
 | 
			
		||||
		if err := a.unmount(m); err != nil {
 | 
			
		||||
			logrus.WithField("storage-driver", "aufs").Debugf("error unmounting %s: %s", m, err)
 | 
			
		||||
			logger.Debugf("error unmounting %s: %s", m, err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return mountpk.RecursiveUnmount(a.root)
 | 
			
		||||
| 
						 | 
				
			
			@ -652,7 +650,6 @@ func (a *Driver) aufsMount(ro []string, rw, target, mountLabel string) (err erro
 | 
			
		|||
// useDirperm checks dirperm1 mount option can be used with the current
 | 
			
		||||
// version of aufs.
 | 
			
		||||
func useDirperm() bool {
 | 
			
		||||
	logger := logrus.WithField("storage-driver", "aufs")
 | 
			
		||||
	enableDirpermLock.Do(func() {
 | 
			
		||||
		base, err := ioutil.TempDir("", "docker-aufs-base")
 | 
			
		||||
		if err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,14 +5,13 @@ package aufs // import "github.com/docker/docker/daemon/graphdriver/aufs"
 | 
			
		|||
import (
 | 
			
		||||
	"os/exec"
 | 
			
		||||
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
	"golang.org/x/sys/unix"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Unmount the target specified.
 | 
			
		||||
func Unmount(target string) error {
 | 
			
		||||
	if err := exec.Command("auplink", target, "flush").Run(); err != nil {
 | 
			
		||||
		logrus.WithField("storage-driver", "aufs").Warnf("Couldn't run auplink before unmount %s: %s", target, err)
 | 
			
		||||
		logger.WithError(err).Warnf("Couldn't run auplink before unmount %s", target)
 | 
			
		||||
	}
 | 
			
		||||
	return unix.Unmount(target, 0)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue