Browse code

Skip evaluation of symlinks to data root on IoT Core

Signed-off-by: Darren Stahl <darst@microsoft.com>

Darren Stahl authored on 2017/06/01 09:11:42
Showing 4 changed files
... ...
@@ -40,7 +40,6 @@ import (
40 40
 	"github.com/docker/docker/layer"
41 41
 	"github.com/docker/docker/libcontainerd"
42 42
 	"github.com/docker/docker/migrate/v1"
43
-	"github.com/docker/docker/pkg/fileutils"
44 43
 	"github.com/docker/docker/pkg/idtools"
45 44
 	"github.com/docker/docker/pkg/plugingetter"
46 45
 	"github.com/docker/docker/pkg/registrar"
... ...
@@ -537,7 +536,7 @@ func NewDaemon(config *config.Config, registryService registry.Service, containe
537 537
 	if err != nil {
538 538
 		return nil, fmt.Errorf("Unable to get the TempDir under %s: %s", config.Root, err)
539 539
 	}
540
-	realTmp, err := fileutils.ReadSymlinkedDirectory(tmp)
540
+	realTmp, err := getRealPath(tmp)
541 541
 	if err != nil {
542 542
 		return nil, fmt.Errorf("Unable to get the full path to the TempDir (%s): %s", tmp, err)
543 543
 	}
... ...
@@ -1143,7 +1142,7 @@ func CreateDaemonRoot(config *config.Config) error {
1143 1143
 	if _, err := os.Stat(config.Root); err != nil && os.IsNotExist(err) {
1144 1144
 		realRoot = config.Root
1145 1145
 	} else {
1146
-		realRoot, err = fileutils.ReadSymlinkedDirectory(config.Root)
1146
+		realRoot, err = getRealPath(config.Root)
1147 1147
 		if err != nil {
1148 1148
 			return fmt.Errorf("Unable to get the full path to root (%s): %s", config.Root, err)
1149 1149
 		}
... ...
@@ -9,6 +9,7 @@ import (
9 9
 	"strings"
10 10
 
11 11
 	"github.com/Sirupsen/logrus"
12
+	"github.com/docker/docker/pkg/fileutils"
12 13
 	"github.com/docker/docker/pkg/mount"
13 14
 )
14 15
 
... ...
@@ -86,3 +87,7 @@ func getCleanPatterns(id string) (regexps []*regexp.Regexp) {
86 86
 	}
87 87
 	return
88 88
 }
89
+
90
+func getRealPath(path string) (string, error) {
91
+	return fileutils.ReadSymlinkedDirectory(path)
92
+}
... ...
@@ -13,6 +13,7 @@ import (
13 13
 	"github.com/docker/docker/container"
14 14
 	"github.com/docker/docker/image"
15 15
 	"github.com/docker/docker/layer"
16
+	"github.com/docker/docker/pkg/fileutils"
16 17
 	"github.com/docker/docker/pkg/idtools"
17 18
 	"github.com/docker/docker/pkg/parsers/kernel"
18 19
 	"github.com/docker/docker/pkg/sysinfo"
... ...
@@ -525,3 +526,7 @@ func setupDaemonProcess(config *Config) error {
525 525
 func (daemon *Daemon) setupSeccompProfile() error {
526 526
 	return nil
527 527
 }
528
+
529
+func getRealPath(path string) (string, error) {
530
+	return fileutils.ReadSymlinkedDirectory(path)
531
+}
... ...
@@ -14,6 +14,7 @@ import (
14 14
 	"github.com/docker/docker/container"
15 15
 	"github.com/docker/docker/daemon/config"
16 16
 	"github.com/docker/docker/image"
17
+	"github.com/docker/docker/pkg/fileutils"
17 18
 	"github.com/docker/docker/pkg/idtools"
18 19
 	"github.com/docker/docker/pkg/parsers"
19 20
 	"github.com/docker/docker/pkg/platform"
... ...
@@ -628,3 +629,13 @@ func (daemon *Daemon) verifyVolumesInfo(container *container.Container) error {
628 628
 func (daemon *Daemon) setupSeccompProfile() error {
629 629
 	return nil
630 630
 }
631
+
632
+func getRealPath(path string) (string, error) {
633
+	if system.IsIoTCore() {
634
+		// Due to https://github.com/golang/go/issues/20506, path expansion
635
+		// does not work correctly on the default IoT Core configuration.
636
+		// TODO @darrenstahlmsft remove this once golang/go/20506 is fixed
637
+		return path, nil
638
+	}
639
+	return fileutils.ReadSymlinkedDirectory(path)
640
+}