The Windows TP5 image is not compatible with the Hyper-V isolated
container clone feature. Detect old images and pass a flag specifying that
clone should not be enabled.
Signed-off-by: John Starks <jostarks@microsoft.com>
| ... | ... |
@@ -85,6 +85,13 @@ func (clnt *client) Create(containerID string, spec Spec, options ...CreateOptio |
| 85 | 85 |
configuration.HvRuntime = &hcsshim.HvRuntime{
|
| 86 | 86 |
ImagePath: spec.Windows.HvRuntime.ImagePath, |
| 87 | 87 |
} |
| 88 |
+ |
|
| 89 |
+ // Images with build verison < 14350 don't support running with clone, but |
|
| 90 |
+ // Windows cannot automatically detect this. Explicitly block cloning in this |
|
| 91 |
+ // case. |
|
| 92 |
+ if build := buildFromVersion(spec.Platform.OSVersion); build > 0 && build < 14350 {
|
|
| 93 |
+ configuration.HvRuntime.SkipTemplate = true |
|
| 94 |
+ } |
|
| 88 | 95 |
} |
| 89 | 96 |
|
| 90 | 97 |
if configuration.HvPartition {
|
| ... | ... |
@@ -2,8 +2,6 @@ package libcontainerd |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"io" |
| 5 |
- "strconv" |
|
| 6 |
- "strings" |
|
| 7 | 5 |
|
| 8 | 6 |
"github.com/Microsoft/hcsshim" |
| 9 | 7 |
) |
| ... | ... |
@@ -38,12 +36,7 @@ func fixStdinBackspaceBehavior(w io.WriteCloser, osversion string, tty bool) io. |
| 38 | 38 |
if !tty {
|
| 39 | 39 |
return w |
| 40 | 40 |
} |
| 41 |
- v := strings.Split(osversion, ".") |
|
| 42 |
- if len(v) < 3 {
|
|
| 43 |
- return w |
|
| 44 |
- } |
|
| 45 |
- |
|
| 46 |
- if build, err := strconv.Atoi(v[2]); err != nil || build >= 14350 {
|
|
| 41 |
+ if build := buildFromVersion(osversion); build == 0 || build >= 14350 {
|
|
| 47 | 42 |
return w |
| 48 | 43 |
} |
| 49 | 44 |
|
| ... | ... |
@@ -1,6 +1,9 @@ |
| 1 | 1 |
package libcontainerd |
| 2 | 2 |
|
| 3 |
-import "strings" |
|
| 3 |
+import ( |
|
| 4 |
+ "strconv" |
|
| 5 |
+ "strings" |
|
| 6 |
+) |
|
| 4 | 7 |
|
| 5 | 8 |
// setupEnvironmentVariables convert a string array of environment variables |
| 6 | 9 |
// into a map as required by the HCS. Source array is in format [v1=k1] [v2=k2] etc. |
| ... | ... |
@@ -19,3 +22,16 @@ func setupEnvironmentVariables(a []string) map[string]string {
|
| 19 | 19 |
func (s *ServicingOption) Apply(interface{}) error {
|
| 20 | 20 |
return nil |
| 21 | 21 |
} |
| 22 |
+ |
|
| 23 |
+// buildFromVersion takes an image version string and returns the Windows build |
|
| 24 |
+// number. It returns 0 if the build number is not present. |
|
| 25 |
+func buildFromVersion(osver string) int {
|
|
| 26 |
+ v := strings.Split(osver, ".") |
|
| 27 |
+ if len(v) < 3 {
|
|
| 28 |
+ return 0 |
|
| 29 |
+ } |
|
| 30 |
+ if build, err := strconv.Atoi(v[2]); err == nil {
|
|
| 31 |
+ return build |
|
| 32 |
+ } |
|
| 33 |
+ return 0 |
|
| 34 |
+} |