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>
99 lines
2.8 KiB
Go
99 lines
2.8 KiB
Go
package hcsshim
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/Microsoft/hcsshim/internal/hcs"
|
|
)
|
|
|
|
// ContainerError is an error encountered in HCS
|
|
type process struct {
|
|
p *hcs.Process
|
|
waitOnce sync.Once
|
|
waitCh chan struct{}
|
|
waitErr error
|
|
}
|
|
|
|
// Pid returns the process ID of the process within the container.
|
|
func (process *process) Pid() int {
|
|
return process.p.Pid()
|
|
}
|
|
|
|
// Kill signals the process to terminate but does not wait for it to finish terminating.
|
|
func (process *process) Kill() error {
|
|
found, err := process.p.Kill(context.Background())
|
|
if err != nil {
|
|
return convertProcessError(err, process)
|
|
}
|
|
if !found {
|
|
return &ProcessError{Process: process, Err: ErrElementNotFound, Operation: "hcsshim::Process::Kill"}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Wait waits for the process to exit.
|
|
func (process *process) Wait() error {
|
|
return convertProcessError(process.p.Wait(), process)
|
|
}
|
|
|
|
// WaitTimeout waits for the process to exit or the duration to elapse. It returns
|
|
// false if timeout occurs.
|
|
func (process *process) WaitTimeout(timeout time.Duration) error {
|
|
process.waitOnce.Do(func() {
|
|
process.waitCh = make(chan struct{})
|
|
go func() {
|
|
process.waitErr = process.Wait()
|
|
close(process.waitCh)
|
|
}()
|
|
})
|
|
t := time.NewTimer(timeout)
|
|
defer t.Stop()
|
|
select {
|
|
case <-t.C:
|
|
return &ProcessError{Process: process, Err: ErrTimeout, Operation: "hcsshim::Process::Wait"}
|
|
case <-process.waitCh:
|
|
return process.waitErr
|
|
}
|
|
}
|
|
|
|
// ExitCode returns the exit code of the process. The process must have
|
|
// already terminated.
|
|
func (process *process) ExitCode() (int, error) {
|
|
code, err := process.p.ExitCode()
|
|
if err != nil {
|
|
err = convertProcessError(err, process)
|
|
}
|
|
return code, err
|
|
}
|
|
|
|
// ResizeConsole resizes the console of the process.
|
|
func (process *process) ResizeConsole(width, height uint16) error {
|
|
return convertProcessError(process.p.ResizeConsole(context.Background(), width, height), process)
|
|
}
|
|
|
|
// Stdio returns the stdin, stdout, and stderr pipes, respectively. Closing
|
|
// these pipes does not close the underlying pipes; it should be possible to
|
|
// call this multiple times to get multiple interfaces.
|
|
func (process *process) Stdio() (io.WriteCloser, io.ReadCloser, io.ReadCloser, error) {
|
|
stdin, stdout, stderr, err := process.p.StdioLegacy()
|
|
if err != nil {
|
|
err = convertProcessError(err, process)
|
|
}
|
|
return stdin, stdout, stderr, err
|
|
}
|
|
|
|
// CloseStdin closes the write side of the stdin pipe so that the process is
|
|
// notified on the read side that there is no more data in stdin.
|
|
func (process *process) CloseStdin() error {
|
|
return convertProcessError(process.p.CloseStdin(context.Background()), process)
|
|
}
|
|
|
|
// Close cleans up any state associated with the process but does not kill
|
|
// or wait on it.
|
|
func (process *process) Close() error {
|
|
return convertProcessError(process.p.Close(), process)
|
|
}
|