Bladeren bron

Merge pull request #23392 from Microsoft/RevendorHcsshim

Revendor hcsshim to v0.3.2
John Howard 9 jaren geleden
bovenliggende
commit
30bbf184e9

+ 1 - 1
hack/vendor.sh

@@ -43,7 +43,7 @@ esac
 
 
 # the following lines are in sorted order, FYI
 # the following lines are in sorted order, FYI
 clone git github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62
 clone git github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62
-clone git github.com/Microsoft/hcsshim v0.3.1
+clone git github.com/Microsoft/hcsshim v0.3.2
 clone git github.com/Microsoft/go-winio v0.3.4
 clone git github.com/Microsoft/go-winio v0.3.4
 clone git github.com/Sirupsen/logrus v0.10.0 # logrus is a common dependency among multiple deps
 clone git github.com/Sirupsen/logrus v0.10.0 # logrus is a common dependency among multiple deps
 clone git github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
 clone git github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a

+ 19 - 3
vendor/src/github.com/Microsoft/hcsshim/container.go

@@ -82,6 +82,9 @@ func CreateContainer(id string, c *ContainerConfig) (Container, error) {
 
 
 	err = processAsyncHcsResult(createError, resultp, container.callbackNumber, hcsNotificationSystemCreateCompleted, &defaultTimeout)
 	err = processAsyncHcsResult(createError, resultp, container.callbackNumber, hcsNotificationSystemCreateCompleted, &defaultTimeout)
 	if err != nil {
 	if err != nil {
+		if err == ErrTimeout || err == ErrUnexpectedProcessAbort || err == ErrUnexpectedContainerExit {
+			return nil, err
+		}
 		err := &ContainerError{Container: container, Operation: operation, ExtraInfo: configuration, Err: err}
 		err := &ContainerError{Container: container, Operation: operation, ExtraInfo: configuration, Err: err}
 		logrus.Error(err)
 		logrus.Error(err)
 		return nil, err
 		return nil, err
@@ -131,6 +134,9 @@ func (container *container) Start() error {
 	err := hcsStartComputeSystemTP5(container.handle, nil, &resultp)
 	err := hcsStartComputeSystemTP5(container.handle, nil, &resultp)
 	err = processAsyncHcsResult(err, resultp, container.callbackNumber, hcsNotificationSystemStartCompleted, &defaultTimeout)
 	err = processAsyncHcsResult(err, resultp, container.callbackNumber, hcsNotificationSystemStartCompleted, &defaultTimeout)
 	if err != nil {
 	if err != nil {
+		if err == ErrTimeout || err == ErrUnexpectedProcessAbort || err == ErrUnexpectedContainerExit {
+			return err
+		}
 		err := &ContainerError{Container: container, Operation: operation, Err: err}
 		err := &ContainerError{Container: container, Operation: operation, Err: err}
 		logrus.Error(err)
 		logrus.Error(err)
 		return err
 		return err
@@ -195,6 +201,9 @@ func (container *container) Wait() error {
 	if hcsCallbacksSupported {
 	if hcsCallbacksSupported {
 		err := waitForNotification(container.callbackNumber, hcsNotificationSystemExited, nil)
 		err := waitForNotification(container.callbackNumber, hcsNotificationSystemExited, nil)
 		if err != nil {
 		if err != nil {
+			if err == ErrUnexpectedProcessAbort || err == ErrUnexpectedContainerExit {
+				return err
+			}
 			err := &ContainerError{Container: container, Operation: operation, Err: err}
 			err := &ContainerError{Container: container, Operation: operation, Err: err}
 			logrus.Error(err)
 			logrus.Error(err)
 			return err
 			return err
@@ -225,9 +234,10 @@ func (container *container) WaitTimeout(timeout time.Duration) error {
 
 
 	if hcsCallbacksSupported {
 	if hcsCallbacksSupported {
 		err := waitForNotification(container.callbackNumber, hcsNotificationSystemExited, &timeout)
 		err := waitForNotification(container.callbackNumber, hcsNotificationSystemExited, &timeout)
-		if err == ErrTimeout {
-			return ErrTimeout
-		} else if err != nil {
+		if err != nil {
+			if err == ErrTimeout || err == ErrUnexpectedProcessAbort || err == ErrUnexpectedContainerExit {
+				return err
+			}
 			err := &ContainerError{Container: container, Operation: operation, Err: err}
 			err := &ContainerError{Container: container, Operation: operation, Err: err}
 			logrus.Error(err)
 			logrus.Error(err)
 			return err
 			return err
@@ -313,6 +323,9 @@ func (container *container) Pause() error {
 	err := hcsPauseComputeSystemTP5(container.handle, nil, &resultp)
 	err := hcsPauseComputeSystemTP5(container.handle, nil, &resultp)
 	err = processAsyncHcsResult(err, resultp, container.callbackNumber, hcsNotificationSystemPauseCompleted, &defaultTimeout)
 	err = processAsyncHcsResult(err, resultp, container.callbackNumber, hcsNotificationSystemPauseCompleted, &defaultTimeout)
 	if err != nil {
 	if err != nil {
+		if err == ErrTimeout || err == ErrUnexpectedProcessAbort || err == ErrUnexpectedContainerExit {
+			return err
+		}
 		err := &ContainerError{Container: container, Operation: operation, Err: err}
 		err := &ContainerError{Container: container, Operation: operation, Err: err}
 		logrus.Error(err)
 		logrus.Error(err)
 		return err
 		return err
@@ -334,6 +347,9 @@ func (container *container) Resume() error {
 	err := hcsResumeComputeSystemTP5(container.handle, nil, &resultp)
 	err := hcsResumeComputeSystemTP5(container.handle, nil, &resultp)
 	err = processAsyncHcsResult(err, resultp, container.callbackNumber, hcsNotificationSystemResumeCompleted, &defaultTimeout)
 	err = processAsyncHcsResult(err, resultp, container.callbackNumber, hcsNotificationSystemResumeCompleted, &defaultTimeout)
 	if err != nil {
 	if err != nil {
+		if err == ErrTimeout || err == ErrUnexpectedProcessAbort || err == ErrUnexpectedContainerExit {
+			return err
+		}
 		err := &ContainerError{Container: container, Operation: operation, Err: err}
 		err := &ContainerError{Container: container, Operation: operation, Err: err}
 		logrus.Error(err)
 		logrus.Error(err)
 		return err
 		return err

+ 26 - 0
vendor/src/github.com/Microsoft/hcsshim/expandsandboxsize.go

@@ -0,0 +1,26 @@
+package hcsshim
+
+import "github.com/Sirupsen/logrus"
+
+// ExpandSandboxSize expands the size of a layer to at least size bytes.
+func ExpandSandboxSize(info DriverInfo, layerId string, size uint64) error {
+	title := "hcsshim::ExpandSandboxSize "
+	logrus.Debugf(title+"layerId=%s size=%d", layerId, size)
+
+	// Convert info to API calling convention
+	infop, err := convertDriverInfo(info)
+	if err != nil {
+		logrus.Error(err)
+		return err
+	}
+
+	err = expandSandboxSize(&infop, layerId, size)
+	if err != nil {
+		err = makeErrorf(err, title, "layerId=%s  size=%d", layerId, size)
+		logrus.Error(err)
+		return err
+	}
+
+	logrus.Debugf(title+"- succeeded layerId=%s size=%d", layerId, size)
+	return nil
+}

+ 1 - 0
vendor/src/github.com/Microsoft/hcsshim/hcsshim.go

@@ -19,6 +19,7 @@ import (
 //sys copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CopyLayer?
 //sys copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CopyLayer?
 //sys createLayer(info *driverInfo, id string, parent string) (hr error) = vmcompute.CreateLayer?
 //sys createLayer(info *driverInfo, id string, parent string) (hr error) = vmcompute.CreateLayer?
 //sys createSandboxLayer(info *driverInfo, id string, parent string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CreateSandboxLayer?
 //sys createSandboxLayer(info *driverInfo, id string, parent string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CreateSandboxLayer?
+//sys expandSandboxSize(info *driverInfo, id string, size uint64) (hr error) = vmcompute.ExpandSandboxSize?
 //sys deactivateLayer(info *driverInfo, id string) (hr error) = vmcompute.DeactivateLayer?
 //sys deactivateLayer(info *driverInfo, id string) (hr error) = vmcompute.DeactivateLayer?
 //sys destroyLayer(info *driverInfo, id string) (hr error) = vmcompute.DestroyLayer?
 //sys destroyLayer(info *driverInfo, id string) (hr error) = vmcompute.DestroyLayer?
 //sys exportLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.ExportLayer?
 //sys exportLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.ExportLayer?

+ 10 - 0
vendor/src/github.com/Microsoft/hcsshim/hnsfuncs.go

@@ -20,6 +20,16 @@ type QosPolicy struct {
 	MaximumOutgoingBandwidthInBytes uint64
 	MaximumOutgoingBandwidthInBytes uint64
 }
 }
 
 
+type VlanPolicy struct {
+	Type string
+	VLAN uint
+}
+
+type VsidPolicy struct {
+	Type string
+	VSID uint
+}
+
 // Subnet is assoicated with a network and represents a list
 // Subnet is assoicated with a network and represents a list
 // of subnets available to the network
 // of subnets available to the network
 type Subnet struct {
 type Subnet struct {

+ 1 - 0
vendor/src/github.com/Microsoft/hcsshim/interface.go

@@ -46,6 +46,7 @@ type ContainerConfig struct {
 	IgnoreFlushesDuringBoot bool        // Optimization hint for container startup in Windows
 	IgnoreFlushesDuringBoot bool        // Optimization hint for container startup in Windows
 	LayerFolderPath         string      // Where the layer folders are located
 	LayerFolderPath         string      // Where the layer folders are located
 	Layers                  []Layer     // List of storage layers
 	Layers                  []Layer     // List of storage layers
+	Credentials             string      `json:",omitempty"` // Credentials information
 	ProcessorWeight         uint64      `json:",omitempty"` // CPU Shares 0..10000 on Windows; where 0 will be omitted and HCS will default.
 	ProcessorWeight         uint64      `json:",omitempty"` // CPU Shares 0..10000 on Windows; where 0 will be omitted and HCS will default.
 	ProcessorMaximum        int64       `json:",omitempty"` // CPU maximum usage percent 1..100
 	ProcessorMaximum        int64       `json:",omitempty"` // CPU maximum usage percent 1..100
 	StorageIOPSMaximum      uint64      `json:",omitempty"` // Maximum Storage IOPS
 	StorageIOPSMaximum      uint64      `json:",omitempty"` // Maximum Storage IOPS

+ 7 - 3
vendor/src/github.com/Microsoft/hcsshim/process.go

@@ -103,6 +103,9 @@ func (process *process) Wait() error {
 	if hcsCallbacksSupported {
 	if hcsCallbacksSupported {
 		err := waitForNotification(process.callbackNumber, hcsNotificationProcessExited, nil)
 		err := waitForNotification(process.callbackNumber, hcsNotificationProcessExited, nil)
 		if err != nil {
 		if err != nil {
+			if err == ErrUnexpectedProcessAbort || err == ErrUnexpectedContainerExit {
+				return err
+			}
 			err := &ProcessError{Operation: operation, Process: process, Err: err}
 			err := &ProcessError{Operation: operation, Process: process, Err: err}
 			logrus.Error(err)
 			logrus.Error(err)
 			return err
 			return err
@@ -129,9 +132,10 @@ func (process *process) WaitTimeout(timeout time.Duration) error {
 
 
 	if hcsCallbacksSupported {
 	if hcsCallbacksSupported {
 		err := waitForNotification(process.callbackNumber, hcsNotificationProcessExited, &timeout)
 		err := waitForNotification(process.callbackNumber, hcsNotificationProcessExited, &timeout)
-		if err == ErrTimeout {
-			return ErrTimeout
-		} else if err != nil {
+		if err != nil {
+			if err == ErrTimeout || err == ErrUnexpectedProcessAbort || err == ErrUnexpectedContainerExit {
+				return err
+			}
 			err := &ProcessError{Operation: operation, Process: process, Err: err}
 			err := &ProcessError{Operation: operation, Process: process, Err: err}
 			logrus.Error(err)
 			logrus.Error(err)
 			return err
 			return err

+ 21 - 0
vendor/src/github.com/Microsoft/hcsshim/zhcsshim.go

@@ -17,6 +17,7 @@ var (
 	procCopyLayer                                  = modvmcompute.NewProc("CopyLayer")
 	procCopyLayer                                  = modvmcompute.NewProc("CopyLayer")
 	procCreateLayer                                = modvmcompute.NewProc("CreateLayer")
 	procCreateLayer                                = modvmcompute.NewProc("CreateLayer")
 	procCreateSandboxLayer                         = modvmcompute.NewProc("CreateSandboxLayer")
 	procCreateSandboxLayer                         = modvmcompute.NewProc("CreateSandboxLayer")
+	procExpandSandboxSize                          = modvmcompute.NewProc("ExpandSandboxSize")
 	procDeactivateLayer                            = modvmcompute.NewProc("DeactivateLayer")
 	procDeactivateLayer                            = modvmcompute.NewProc("DeactivateLayer")
 	procDestroyLayer                               = modvmcompute.NewProc("DestroyLayer")
 	procDestroyLayer                               = modvmcompute.NewProc("DestroyLayer")
 	procExportLayer                                = modvmcompute.NewProc("ExportLayer")
 	procExportLayer                                = modvmcompute.NewProc("ExportLayer")
@@ -184,6 +185,26 @@ func _createSandboxLayer(info *driverInfo, id *uint16, parent *uint16, descripto
 	return
 	return
 }
 }
 
 
+func expandSandboxSize(info *driverInfo, id string, size uint64) (hr error) {
+	var _p0 *uint16
+	_p0, hr = syscall.UTF16PtrFromString(id)
+	if hr != nil {
+		return
+	}
+	return _expandSandboxSize(info, _p0, size)
+}
+
+func _expandSandboxSize(info *driverInfo, id *uint16, size uint64) (hr error) {
+	if hr = procExpandSandboxSize.Find(); hr != nil {
+		return
+	}
+	r0, _, _ := syscall.Syscall(procExpandSandboxSize.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(size))
+	if int32(r0) < 0 {
+		hr = syscall.Errno(win32FromHresult(r0))
+	}
+	return
+}
+
 func deactivateLayer(info *driverInfo, id string) (hr error) {
 func deactivateLayer(info *driverInfo, id string) (hr error) {
 	var _p0 *uint16
 	var _p0 *uint16
 	_p0, hr = syscall.UTF16PtrFromString(id)
 	_p0, hr = syscall.UTF16PtrFromString(id)