mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	another commit to do like @crosbymichael
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
		
							parent
							
								
									fcf37be2b1
								
							
						
					
					
						commit
						a0392324f1
					
				
					 11 changed files with 39 additions and 39 deletions
				
			
		| 
						 | 
				
			
			@ -434,11 +434,11 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
 | 
			
		|||
	out := engine.NewOutput()
 | 
			
		||||
	remoteVersion, err := out.AddEnv()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Errorf("Error reading remote version: %s\n", err)
 | 
			
		||||
		log.Errorf("Error reading remote version: %s", err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if _, err := out.Write(body); err != nil {
 | 
			
		||||
		log.Errorf("Error reading remote version: %s\n", err)
 | 
			
		||||
		log.Errorf("Error reading remote version: %s", err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	out.Close()
 | 
			
		||||
| 
						 | 
				
			
			@ -474,7 +474,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := out.Write(body); err != nil {
 | 
			
		||||
		log.Errorf("Error reading remote info: %s\n", err)
 | 
			
		||||
		log.Errorf("Error reading remote info: %s", err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	out.Close()
 | 
			
		||||
| 
						 | 
				
			
			@ -691,7 +691,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
 | 
			
		|||
	if *openStdin || *attach {
 | 
			
		||||
		if tty && cli.isTerminal {
 | 
			
		||||
			if err := cli.monitorTtySize(cmd.Arg(0)); err != nil {
 | 
			
		||||
				log.Errorf("Error monitoring TTY size: %s\n", err)
 | 
			
		||||
				log.Errorf("Error monitoring TTY size: %s", err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return <-cErr
 | 
			
		||||
| 
						 | 
				
			
			@ -2159,7 +2159,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
 | 
			
		|||
 | 
			
		||||
	if (config.AttachStdin || config.AttachStdout || config.AttachStderr) && config.Tty && cli.isTerminal {
 | 
			
		||||
		if err := cli.monitorTtySize(runResult.Get("Id")); err != nil {
 | 
			
		||||
			log.Errorf("Error monitoring TTY size: %s\n", err)
 | 
			
		||||
			log.Errorf("Error monitoring TTY size: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,11 +106,11 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
 | 
			
		|||
		}
 | 
			
		||||
		if tcpc, ok := rwc.(*net.TCPConn); ok {
 | 
			
		||||
			if err := tcpc.CloseWrite(); err != nil {
 | 
			
		||||
				log.Debugf("Couldn't send EOF: %s\n", err)
 | 
			
		||||
				log.Debugf("Couldn't send EOF: %s", err)
 | 
			
		||||
			}
 | 
			
		||||
		} else if unixc, ok := rwc.(*net.UnixConn); ok {
 | 
			
		||||
			if err := unixc.CloseWrite(); err != nil {
 | 
			
		||||
				log.Debugf("Couldn't send EOF: %s\n", err)
 | 
			
		||||
				log.Debugf("Couldn't send EOF: %s", err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		// Discard errors due to pipe interruption
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -342,7 +342,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
 | 
			
		|||
		for _, include := range options.Includes {
 | 
			
		||||
			filepath.Walk(filepath.Join(srcPath, include), func(filePath string, f os.FileInfo, err error) error {
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Debugf("Tar: Can't stat file %s to tar: %s\n", srcPath, err)
 | 
			
		||||
					log.Debugf("Tar: Can't stat file %s to tar: %s", srcPath, err)
 | 
			
		||||
					return nil
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -353,7 +353,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
 | 
			
		|||
 | 
			
		||||
				skip, err := utils.Matches(relFilePath, options.Excludes)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Debugf("Error matching %s\n", relFilePath, err)
 | 
			
		||||
					log.Debugf("Error matching %s", relFilePath, err)
 | 
			
		||||
					return err
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -365,7 +365,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
 | 
			
		|||
				}
 | 
			
		||||
 | 
			
		||||
				if err := addTarFile(filePath, relFilePath, tw, twBuf); err != nil {
 | 
			
		||||
					log.Debugf("Can't add file %s to tar: %s\n", srcPath, err)
 | 
			
		||||
					log.Debugf("Can't add file %s to tar: %s", srcPath, err)
 | 
			
		||||
				}
 | 
			
		||||
				return nil
 | 
			
		||||
			})
 | 
			
		||||
| 
						 | 
				
			
			@ -373,13 +373,13 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
 | 
			
		|||
 | 
			
		||||
		// Make sure to check the error on Close.
 | 
			
		||||
		if err := tw.Close(); err != nil {
 | 
			
		||||
			log.Debugf("Can't close tar writer: %s\n", err)
 | 
			
		||||
			log.Debugf("Can't close tar writer: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
		if err := compressWriter.Close(); err != nil {
 | 
			
		||||
			log.Debugf("Can't close compress writer: %s\n", err)
 | 
			
		||||
			log.Debugf("Can't close compress writer: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
		if err := pipeWriter.Close(); err != nil {
 | 
			
		||||
			log.Debugf("Can't close pipe writer: %s\n", err)
 | 
			
		||||
			log.Debugf("Can't close pipe writer: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -364,19 +364,19 @@ func ExportChanges(dir string, changes []Change) (Archive, error) {
 | 
			
		|||
					ChangeTime: timestamp,
 | 
			
		||||
				}
 | 
			
		||||
				if err := tw.WriteHeader(hdr); err != nil {
 | 
			
		||||
					log.Debugf("Can't write whiteout header: %s\n", err)
 | 
			
		||||
					log.Debugf("Can't write whiteout header: %s", err)
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				path := filepath.Join(dir, change.Path)
 | 
			
		||||
				if err := addTarFile(path, change.Path[1:], tw, twBuf); err != nil {
 | 
			
		||||
					log.Debugf("Can't add file %s to tar: %s\n", path, err)
 | 
			
		||||
					log.Debugf("Can't add file %s to tar: %s", path, err)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Make sure to check the error on Close.
 | 
			
		||||
		if err := tw.Close(); err != nil {
 | 
			
		||||
			log.Debugf("Can't close layer: %s\n", err)
 | 
			
		||||
			log.Debugf("Can't close layer: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
		writer.Close()
 | 
			
		||||
	}()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -210,7 +210,7 @@ func (a *Driver) Remove(id string) error {
 | 
			
		|||
	defer a.Unlock()
 | 
			
		||||
 | 
			
		||||
	if a.active[id] != 0 {
 | 
			
		||||
		log.Errorf("Warning: removing active id %s\n", id)
 | 
			
		||||
		log.Errorf("Warning: removing active id %s", id)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Make sure the dir is umounted first
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -596,7 +596,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
 | 
			
		|||
 | 
			
		||||
			data, err := devices.ensureImage("data", devices.dataLoopbackSize)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Debugf("Error device ensureImage (data): %s\n", err)
 | 
			
		||||
				log.Debugf("Error device ensureImage (data): %s", err)
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -627,7 +627,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
 | 
			
		|||
 | 
			
		||||
			metadata, err := devices.ensureImage("metadata", devices.metaDataLoopbackSize)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Debugf("Error device ensureImage (metadata): %s\n", err)
 | 
			
		||||
				log.Debugf("Error device ensureImage (metadata): %s", err)
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -659,7 +659,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
 | 
			
		|||
	// Setup the base image
 | 
			
		||||
	if doInit {
 | 
			
		||||
		if err := devices.setupBaseImage(); err != nil {
 | 
			
		||||
			log.Debugf("Error device setupBaseImage: %s\n", err)
 | 
			
		||||
			log.Debugf("Error device setupBaseImage: %s", err)
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -686,7 +686,7 @@ func (devices *DeviceSet) AddDevice(hash, baseHash string) error {
 | 
			
		|||
	deviceId := devices.nextDeviceId
 | 
			
		||||
 | 
			
		||||
	if err := createSnapDevice(devices.getPoolDevName(), &deviceId, baseInfo.Name(), baseInfo.DeviceId); err != nil {
 | 
			
		||||
		log.Debugf("Error creating snap device: %s\n", err)
 | 
			
		||||
		log.Debugf("Error creating snap device: %s", err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -695,7 +695,7 @@ func (devices *DeviceSet) AddDevice(hash, baseHash string) error {
 | 
			
		|||
 | 
			
		||||
	if _, err := devices.registerDevice(deviceId, hash, baseInfo.Size); err != nil {
 | 
			
		||||
		deleteDevice(devices.getPoolDevName(), deviceId)
 | 
			
		||||
		log.Debugf("Error registering device: %s\n", err)
 | 
			
		||||
		log.Debugf("Error registering device: %s", err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
| 
						 | 
				
			
			@ -708,7 +708,7 @@ func (devices *DeviceSet) deleteDevice(info *DevInfo) error {
 | 
			
		|||
		// manually
 | 
			
		||||
		if err := devices.activateDeviceIfNeeded(info); err == nil {
 | 
			
		||||
			if err := BlockDeviceDiscard(info.DevName()); err != nil {
 | 
			
		||||
				log.Debugf("Error discarding block on device: %s (ignoring)\n", err)
 | 
			
		||||
				log.Debugf("Error discarding block on device: %s (ignoring)", err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -716,13 +716,13 @@ func (devices *DeviceSet) deleteDevice(info *DevInfo) error {
 | 
			
		|||
	devinfo, _ := getInfo(info.Name())
 | 
			
		||||
	if devinfo != nil && devinfo.Exists != 0 {
 | 
			
		||||
		if err := devices.removeDeviceAndWait(info.Name()); err != nil {
 | 
			
		||||
			log.Debugf("Error removing device: %s\n", err)
 | 
			
		||||
			log.Debugf("Error removing device: %s", err)
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := deleteDevice(devices.getPoolDevName(), info.DeviceId); err != nil {
 | 
			
		||||
		log.Debugf("Error deleting device: %s\n", err)
 | 
			
		||||
		log.Debugf("Error deleting device: %s", err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -735,7 +735,7 @@ func (devices *DeviceSet) deleteDevice(info *DevInfo) error {
 | 
			
		|||
		devices.devicesLock.Lock()
 | 
			
		||||
		devices.Devices[info.Hash] = info
 | 
			
		||||
		devices.devicesLock.Unlock()
 | 
			
		||||
		log.Debugf("Error removing meta data: %s\n", err)
 | 
			
		||||
		log.Debugf("Error removing meta data: %s", err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -779,7 +779,7 @@ func (devices *DeviceSet) deactivateDevice(info *DevInfo) error {
 | 
			
		|||
	// Wait for the unmount to be effective,
 | 
			
		||||
	// by watching the value of Info.OpenCount for the device
 | 
			
		||||
	if err := devices.waitClose(info); err != nil {
 | 
			
		||||
		log.Errorf("Warning: error waiting for device %s to close: %s\n", info.Hash, err)
 | 
			
		||||
		log.Errorf("Warning: error waiting for device %s to close: %s", info.Hash, err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	devinfo, err := getInfo(info.Name())
 | 
			
		||||
| 
						 | 
				
			
			@ -903,12 +903,12 @@ func (devices *DeviceSet) Shutdown() error {
 | 
			
		|||
			// container. This means it'll go away from the global scope directly,
 | 
			
		||||
			// and the device will be released when that container dies.
 | 
			
		||||
			if err := syscall.Unmount(info.mountPath, syscall.MNT_DETACH); err != nil {
 | 
			
		||||
				log.Debugf("Shutdown unmounting %s, error: %s\n", info.mountPath, err)
 | 
			
		||||
				log.Debugf("Shutdown unmounting %s, error: %s", info.mountPath, err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			devices.Lock()
 | 
			
		||||
			if err := devices.deactivateDevice(info); err != nil {
 | 
			
		||||
				log.Debugf("Shutdown deactivate %s , error: %s\n", info.Hash, err)
 | 
			
		||||
				log.Debugf("Shutdown deactivate %s , error: %s", info.Hash, err)
 | 
			
		||||
			}
 | 
			
		||||
			devices.Unlock()
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -920,7 +920,7 @@ func (devices *DeviceSet) Shutdown() error {
 | 
			
		|||
		info.lock.Lock()
 | 
			
		||||
		devices.Lock()
 | 
			
		||||
		if err := devices.deactivateDevice(info); err != nil {
 | 
			
		||||
			log.Debugf("Shutdown deactivate base , error: %s\n", err)
 | 
			
		||||
			log.Debugf("Shutdown deactivate base , error: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
		devices.Unlock()
 | 
			
		||||
		info.lock.Unlock()
 | 
			
		||||
| 
						 | 
				
			
			@ -928,7 +928,7 @@ func (devices *DeviceSet) Shutdown() error {
 | 
			
		|||
 | 
			
		||||
	devices.Lock()
 | 
			
		||||
	if err := devices.deactivatePool(); err != nil {
 | 
			
		||||
		log.Debugf("Shutdown deactivate pool , error: %s\n", err)
 | 
			
		||||
		log.Debugf("Shutdown deactivate pool , error: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	devices.Unlock()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -198,7 +198,7 @@ func (t *Task) GetNextTarget(next uintptr) (nextPtr uintptr, start uint64,
 | 
			
		|||
func getLoopbackBackingFile(file *os.File) (uint64, uint64, error) {
 | 
			
		||||
	loopInfo, err := ioctlLoopGetStatus64(file.Fd())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Errorf("Error get loopback backing file: %s\n", err)
 | 
			
		||||
		log.Errorf("Error get loopback backing file: %s", err)
 | 
			
		||||
		return 0, 0, ErrGetLoopbackBackingFile
 | 
			
		||||
	}
 | 
			
		||||
	return loopInfo.loDevice, loopInfo.loInode, nil
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -138,7 +138,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
 | 
			
		|||
 | 
			
		||||
func (d *Driver) Put(id string) {
 | 
			
		||||
	if err := d.DeviceSet.UnmountDevice(id); err != nil {
 | 
			
		||||
		log.Errorf("Warning: error unmounting device %s: %s\n", id, err)
 | 
			
		||||
		log.Errorf("Warning: error unmounting device %s: %s", id, err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,7 +88,7 @@ func (m *containerMonitor) Close() error {
 | 
			
		|||
	// because they share same runconfig and change image. Must be fixed
 | 
			
		||||
	// in builder/builder.go
 | 
			
		||||
	if err := m.container.toDisk(); err != nil {
 | 
			
		||||
		log.Errorf("Error dumping container %s state to disk: %s\n", m.container.ID, err)
 | 
			
		||||
		log.Errorf("Error dumping container %s state to disk: %s", m.container.ID, err)
 | 
			
		||||
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -97,9 +97,9 @@ func (s *TagStore) pushRepository(r *registry.Session, out io.Writer, localName,
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("Preparing to push %s with the following images and tags\n", localRepo)
 | 
			
		||||
	log.Debugf("Preparing to push %s with the following images and tags", localRepo)
 | 
			
		||||
	for _, data := range imageIndex {
 | 
			
		||||
		log.Debugf("Pushing ID: %s with Tag: %s\n", data.ID, data.Tag)
 | 
			
		||||
		log.Debugf("Pushing ID: %s with Tag: %s", data.ID, data.Tag)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Register all the images in a repository with the registry
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,16 +107,16 @@ func init() {
 | 
			
		|||
	if dockerinit := os.Getenv("TEST_DOCKERINIT_PATH"); dockerinit != "" {
 | 
			
		||||
		src, err := os.Open(dockerinit)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatalf("Unable to open TEST_DOCKERINIT_PATH: %s\n", err)
 | 
			
		||||
			log.Fatalf("Unable to open TEST_DOCKERINIT_PATH: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
		defer src.Close()
 | 
			
		||||
		dst, err := os.OpenFile(filepath.Join(filepath.Dir(utils.SelfPath()), "dockerinit"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0555)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatalf("Unable to create dockerinit in test directory: %s\n", err)
 | 
			
		||||
			log.Fatalf("Unable to create dockerinit in test directory: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
		defer dst.Close()
 | 
			
		||||
		if _, err := io.Copy(dst, src); err != nil {
 | 
			
		||||
			log.Fatalf("Unable to copy dockerinit to TEST_DOCKERINIT_PATH: %s\n", err)
 | 
			
		||||
			log.Fatalf("Unable to copy dockerinit to TEST_DOCKERINIT_PATH: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
		dst.Close()
 | 
			
		||||
		src.Close()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue