update docker to v1.11.2

Signed-off-by: Vishnu kannan <vishnuk@google.com>
This commit is contained in:
Vishnu kannan 2016-07-19 16:51:13 -07:00
parent 734db4c437
commit d4ce3dccdd
25 changed files with 239 additions and 160 deletions

21
Godeps/Godeps.json generated
View File

@ -135,28 +135,23 @@
}, },
{ {
"ImportPath": "github.com/docker/docker/pkg/longpath", "ImportPath": "github.com/docker/docker/pkg/longpath",
"Comment": "v1.9.1", "Comment": "v1.11.2",
"Rev": "a34a1d598c6096ed8b5ce5219e77d68e5cd85462" "Rev": "b9f10c951893f9a00865890a5232e85d770c1087"
}, },
{ {
"ImportPath": "github.com/docker/docker/pkg/mount", "ImportPath": "github.com/docker/docker/pkg/mount",
"Comment": "v1.9.1", "Comment": "v1.11.2",
"Rev": "a34a1d598c6096ed8b5ce5219e77d68e5cd85462" "Rev": "b9f10c951893f9a00865890a5232e85d770c1087"
}, },
{ {
"ImportPath": "github.com/docker/docker/pkg/symlink", "ImportPath": "github.com/docker/docker/pkg/symlink",
"Comment": "v1.9.1", "Comment": "v1.11.2",
"Rev": "a34a1d598c6096ed8b5ce5219e77d68e5cd85462" "Rev": "b9f10c951893f9a00865890a5232e85d770c1087"
}, },
{ {
"ImportPath": "github.com/docker/docker/pkg/system", "ImportPath": "github.com/docker/docker/pkg/system",
"Comment": "v1.9.1", "Comment": "v1.11.2",
"Rev": "a34a1d598c6096ed8b5ce5219e77d68e5cd85462" "Rev": "b9f10c951893f9a00865890a5232e85d770c1087"
},
{
"ImportPath": "github.com/docker/docker/pkg/units",
"Comment": "v1.9.1",
"Rev": "a34a1d598c6096ed8b5ce5219e77d68e5cd85462"
}, },
{ {
"ImportPath": "github.com/docker/engine-api/client", "ImportPath": "github.com/docker/engine-api/client",

View File

@ -176,7 +176,7 @@
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
Copyright 2013-2015 Docker, Inc. Copyright 2013-2016 Docker, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
Docker Docker
Copyright 2012-2015 Docker, Inc. Copyright 2012-2016 Docker, Inc.
This product includes software developed at Docker, Inc. (https://www.docker.com). This product includes software developed at Docker, Inc. (https://www.docker.com).

View File

@ -1,6 +1,7 @@
package mount package mount
import ( import (
"fmt"
"strings" "strings"
) )
@ -67,3 +68,25 @@ func parseOptions(options string) (int, string) {
} }
return flag, strings.Join(data, ",") return flag, strings.Join(data, ",")
} }
// ParseTmpfsOptions parse fstab type mount options into flags and data
func ParseTmpfsOptions(options string) (int, string, error) {
flags, data := parseOptions(options)
validFlags := map[string]bool{
"": true,
"size": true,
"mode": true,
"uid": true,
"gid": true,
"nr_inodes": true,
"nr_blocks": true,
"mpol": true,
}
for _, o := range strings.Split(data, ",") {
opt := strings.SplitN(o, "=", 2)
if !validFlags[opt[0]] {
return 0, "", fmt.Errorf("Invalid tmpfs option %q", opt)
}
}
return flags, data, nil
}

View File

@ -23,7 +23,7 @@ const (
SYNCHRONOUS = syscall.MS_SYNCHRONOUS SYNCHRONOUS = syscall.MS_SYNCHRONOUS
// DIRSYNC will force all directory updates within the file system to be done // DIRSYNC will force all directory updates within the file system to be done
// synchronously. This affects the following system calls: creat, link, // synchronously. This affects the following system calls: create, link,
// unlink, symlink, mkdir, rmdir, mknod and rename. // unlink, symlink, mkdir, rmdir, mknod and rename.
DIRSYNC = syscall.MS_DIRSYNC DIRSYNC = syscall.MS_DIRSYNC

View File

@ -1,4 +1,4 @@
// +build !linux,!freebsd freebsd,!cgo // +build !windows,!linux,!freebsd freebsd,!cgo
package mount package mount

View File

@ -0,0 +1,6 @@
package mount
func parseMountTable() ([]*Info, error) {
// Do NOT return an error!
return nil, nil
}

View File

@ -61,8 +61,7 @@ func ensureMountedAs(mountPoint, options string) error {
return err return err
} }
} }
mounted, err = Mounted(mountPoint) if _, err = Mounted(mountPoint); err != nil {
if err != nil {
return err return err
} }

View File

@ -176,7 +176,7 @@
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
Copyright 2014-2015 Docker, Inc. Copyright 2014-2016 Docker, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@ -1,4 +1,4 @@
Copyright (c) 2014-2015 The Docker & Go Authors. All rights reserved. Copyright (c) 2014-2016 The Docker & Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are modification, are permitted provided that the following conditions are

View File

@ -23,8 +23,7 @@ func toShort(path string) (string, error) {
} }
if n > uint32(len(b)) { if n > uint32(len(b)) {
b = make([]uint16, n) b = make([]uint16, n)
n, err = syscall.GetShortPathName(&p[0], &b[0], uint32(len(b))) if _, err = syscall.GetShortPathName(&p[0], &b[0], uint32(len(b))); err != nil {
if err != nil {
return "", err return "", err
} }
} }
@ -91,7 +90,7 @@ func walkSymlinks(path string) (string, error) {
return "", errors.New("EvalSymlinks: too many links in " + originalPath) return "", errors.New("EvalSymlinks: too many links in " + originalPath)
} }
// A path beginnging with `\\?\` represents the root, so automatically // A path beginning with `\\?\` represents the root, so automatically
// skip that part and begin processing the next segment. // skip that part and begin processing the next segment.
if strings.HasPrefix(path, longpath.Prefix) { if strings.HasPrefix(path, longpath.Prefix) {
b.WriteString(longpath.Prefix) b.WriteString(longpath.Prefix)

View File

@ -2,14 +2,30 @@ package system
import ( import (
"os" "os"
"syscall"
"time" "time"
"unsafe"
) )
var (
maxTime time.Time
)
func init() {
if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 {
// This is a 64 bit timespec
// os.Chtimes limits time to the following
maxTime = time.Unix(0, 1<<63-1)
} else {
// This is a 32 bit timespec
maxTime = time.Unix(1<<31-1, 0)
}
}
// Chtimes changes the access time and modified time of a file at the given path // Chtimes changes the access time and modified time of a file at the given path
func Chtimes(name string, atime time.Time, mtime time.Time) error { func Chtimes(name string, atime time.Time, mtime time.Time) error {
unixMinTime := time.Unix(0, 0) unixMinTime := time.Unix(0, 0)
// The max Unix time is 33 bits set unixMaxTime := maxTime
unixMaxTime := unixMinTime.Add((1<<33 - 1) * time.Second)
// If the modified time is prior to the Unix Epoch, or after the // If the modified time is prior to the Unix Epoch, or after the
// end of Unix Time, os.Chtimes has undefined behavior // end of Unix Time, os.Chtimes has undefined behavior
@ -27,5 +43,10 @@ func Chtimes(name string, atime time.Time, mtime time.Time) error {
return err return err
} }
// Take platform specific action for setting create time.
if err := setCTime(name, mtime); err != nil {
return err
}
return nil return nil
} }

View File

@ -0,0 +1,14 @@
// +build !windows
package system
import (
"time"
)
//setCTime will set the create time on a file. On Unix, the create
//time is updated as a side effect of setting the modified time, so
//no action is required.
func setCTime(path string, ctime time.Time) error {
return nil
}

View File

@ -0,0 +1,27 @@
// +build windows
package system
import (
"syscall"
"time"
)
//setCTime will set the create time on a file. On Windows, this requires
//calling SetFileTime and explicitly including the create time.
func setCTime(path string, ctime time.Time) error {
ctimespec := syscall.NsecToTimespec(ctime.UnixNano())
pathp, e := syscall.UTF16PtrFromString(path)
if e != nil {
return e
}
h, e := syscall.CreateFile(pathp,
syscall.FILE_WRITE_ATTRIBUTES, syscall.FILE_SHARE_WRITE, nil,
syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0)
if e != nil {
return e
}
defer syscall.Close(h)
c := syscall.NsecToFiletime(syscall.TimespecToNsec(ctimespec))
return syscall.SetFileTime(h, &c, nil, nil)
}

View File

@ -7,11 +7,11 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/docker/docker/pkg/units" "github.com/docker/go-units"
) )
// ReadMemInfo retrieves memory statistics of the host system and returns a // ReadMemInfo retrieves memory statistics of the host system and returns a
// MemInfo type. // MemInfo type.
func ReadMemInfo() (*MemInfo, error) { func ReadMemInfo() (*MemInfo, error) {
file, err := os.Open("/proc/meminfo") file, err := os.Open("/proc/meminfo")
if err != nil { if err != nil {
@ -22,8 +22,7 @@ func ReadMemInfo() (*MemInfo, error) {
} }
// parseMemInfo parses the /proc/meminfo file into // parseMemInfo parses the /proc/meminfo file into
// a MemInfo object given a io.Reader to the file. // a MemInfo object given an io.Reader to the file.
//
// Throws error if there are problems reading from the file // Throws error if there are problems reading from the file
func parseMemInfo(reader io.Reader) (*MemInfo, error) { func parseMemInfo(reader io.Reader) (*MemInfo, error) {
meminfo := &MemInfo{} meminfo := &MemInfo{}

View File

@ -0,0 +1,8 @@
// +build !windows
package system
// DefaultPathEnv is unix style list of directories to search for
// executables. Each directory is separated from the next by a colon
// ':' character .
const DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

View File

@ -0,0 +1,7 @@
// +build windows
package system
// DefaultPathEnv is deliberately empty on Windows as the default path will be set by
// the container. Docker has no context of what the default path should be.
const DefaultPathEnv = ""

View File

@ -0,0 +1,15 @@
package system
import (
"syscall"
)
// fromStatT creates a system.StatT type from a syscall.Stat_t type
func fromStatT(s *syscall.Stat_t) (*StatT, error) {
return &StatT{size: s.Size,
mode: uint32(s.Mode),
uid: s.Uid,
gid: s.Gid,
rdev: uint64(s.Rdev),
mtim: s.Mtim}, nil
}

View File

@ -0,0 +1,17 @@
// +build solaris
package system
import (
"syscall"
)
// fromStatT creates a system.StatT type from a syscall.Stat_t type
func fromStatT(s *syscall.Stat_t) (*StatT, error) {
return &StatT{size: s.Size,
mode: uint32(s.Mode),
uid: s.Uid,
gid: s.Gid,
rdev: uint64(s.Rdev),
mtim: s.Mtim}, nil
}

View File

@ -1,4 +1,4 @@
// +build !linux,!windows,!freebsd // +build !linux,!windows,!freebsd,!solaris,!openbsd
package system package system

View File

@ -0,0 +1,17 @@
// +build linux freebsd
package system
import "syscall"
// Unmount is a platform-specific helper function to call
// the unmount syscall.
func Unmount(dest string) error {
return syscall.Unmount(dest, 0)
}
// CommandLineToArgv should not be used on Unix.
// It simply returns commandLine in the only element in the returned array.
func CommandLineToArgv(commandLine string) ([]string, error) {
return []string{commandLine}, nil
}

View File

@ -0,0 +1,60 @@
package system
import (
"fmt"
"syscall"
"unsafe"
)
// OSVersion is a wrapper for Windows version information
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
type OSVersion struct {
Version uint32
MajorVersion uint8
MinorVersion uint8
Build uint16
}
// GetOSVersion gets the operating system version on Windows. Note that
// docker.exe must be manifested to get the correct version information.
func GetOSVersion() (OSVersion, error) {
var err error
osv := OSVersion{}
osv.Version, err = syscall.GetVersion()
if err != nil {
return osv, fmt.Errorf("Failed to call GetVersion()")
}
osv.MajorVersion = uint8(osv.Version & 0xFF)
osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
osv.Build = uint16(osv.Version >> 16)
return osv, nil
}
// Unmount is a platform-specific helper function to call
// the unmount syscall. Not supported on Windows
func Unmount(dest string) error {
return nil
}
// CommandLineToArgv wraps the Windows syscall to turn a commandline into an argument array.
func CommandLineToArgv(commandLine string) ([]string, error) {
var argc int32
argsPtr, err := syscall.UTF16PtrFromString(commandLine)
if err != nil {
return nil, err
}
argv, err := syscall.CommandLineToArgv(argsPtr, &argc)
if err != nil {
return nil, err
}
defer syscall.LocalFree(syscall.Handle(uintptr(unsafe.Pointer(argv))))
newArgs := make([]string, argc)
for i, v := range (*argv)[:argc] {
newArgs[i] = string(syscall.UTF16ToString((*v)[:]))
}
return newArgs, nil
}

View File

@ -5,7 +5,7 @@ import (
"unsafe" "unsafe"
) )
// LUtimesNano is used to change access and modification time of the speficied path. // LUtimesNano is used to change access and modification time of the specified path.
// It's used for symbol link file because syscall.UtimesNano doesn't support a NOFOLLOW flag atm. // It's used for symbol link file because syscall.UtimesNano doesn't support a NOFOLLOW flag atm.
func LUtimesNano(path string, ts []syscall.Timespec) error { func LUtimesNano(path string, ts []syscall.Timespec) error {
// These are not currently available in syscall // These are not currently available in syscall

View File

@ -1,33 +0,0 @@
// Package units provides helper function to parse and print size and time units
// in human-readable format.
package units
import (
"fmt"
"time"
)
// HumanDuration returns a human-readable approximation of a duration
// (eg. "About a minute", "4 hours ago", etc.).
func HumanDuration(d time.Duration) string {
if seconds := int(d.Seconds()); seconds < 1 {
return "Less than a second"
} else if seconds < 60 {
return fmt.Sprintf("%d seconds", seconds)
} else if minutes := int(d.Minutes()); minutes == 1 {
return "About a minute"
} else if minutes < 60 {
return fmt.Sprintf("%d minutes", minutes)
} else if hours := int(d.Hours()); hours == 1 {
return "About an hour"
} else if hours < 48 {
return fmt.Sprintf("%d hours", hours)
} else if hours < 24*7*2 {
return fmt.Sprintf("%d days", hours/24)
} else if hours < 24*30*3 {
return fmt.Sprintf("%d weeks", hours/24/7)
} else if hours < 24*365*2 {
return fmt.Sprintf("%d months", hours/24/30)
}
return fmt.Sprintf("%d years", int(d.Hours())/24/365)
}

View File

@ -1,95 +0,0 @@
package units
import (
"fmt"
"regexp"
"strconv"
"strings"
)
// See: http://en.wikipedia.org/wiki/Binary_prefix
const (
// Decimal
KB = 1000
MB = 1000 * KB
GB = 1000 * MB
TB = 1000 * GB
PB = 1000 * TB
// Binary
KiB = 1024
MiB = 1024 * KiB
GiB = 1024 * MiB
TiB = 1024 * GiB
PiB = 1024 * TiB
)
type unitMap map[string]int64
var (
decimalMap = unitMap{"k": KB, "m": MB, "g": GB, "t": TB, "p": PB}
binaryMap = unitMap{"k": KiB, "m": MiB, "g": GiB, "t": TiB, "p": PiB}
sizeRegex = regexp.MustCompile(`^(\d+)([kKmMgGtTpP])?[bB]?$`)
)
var decimapAbbrs = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}
var binaryAbbrs = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
// CustomSize returns a human-readable approximation of a size
// using custom format.
func CustomSize(format string, size float64, base float64, _map []string) string {
i := 0
for size >= base {
size = size / base
i++
}
return fmt.Sprintf(format, size, _map[i])
}
// HumanSize returns a human-readable approximation of a size
// capped at 4 valid numbers (eg. "2.746 MB", "796 KB").
func HumanSize(size float64) string {
return CustomSize("%.4g %s", size, 1000.0, decimapAbbrs)
}
// BytesSize returns a human-readable size in bytes, kibibytes,
// mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").
func BytesSize(size float64) string {
return CustomSize("%.4g %s", size, 1024.0, binaryAbbrs)
}
// FromHumanSize returns an integer from a human-readable specification of a
// size using SI standard (eg. "44kB", "17MB").
func FromHumanSize(size string) (int64, error) {
return parseSize(size, decimalMap)
}
// RAMInBytes parses a human-readable string representing an amount of RAM
// in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and
// returns the number of bytes, or -1 if the string is unparseable.
// Units are case-insensitive, and the 'b' suffix is optional.
func RAMInBytes(size string) (int64, error) {
return parseSize(size, binaryMap)
}
// Parses the human-readable size string into the amount it represents.
func parseSize(sizeStr string, uMap unitMap) (int64, error) {
matches := sizeRegex.FindStringSubmatch(sizeStr)
if len(matches) != 3 {
return -1, fmt.Errorf("invalid size: '%s'", sizeStr)
}
size, err := strconv.ParseInt(matches[1], 10, 0)
if err != nil {
return -1, err
}
unitPrefix := strings.ToLower(matches[2])
if mul, ok := uMap[unitPrefix]; ok {
size *= mul
}
return size, nil
}