From 9e1c0d71874b219e7acfdb16bf8a756ce0eae5cf Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 13 Feb 2018 14:29:14 -0500 Subject: [PATCH 1/2] Remove unnecessary getLayerInit Signed-off-by: Daniel Nephin Upstream-commit: c502bcff33e10be55f15366e123b25574016a9af Component: engine --- components/engine/daemon/create.go | 2 +- components/engine/daemon/daemon.go | 7 ------- components/engine/daemon/daemon_unix.go | 7 +++++-- components/engine/daemon/daemon_windows.go | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/components/engine/daemon/create.go b/components/engine/daemon/create.go index 05231dfcec..7e6b6519fe 100644 --- a/components/engine/daemon/create.go +++ b/components/engine/daemon/create.go @@ -266,7 +266,7 @@ func (daemon *Daemon) setRWLayer(container *container.Container) error { rwLayerOpts := &layer.CreateRWLayerOpts{ MountLabel: container.MountLabel, - InitFunc: daemon.getLayerInit(), + InitFunc: setupInitLayer(daemon.idMappings), StorageOpt: container.HostConfig.StorageOpt, } diff --git a/components/engine/daemon/daemon.go b/components/engine/daemon/daemon.go index ab28a56ebe..97694234af 100644 --- a/components/engine/daemon/daemon.go +++ b/components/engine/daemon/daemon.go @@ -32,7 +32,6 @@ import ( "github.com/sirupsen/logrus" // register graph drivers _ "github.com/docker/docker/daemon/graphdriver/register" - "github.com/docker/docker/daemon/initlayer" "github.com/docker/docker/daemon/stats" dmetadata "github.com/docker/docker/distribution/metadata" "github.com/docker/docker/distribution/xfer" @@ -41,7 +40,6 @@ import ( "github.com/docker/docker/layer" "github.com/docker/docker/libcontainerd" "github.com/docker/docker/migrate/v1" - "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/locker" "github.com/docker/docker/pkg/plugingetter" @@ -1142,11 +1140,6 @@ func prepareTempDir(rootDir string, rootIDs idtools.IDPair) (string, error) { return tmpDir, idtools.MkdirAllAndChown(tmpDir, 0700, rootIDs) } -func (daemon *Daemon) setupInitLayer(initPath containerfs.ContainerFS) error { - rootIDs := daemon.idMappings.RootPair() - return initlayer.Setup(initPath, rootIDs) -} - func (daemon *Daemon) setGenericResources(conf *config.Config) error { genericResources, err := config.ParseGenericResources(conf.NodeGenericResources) if err != nil { diff --git a/components/engine/daemon/daemon_unix.go b/components/engine/daemon/daemon_unix.go index 55ff9f8574..b98b29aa61 100644 --- a/components/engine/daemon/daemon_unix.go +++ b/components/engine/daemon/daemon_unix.go @@ -23,6 +23,7 @@ import ( containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/daemon/config" + "github.com/docker/docker/daemon/initlayer" "github.com/docker/docker/image" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/containerfs" @@ -1000,8 +1001,10 @@ func removeDefaultBridgeInterface() { } } -func (daemon *Daemon) getLayerInit() func(containerfs.ContainerFS) error { - return daemon.setupInitLayer +func setupInitLayer(idMappings *idtools.IDMappings) func(containerfs.ContainerFS) error { + return func(initPath containerfs.ContainerFS) error { + return initlayer.Setup(initPath, idMappings.RootPair()) + } } // Parse the remapped root (user namespace) option, which can be one of: diff --git a/components/engine/daemon/daemon_windows.go b/components/engine/daemon/daemon_windows.go index 7b5d954e98..5dd90de8a0 100644 --- a/components/engine/daemon/daemon_windows.go +++ b/components/engine/daemon/daemon_windows.go @@ -54,7 +54,7 @@ func parseSecurityOpt(container *container.Container, config *containertypes.Hos return nil } -func (daemon *Daemon) getLayerInit() func(containerfs.ContainerFS) error { +func setupInitLayer(idMappings *idtools.IDMappings) func(containerfs.ContainerFS) error { return nil } From a5927022374a928d638a67e32641de940acb39eb Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 13 Feb 2018 14:32:05 -0500 Subject: [PATCH 2/2] Remove duplicate rootFSToAPIType Signed-off-by: Daniel Nephin Upstream-commit: 4ceea53b5e6a86c39122e99f6ffbc1142d28a174 Component: engine --- components/engine/daemon/daemon_unix.go | 12 ------------ components/engine/daemon/daemon_windows.go | 12 ------------ components/engine/daemon/image_inspect.go | 12 ++++++++++++ 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/components/engine/daemon/daemon_unix.go b/components/engine/daemon/daemon_unix.go index b98b29aa61..670d564b8a 100644 --- a/components/engine/daemon/daemon_unix.go +++ b/components/engine/daemon/daemon_unix.go @@ -24,7 +24,6 @@ import ( "github.com/docker/docker/container" "github.com/docker/docker/daemon/config" "github.com/docker/docker/daemon/initlayer" - "github.com/docker/docker/image" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" @@ -1360,17 +1359,6 @@ func (daemon *Daemon) setDefaultIsolation() error { return nil } -func rootFSToAPIType(rootfs *image.RootFS) types.RootFS { - var layers []string - for _, l := range rootfs.DiffIDs { - layers = append(layers, l.String()) - } - return types.RootFS{ - Type: rootfs.Type, - Layers: layers, - } -} - // setupDaemonProcess sets various settings for the daemon's process func setupDaemonProcess(config *config.Config) error { // setup the daemons oom_score_adj diff --git a/components/engine/daemon/daemon_windows.go b/components/engine/daemon/daemon_windows.go index 5dd90de8a0..50507e5fad 100644 --- a/components/engine/daemon/daemon_windows.go +++ b/components/engine/daemon/daemon_windows.go @@ -11,7 +11,6 @@ import ( containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/daemon/config" - "github.com/docker/docker/image" "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/idtools" @@ -629,17 +628,6 @@ func (daemon *Daemon) setDefaultIsolation() error { return nil } -func rootFSToAPIType(rootfs *image.RootFS) types.RootFS { - var layers []string - for _, l := range rootfs.DiffIDs { - layers = append(layers, l.String()) - } - return types.RootFS{ - Type: rootfs.Type, - Layers: layers, - } -} - func setupDaemonProcess(config *config.Config) error { return nil } diff --git a/components/engine/daemon/image_inspect.go b/components/engine/daemon/image_inspect.go index 066466e047..731057cf34 100644 --- a/components/engine/daemon/image_inspect.go +++ b/components/engine/daemon/image_inspect.go @@ -5,6 +5,7 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/image" "github.com/docker/docker/layer" "github.com/docker/docker/pkg/system" "github.com/pkg/errors" @@ -90,3 +91,14 @@ func (daemon *Daemon) LookupImage(name string) (*types.ImageInspect, error) { return imageInspect, nil } + +func rootFSToAPIType(rootfs *image.RootFS) types.RootFS { + var layers []string + for _, l := range rootfs.DiffIDs { + layers = append(layers, l.String()) + } + return types.RootFS{ + Type: rootfs.Type, + Layers: layers, + } +}