From 72de562943a9bfbc44d24c80dfc9d0dc112ab0f4 Mon Sep 17 00:00:00 2001 From: John Howard Date: Fri, 16 Sep 2016 10:04:53 -0700 Subject: [PATCH] Windows: Remove osversion from OCI Signed-off-by: John Howard --- daemon/oci_windows.go | 2 -- libcontainerd/client_windows.go | 10 -------- libcontainerd/container_windows.go | 3 --- libcontainerd/process_windows.go | 34 ------------------------- libcontainerd/utils_windows.go | 18 +------------ libcontainerd/windowsoci/oci_windows.go | 2 -- 6 files changed, 1 insertion(+), 68 deletions(-) diff --git a/daemon/oci_windows.go b/daemon/oci_windows.go index 1b53ee9104..12821d4562 100644 --- a/daemon/oci_windows.go +++ b/daemon/oci_windows.go @@ -35,8 +35,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e return nil, fmt.Errorf("Failed to graph.Get on ImageID %s - %s", c.ImageID, err) } - s.Platform.OSVersion = img.OSVersion - // In base spec s.Hostname = c.FullHostname() diff --git a/libcontainerd/client_windows.go b/libcontainerd/client_windows.go index 7f8d55579f..07cf17abe3 100644 --- a/libcontainerd/client_windows.go +++ b/libcontainerd/client_windows.go @@ -84,13 +84,6 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir configuration.HvRuntime = &hcsshim.HvRuntime{ ImagePath: spec.Windows.HvRuntime.ImagePath, } - - // Images with build version < 14350 don't support running with clone, but - // Windows cannot automatically detect this. Explicitly block cloning in this - // case. - if build := buildFromVersion(spec.Platform.OSVersion); build > 0 && build < 14350 { - configuration.HvRuntime.SkipTemplate = true - } } if configuration.HvPartition { @@ -236,9 +229,6 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly iopipe := &IOPipe{Terminal: procToAdd.Terminal} iopipe.Stdin = createStdInCloser(stdin, newProcess) - // TEMP: Work around Windows BS/DEL behavior. - iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, container.ociSpec.Platform.OSVersion, procToAdd.Terminal) - // Convert io.ReadClosers to io.Readers if stdout != nil { iopipe.Stdout = openReaderFromPipe(stdout) diff --git a/libcontainerd/container_windows.go b/libcontainerd/container_windows.go index ffbadb5ce9..f3214d8a77 100644 --- a/libcontainerd/container_windows.go +++ b/libcontainerd/container_windows.go @@ -122,9 +122,6 @@ func (ctr *container) start() error { iopipe.Stdin = createStdInCloser(stdin, hcsProcess) - // TEMP: Work around Windows BS/DEL behavior. - iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, ctr.ociSpec.Platform.OSVersion, ctr.ociSpec.Process.Terminal) - // Convert io.ReadClosers to io.Readers if stdout != nil { iopipe.Stdout = openReaderFromPipe(stdout) diff --git a/libcontainerd/process_windows.go b/libcontainerd/process_windows.go index 01427246f3..d783c2761a 100644 --- a/libcontainerd/process_windows.go +++ b/libcontainerd/process_windows.go @@ -29,40 +29,6 @@ func openReaderFromPipe(p io.ReadCloser) io.Reader { return r } -// fixStdinBackspaceBehavior works around a bug in Windows before build 14350 -// where it interpreted DEL as VK_DELETE instead of as VK_BACK. This replaces -// DEL with BS to work around this. -func fixStdinBackspaceBehavior(w io.WriteCloser, osversion string, tty bool) io.WriteCloser { - if !tty { - return w - } - if build := buildFromVersion(osversion); build == 0 || build >= 14350 { - return w - } - - return &delToBsWriter{w} -} - -type delToBsWriter struct { - io.WriteCloser -} - -func (w *delToBsWriter) Write(b []byte) (int, error) { - const ( - backspace = 0x8 - del = 0x7f - ) - bc := make([]byte, len(b)) - for i, c := range b { - if c == del { - bc[i] = backspace - } else { - bc[i] = c - } - } - return w.WriteCloser.Write(bc) -} - type stdInCloser struct { io.WriteCloser hcsshim.Process diff --git a/libcontainerd/utils_windows.go b/libcontainerd/utils_windows.go index fcd72145c6..fa63e82bc3 100644 --- a/libcontainerd/utils_windows.go +++ b/libcontainerd/utils_windows.go @@ -1,9 +1,6 @@ package libcontainerd -import ( - "strconv" - "strings" -) +import "strings" // setupEnvironmentVariables converts a string array of environment variables // into a map as required by the HCS. Source array is in format [v1=k1] [v2=k2] etc. @@ -27,16 +24,3 @@ func (s *ServicingOption) Apply(interface{}) error { func (s *FlushOption) Apply(interface{}) error { return nil } - -// buildFromVersion takes an image version string and returns the Windows build -// number. It returns 0 if the build number is not present. -func buildFromVersion(osver string) int { - v := strings.Split(osver, ".") - if len(v) < 3 { - return 0 - } - if build, err := strconv.Atoi(v[2]); err == nil { - return build - } - return 0 -} diff --git a/libcontainerd/windowsoci/oci_windows.go b/libcontainerd/windowsoci/oci_windows.go index ab70cc989c..a520f001b5 100644 --- a/libcontainerd/windowsoci/oci_windows.go +++ b/libcontainerd/windowsoci/oci_windows.go @@ -91,8 +91,6 @@ type Platform struct { OS string `json:"os"` // Arch is the architecture Arch string `json:"arch"` - // OSVersion is the version of the operating system. - OSVersion string `json:"os.version,omitempty"` } // Mount specifies a mount for a container.