Browse code

Windows: Remove osversion from OCI

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2016/09/17 02:04:53
Showing 6 changed files
... ...
@@ -35,8 +35,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
35 35
 		return nil, fmt.Errorf("Failed to graph.Get on ImageID %s - %s", c.ImageID, err)
36 36
 	}
37 37
 
38
-	s.Platform.OSVersion = img.OSVersion
39
-
40 38
 	// In base spec
41 39
 	s.Hostname = c.FullHostname()
42 40
 
... ...
@@ -84,13 +84,6 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir
84 84
 		configuration.HvRuntime = &hcsshim.HvRuntime{
85 85
 			ImagePath: spec.Windows.HvRuntime.ImagePath,
86 86
 		}
87
-
88
-		// Images with build version < 14350 don't support running with clone, but
89
-		// Windows cannot automatically detect this. Explicitly block cloning in this
90
-		// case.
91
-		if build := buildFromVersion(spec.Platform.OSVersion); build > 0 && build < 14350 {
92
-			configuration.HvRuntime.SkipTemplate = true
93
-		}
94 87
 	}
95 88
 
96 89
 	if configuration.HvPartition {
... ...
@@ -236,9 +229,6 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly
236 236
 	iopipe := &IOPipe{Terminal: procToAdd.Terminal}
237 237
 	iopipe.Stdin = createStdInCloser(stdin, newProcess)
238 238
 
239
-	// TEMP: Work around Windows BS/DEL behavior.
240
-	iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, container.ociSpec.Platform.OSVersion, procToAdd.Terminal)
241
-
242 239
 	// Convert io.ReadClosers to io.Readers
243 240
 	if stdout != nil {
244 241
 		iopipe.Stdout = openReaderFromPipe(stdout)
... ...
@@ -122,9 +122,6 @@ func (ctr *container) start() error {
122 122
 
123 123
 	iopipe.Stdin = createStdInCloser(stdin, hcsProcess)
124 124
 
125
-	// TEMP: Work around Windows BS/DEL behavior.
126
-	iopipe.Stdin = fixStdinBackspaceBehavior(iopipe.Stdin, ctr.ociSpec.Platform.OSVersion, ctr.ociSpec.Process.Terminal)
127
-
128 125
 	// Convert io.ReadClosers to io.Readers
129 126
 	if stdout != nil {
130 127
 		iopipe.Stdout = openReaderFromPipe(stdout)
... ...
@@ -29,40 +29,6 @@ func openReaderFromPipe(p io.ReadCloser) io.Reader {
29 29
 	return r
30 30
 }
31 31
 
32
-// fixStdinBackspaceBehavior works around a bug in Windows before build 14350
33
-// where it interpreted DEL as VK_DELETE instead of as VK_BACK. This replaces
34
-// DEL with BS to work around this.
35
-func fixStdinBackspaceBehavior(w io.WriteCloser, osversion string, tty bool) io.WriteCloser {
36
-	if !tty {
37
-		return w
38
-	}
39
-	if build := buildFromVersion(osversion); build == 0 || build >= 14350 {
40
-		return w
41
-	}
42
-
43
-	return &delToBsWriter{w}
44
-}
45
-
46
-type delToBsWriter struct {
47
-	io.WriteCloser
48
-}
49
-
50
-func (w *delToBsWriter) Write(b []byte) (int, error) {
51
-	const (
52
-		backspace = 0x8
53
-		del       = 0x7f
54
-	)
55
-	bc := make([]byte, len(b))
56
-	for i, c := range b {
57
-		if c == del {
58
-			bc[i] = backspace
59
-		} else {
60
-			bc[i] = c
61
-		}
62
-	}
63
-	return w.WriteCloser.Write(bc)
64
-}
65
-
66 32
 type stdInCloser struct {
67 33
 	io.WriteCloser
68 34
 	hcsshim.Process
... ...
@@ -1,9 +1,6 @@
1 1
 package libcontainerd
2 2
 
3
-import (
4
-	"strconv"
5
-	"strings"
6
-)
3
+import "strings"
7 4
 
8 5
 // setupEnvironmentVariables converts a string array of environment variables
9 6
 // 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 {
27 27
 func (s *FlushOption) Apply(interface{}) error {
28 28
 	return nil
29 29
 }
30
-
31
-// buildFromVersion takes an image version string and returns the Windows build
32
-// number. It returns 0 if the build number is not present.
33
-func buildFromVersion(osver string) int {
34
-	v := strings.Split(osver, ".")
35
-	if len(v) < 3 {
36
-		return 0
37
-	}
38
-	if build, err := strconv.Atoi(v[2]); err == nil {
39
-		return build
40
-	}
41
-	return 0
42
-}
... ...
@@ -91,8 +91,6 @@ type Platform struct {
91 91
 	OS string `json:"os"`
92 92
 	// Arch is the architecture
93 93
 	Arch string `json:"arch"`
94
-	// OSVersion is the version of the operating system.
95
-	OSVersion string `json:"os.version,omitempty"`
96 94
 }
97 95
 
98 96
 // Mount specifies a mount for a container.