full diff: https://2226e083fc390003ae5aa8325c3c92789afa0e7a...b3f49c06ffaeef24d09c6c08ec8ec8425a0303e2 includes: - microsoft/hcsshim#718 wclayer: Work around Windows bug when expanding sandbox size - fixes microsoft/hcsshim#708 Windows Host Compute Service bug breaks docker (and other) sandboxes bigger than 20G on Windows 1903 - fixes microsoft/hcsshim#624The hcsshim on Windows 10 1903 always fails to build Docker image - fixes/addresses docker/for-win#3884 An error occurred while attempting to build Docker image (especially this comment and the next comments after: https://github.com/docker/for-win/issues/3884#issuecomment-498939672) - fixes/addresses docker/for-win#4100 Windows 1903 fails when storage-opt used - fixes moby/moby#36831 hcsshim::PrepareLayer failed in Win32: The parameter is incorrect (https://github.com/moby/moby/issues/36831#issuecomment-498612392) - fixes Stannieman/audacity-with-asio-builder#5 Docker won't build container - fixes MicrosoftDocs/visualstudio-docs#3523 Error when running build with storage-opts set - fixes moby/moby#39524 Docker build windows 19.03 --storage-opt size>20G Note that this is a temporary workaround for a bug in the platform, and will be reverted once that is addressed: - microsoft/hcsshim#721 Revert 718 when Windows 19H1 has expand sandbox fix Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
70 lines
2.1 KiB
Go
70 lines
2.1 KiB
Go
package hcs
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/Microsoft/hcsshim/internal/log"
|
|
)
|
|
|
|
func processAsyncHcsResult(ctx context.Context, err error, resultJSON string, callbackNumber uintptr, expectedNotification hcsNotification, timeout *time.Duration) ([]ErrorEvent, error) {
|
|
events := processHcsResult(ctx, resultJSON)
|
|
if IsPending(err) {
|
|
return nil, waitForNotification(ctx, callbackNumber, expectedNotification, timeout)
|
|
}
|
|
|
|
return events, err
|
|
}
|
|
|
|
func waitForNotification(ctx context.Context, callbackNumber uintptr, expectedNotification hcsNotification, timeout *time.Duration) error {
|
|
callbackMapLock.RLock()
|
|
if _, ok := callbackMap[callbackNumber]; !ok {
|
|
callbackMapLock.RUnlock()
|
|
log.G(ctx).WithField("callbackNumber", callbackNumber).Error("failed to waitForNotification: callbackNumber does not exist in callbackMap")
|
|
return ErrHandleClose
|
|
}
|
|
channels := callbackMap[callbackNumber].channels
|
|
callbackMapLock.RUnlock()
|
|
|
|
expectedChannel := channels[expectedNotification]
|
|
if expectedChannel == nil {
|
|
log.G(ctx).WithField("type", expectedNotification).Error("unknown notification type in waitForNotification")
|
|
return ErrInvalidNotificationType
|
|
}
|
|
|
|
var c <-chan time.Time
|
|
if timeout != nil {
|
|
timer := time.NewTimer(*timeout)
|
|
c = timer.C
|
|
defer timer.Stop()
|
|
}
|
|
|
|
select {
|
|
case err, ok := <-expectedChannel:
|
|
if !ok {
|
|
return ErrHandleClose
|
|
}
|
|
return err
|
|
case err, ok := <-channels[hcsNotificationSystemExited]:
|
|
if !ok {
|
|
return ErrHandleClose
|
|
}
|
|
// If the expected notification is hcsNotificationSystemExited which of the two selects
|
|
// chosen is random. Return the raw error if hcsNotificationSystemExited is expected
|
|
if channels[hcsNotificationSystemExited] == expectedChannel {
|
|
return err
|
|
}
|
|
return ErrUnexpectedContainerExit
|
|
case _, ok := <-channels[hcsNotificationServiceDisconnect]:
|
|
if !ok {
|
|
return ErrHandleClose
|
|
}
|
|
// hcsNotificationServiceDisconnect should never be an expected notification
|
|
// it does not need the same handling as hcsNotificationSystemExited
|
|
return ErrUnexpectedProcessAbort
|
|
case <-c:
|
|
return ErrTimeout
|
|
}
|
|
return nil
|
|
}
|