Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow features option live reloading #37692

Merged
merged 1 commit into from
Sep 2, 2018

Conversation

AntaresS
Copy link
Contributor

@AntaresS AntaresS commented Aug 22, 2018

- What I did

  • add reloadFeatures so that the changes of features field in daemon.json can be live reloaded.
  • pass a pointer of features to the rest of places where it is being used.

- How I did it

- How to verify it
First with buildkit turned on in daemon.json

{"debug":true,"tls":true,"tlscacert":"/etc/docker/ca.pem","tlscert":"/etc/docker/cert.pem","tlskey":"/etc/docker/key.pem","tlsverify":true, "experimental": true, "features": {"buildkit": true}}

we hit the /_ping endpoint to verify, Builder-Version: 2
image

Now turn buildkit off

{"debug":true,"tls":true,"tlscacert":"/etc/docker/ca.pem","tlscert":"/etc/docker/cert.pem","tlskey":"/etc/docker/key.pem","tlsverify":true, "experimental": true, "features": {"buildkit": false}}

and run sudo kill -s SIGHUP <dockerd-PID>

then verify with /_ping again, it shows Builder-Version: 1
image

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Anda Xu anda.xu@docker.com

@AntaresS
Copy link
Contributor Author

ptal @thaJeztah @tiborvass

daemon/reload.go Outdated
// reloadFeatures updates configuration with enabled/disabled features
func (daemon *Daemon) reloadFeatures(conf *config.Config, attributes map[string]string) {
// update corresponding configuration
if conf.IsValueSet("features") {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this if to be able to unset features ?

@thaJeztah thaJeztah changed the title allow features option live reloading [wip] allow features option live reloading Aug 30, 2018
@codecov
Copy link

codecov bot commented Aug 30, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@64b7575). Click here to learn what that means.
The diff coverage is 44.44%.

@@            Coverage Diff            @@
##             master   #37692   +/-   ##
=========================================
  Coverage          ?   36.03%           
=========================================
  Files             ?      609           
  Lines             ?    45063           
  Branches          ?        0           
=========================================
  Hits              ?    16240           
  Misses            ?    26592           
  Partials          ?     2231

@AntaresS AntaresS force-pushed the live-reload-buildkit branch 4 times, most recently from 97a1f12 to f634ae4 Compare August 30, 2018 23:10
@AntaresS
Copy link
Contributor Author

@tiborvass I've updated the PR and verified this would actually work.

daemon/reload.go Outdated Show resolved Hide resolved
@@ -7,6 +7,8 @@ import (
"net/http"
"time"

"github.com/docker/docker/api/server/router/build"

Copy link
Contributor

Choose a reason for hiding this comment

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

unneeded extra space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@tiborvass tiborvass left a comment

Choose a reason for hiding this comment

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

LGTM

@AntaresS AntaresS changed the title [wip] allow features option live reloading allow features option live reloading Aug 30, 2018
@AntaresS
Copy link
Contributor Author

@tonistiigi or @thaJeztah can you help review this?

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

one nit, but looks good otherwise

daemon/daemon.go Outdated
@@ -136,6 +136,11 @@ func (daemon *Daemon) HasExperimental() bool {
return daemon.configStore != nil && daemon.configStore.Experimental
}

// GetFeatures returns the features map from configStore
func (daemon *Daemon) GetFeatures() *map[string]bool {
Copy link
Member

Choose a reason for hiding this comment

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

Better to name this Features() instead of GetFeatures(); golang convention is to not use a Get prefix for getters; https://golang.org/doc/effective_go.html#Getters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good call. 👍

Copy link
Contributor Author

@AntaresS AntaresS Aug 31, 2018

Choose a reason for hiding this comment

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

@thaJeztah Fixed :)

Signed-off-by: Anda Xu <anda.xu@docker.com>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

// check if the builder feature has been enabled from daemon as well.
if buildOptions.Version == types.BuilderBuildKit && br.builderVersion != "" && br.builderVersion != types.BuilderBuildKit {
if buildOptions.Version == types.BuilderBuildKit && builderVersion != "" && builderVersion != types.BuilderBuildKit {
Copy link
Member

Choose a reason for hiding this comment

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

@tiborvass As discussed offline, this value should only apply as a hint to the client on negotiation on ping, not override a daemon behavior.

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.

None yet

5 participants