Skip to content

graphdriver: custom build-time priority list#35522

Merged
vieux merged 1 commit into
moby:masterfrom
kolyshkin:gd-custom
Nov 17, 2017
Merged

graphdriver: custom build-time priority list#35522
vieux merged 1 commit into
moby:masterfrom
kolyshkin:gd-custom

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin commented Nov 16, 2017

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.priorityOverride=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.priorityOverride=overlay2,devicemapper" dynbinary

If this variable is either unset during compile time or empty, the default list (priority) is used.

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.

@AkihiroSuda
Copy link
Copy Markdown
Member

I think we should have a document about these overridable variables

Comment thread daemon/graphdriver/driver.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can (and should) be a const.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can not be a const because const can not be overridden with -X.

@cyphar
Copy link
Copy Markdown
Contributor

cyphar commented Nov 16, 2017

I reckon that the ideal way of doing this would be to have priority be a (const) string, with the same format, and then we override it as you're doing here. That way feels much more consistent (to me at least). Also I feel like this information should be present in docker info but that might just be me.

Copy link
Copy Markdown
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Related #35353

@dnephin
Copy link
Copy Markdown
Member

dnephin commented Nov 16, 2017

I feel like this information should be present in docker info

I don't think info needs to report the priority. It already reports the active graphdriver which is really all that is important for someone querying info.

@kolyshkin
Copy link
Copy Markdown
Contributor Author

I reckon that the ideal way of doing this would be to have priority be a (const) string,
with the same format, and then we override it as you're doing here.

@cyphar Makes sense (except it can't be const). Please see the updated commit

@AkihiroSuda
Copy link
Copy Markdown
Member

@kolyshkin

Please add a document about this?
Probably, just adding comments to Makefile should be ok now.

then LGTM

@cyphar
Copy link
Copy Markdown
Contributor

cyphar commented Nov 16, 2017

@kolyshkin 👍, plus the comment about documenting it in a Makefile.

@kolyshkin
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda @cyphar you mean the top-level Makefile? Would something like this be sufficient?

diff --git a/Makefile b/Makefile
index 547230fb1..cb5980d2f 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,13 @@ export DOCKER_GITCOMMIT
 # env vars passed through directly to Docker's build scripts
 # to allow things like `make KEEPBUNDLE=1 binary` easily
 # `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 := \
        -e DOCKER_CROSSPLATFORMS \
        -e BUILD_APT_MIRROR \

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 <[email protected]>
@vieux
Copy link
Copy Markdown
Contributor

vieux commented Nov 17, 2017

LGTM

@vieux vieux merged commit edc204b into moby:master Nov 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants