mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
graphdriver: custom build-time priority list
Add a way to specify a custom graphdriver priority list during build. This can be done with something like go build -ldflags "-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper" As ldflags are already used by the engine build process, and it seems that only one (last) `-ldflags` argument is taken into account by go, an envoronment variable `DOCKER_LDFLAGS` is introduced in order to be able to append some text to `-ldflags`. With this in place, using the feature becomes make DOCKER_LDFLAGS="-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper" dynbinary The idea behind this is, the priority list might be different for different distros, so vendors are now able to change it without patching the source code. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
7c53e73253
commit
17708e72a7
7 changed files with 21 additions and 24 deletions
8
Makefile
8
Makefile
|
@ -16,6 +16,13 @@ export DOCKER_GITCOMMIT
|
||||||
# env vars passed through directly to Docker's build scripts
|
# env vars passed through directly to Docker's build scripts
|
||||||
# to allow things like `make KEEPBUNDLE=1 binary` easily
|
# to allow things like `make KEEPBUNDLE=1 binary` easily
|
||||||
# `project/PACKAGERS.md` have some limited documentation of some of these
|
# `project/PACKAGERS.md` have some limited documentation of some of these
|
||||||
|
#
|
||||||
|
# DOCKER_LDFLAGS can be used to pass additional parameters to -ldflags
|
||||||
|
# option of "go build". For example, a built-in graphdriver priority list
|
||||||
|
# can be changed during build time like this:
|
||||||
|
#
|
||||||
|
# make DOCKER_LDFLAGS="-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper" dynbinary
|
||||||
|
#
|
||||||
DOCKER_ENVS := \
|
DOCKER_ENVS := \
|
||||||
-e DOCKER_CROSSPLATFORMS \
|
-e DOCKER_CROSSPLATFORMS \
|
||||||
-e BUILD_APT_MIRROR \
|
-e BUILD_APT_MIRROR \
|
||||||
|
@ -31,6 +38,7 @@ DOCKER_ENVS := \
|
||||||
-e DOCKER_GITCOMMIT \
|
-e DOCKER_GITCOMMIT \
|
||||||
-e DOCKER_GRAPHDRIVER \
|
-e DOCKER_GRAPHDRIVER \
|
||||||
-e DOCKER_INCREMENTAL_BINARY \
|
-e DOCKER_INCREMENTAL_BINARY \
|
||||||
|
-e DOCKER_LDFLAGS \
|
||||||
-e DOCKER_PORT \
|
-e DOCKER_PORT \
|
||||||
-e DOCKER_REMAP_ROOT \
|
-e DOCKER_REMAP_ROOT \
|
||||||
-e DOCKER_STORAGE_OPTS \
|
-e DOCKER_STORAGE_OPTS \
|
||||||
|
|
|
@ -208,7 +208,9 @@ func New(name string, pg plugingetter.PluginGetter, config Options) (Driver, err
|
||||||
|
|
||||||
// Guess for prior driver
|
// Guess for prior driver
|
||||||
driversMap := scanPriorDrivers(config.Root)
|
driversMap := scanPriorDrivers(config.Root)
|
||||||
for _, name := range priority {
|
list := strings.Split(priority, ",")
|
||||||
|
logrus.Debugf("[graphdriver] priority list: %v", list)
|
||||||
|
for _, name := range list {
|
||||||
if name == "vfs" {
|
if name == "vfs" {
|
||||||
// don't use vfs even if there is state present.
|
// don't use vfs even if there is state present.
|
||||||
continue
|
continue
|
||||||
|
@ -243,7 +245,7 @@ func New(name string, pg plugingetter.PluginGetter, config Options) (Driver, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for priority drivers first
|
// Check for priority drivers first
|
||||||
for _, name := range priority {
|
for _, name := range list {
|
||||||
driver, err := getBuiltinDriver(name, config.Root, config.DriverOptions, config.UIDMaps, config.GIDMaps)
|
driver, err := getBuiltinDriver(name, config.Root, config.DriverOptions, config.UIDMaps, config.GIDMaps)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if isDriverNotSupported(err) {
|
if isDriverNotSupported(err) {
|
||||||
|
|
|
@ -7,10 +7,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Slice of drivers that should be used in an order
|
// List of drivers that should be used in an order
|
||||||
priority = []string{
|
priority = "zfs"
|
||||||
"zfs",
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Mounted checks if the given path is mounted as the fs type
|
// Mounted checks if the given path is mounted as the fs type
|
||||||
|
|
|
@ -51,16 +51,8 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Slice of drivers that should be used in an order
|
// List of drivers that should be used in an order
|
||||||
priority = []string{
|
priority = "btrfs,zfs,overlay2,aufs,overlay,devicemapper,vfs"
|
||||||
"btrfs",
|
|
||||||
"zfs",
|
|
||||||
"overlay2",
|
|
||||||
"aufs",
|
|
||||||
"overlay",
|
|
||||||
"devicemapper",
|
|
||||||
"vfs",
|
|
||||||
}
|
|
||||||
|
|
||||||
// FsNames maps filesystem id to name of the filesystem.
|
// FsNames maps filesystem id to name of the filesystem.
|
||||||
FsNames = map[FsMagic]string{
|
FsNames = map[FsMagic]string{
|
||||||
|
|
|
@ -3,10 +3,8 @@
|
||||||
package graphdriver
|
package graphdriver
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Slice of drivers that should be used in an order
|
// List of drivers that should be used in an order
|
||||||
priority = []string{
|
priority = "unsupported"
|
||||||
"unsupported",
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetFSMagic returns the filesystem id given the path.
|
// GetFSMagic returns the filesystem id given the path.
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package graphdriver
|
package graphdriver
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Slice of drivers that should be used in order
|
// List of drivers that should be used in order
|
||||||
priority = []string{
|
priority = "windowsfilter"
|
||||||
"windowsfilter",
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetFSMagic returns the filesystem id given the path.
|
// GetFSMagic returns the filesystem id given the path.
|
||||||
|
|
|
@ -57,6 +57,7 @@ go build \
|
||||||
-ldflags "
|
-ldflags "
|
||||||
$LDFLAGS
|
$LDFLAGS
|
||||||
$LDFLAGS_STATIC_DOCKER
|
$LDFLAGS_STATIC_DOCKER
|
||||||
|
$DOCKER_LDFLAGS
|
||||||
" \
|
" \
|
||||||
$GO_PACKAGE
|
$GO_PACKAGE
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue