mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon: remove discovery-related config handling
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
9f2240c56f
commit
ff2a5301b8
5 changed files with 0 additions and 176 deletions
|
@ -7,14 +7,11 @@ import (
|
|||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
daemondiscovery "github.com/docker/docker/daemon/discovery"
|
||||
"github.com/docker/docker/opts"
|
||||
"github.com/docker/docker/pkg/authorization"
|
||||
"github.com/docker/docker/pkg/discovery"
|
||||
"github.com/docker/docker/registry"
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -301,27 +298,10 @@ func New() *Config {
|
|||
LogConfig: LogConfig{
|
||||
Config: make(map[string]string),
|
||||
},
|
||||
ClusterOpts: make(map[string]string),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// ParseClusterAdvertiseSettings parses the specified advertise settings
|
||||
func ParseClusterAdvertiseSettings(clusterStore, clusterAdvertise string) (string, error) {
|
||||
if clusterAdvertise == "" {
|
||||
return "", daemondiscovery.ErrDiscoveryDisabled
|
||||
}
|
||||
if clusterStore == "" {
|
||||
return "", errors.New("invalid cluster configuration. --cluster-advertise must be accompanied by --cluster-store configuration")
|
||||
}
|
||||
|
||||
advertise, err := discovery.ParseAdvertise(clusterAdvertise)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "discovery advertise parsing failed")
|
||||
}
|
||||
return advertise, nil
|
||||
}
|
||||
|
||||
// GetConflictFreeLabels validates Labels for conflict
|
||||
// In swarm the duplicates for labels are removed
|
||||
// so we only take same values here, no conflict values
|
||||
|
@ -636,21 +616,6 @@ func ValidateMaxDownloadAttempts(config *Config) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ModifiedDiscoverySettings returns whether the discovery configuration has been modified or not.
|
||||
func ModifiedDiscoverySettings(config *Config, backendType, advertise string, clusterOpts map[string]string) bool {
|
||||
if config.ClusterStore != backendType || config.ClusterAdvertise != advertise {
|
||||
return true
|
||||
}
|
||||
|
||||
if (config.ClusterOpts == nil && clusterOpts == nil) ||
|
||||
(config.ClusterOpts == nil && len(clusterOpts) == 0) ||
|
||||
(len(config.ClusterOpts) == 0 && clusterOpts == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return !reflect.DeepEqual(config.ClusterOpts, clusterOpts)
|
||||
}
|
||||
|
||||
// GetDefaultRuntimeName returns the current default runtime
|
||||
func (conf *Config) GetDefaultRuntimeName() string {
|
||||
conf.Lock()
|
||||
|
|
|
@ -120,9 +120,6 @@ func (conf *Config) GetResolvConf() string {
|
|||
|
||||
// IsSwarmCompatible defines if swarm mode can be enabled in this config
|
||||
func (conf *Config) IsSwarmCompatible() error {
|
||||
if conf.ClusterStore != "" || conf.ClusterAdvertise != "" {
|
||||
return fmt.Errorf("--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode")
|
||||
}
|
||||
if conf.LiveRestoreEnabled {
|
||||
return fmt.Errorf("--live-restore daemon configuration is incompatible with swarm mode")
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -1050,12 +1049,6 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Discovery is only enabled when the daemon is launched with an address to advertise. When
|
||||
// initialized, the daemon is registered and we can store the discovery backend as it's read-only
|
||||
if err := d.initDiscovery(config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sysInfo := d.RawSysInfo()
|
||||
for _, w := range sysInfo.Warnings {
|
||||
logrus.Warn(w)
|
||||
|
@ -1390,26 +1383,6 @@ func (daemon *Daemon) IsShuttingDown() bool {
|
|||
return daemon.shutdown
|
||||
}
|
||||
|
||||
// initDiscovery initializes the discovery watcher for this daemon.
|
||||
func (daemon *Daemon) initDiscovery(conf *config.Config) error {
|
||||
advertise, err := config.ParseClusterAdvertiseSettings(conf.ClusterStore, conf.ClusterAdvertise)
|
||||
if err != nil {
|
||||
if err == discovery.ErrDiscoveryDisabled {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
conf.ClusterAdvertise = advertise
|
||||
discoveryWatcher, err := discovery.Init(conf.ClusterStore, conf.ClusterAdvertise, conf.ClusterOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("discovery initialization failed (%v)", err)
|
||||
}
|
||||
|
||||
daemon.discoveryWatcher = discoveryWatcher
|
||||
return nil
|
||||
}
|
||||
|
||||
func isBridgeNetworkDisabled(conf *config.Config) bool {
|
||||
return conf.BridgeConfig.Iface == config.DisableNetworkBridge
|
||||
}
|
||||
|
@ -1428,27 +1401,6 @@ func (daemon *Daemon) networkOptions(dconfig *config.Config, pg plugingetter.Plu
|
|||
dn := runconfig.DefaultDaemonNetworkMode().NetworkName()
|
||||
options = append(options, nwconfig.OptionDefaultDriver(string(dd)))
|
||||
options = append(options, nwconfig.OptionDefaultNetwork(dn))
|
||||
|
||||
if strings.TrimSpace(dconfig.ClusterStore) != "" {
|
||||
kv := strings.Split(dconfig.ClusterStore, "://")
|
||||
if len(kv) != 2 {
|
||||
return nil, errors.New("kv store daemon config must be of the form KV-PROVIDER://KV-URL")
|
||||
}
|
||||
options = append(options, nwconfig.OptionKVProvider(kv[0]))
|
||||
options = append(options, nwconfig.OptionKVProviderURL(kv[1]))
|
||||
}
|
||||
if len(dconfig.ClusterOpts) > 0 {
|
||||
options = append(options, nwconfig.OptionKVOpts(dconfig.ClusterOpts))
|
||||
}
|
||||
|
||||
if daemon.discoveryWatcher != nil {
|
||||
options = append(options, nwconfig.OptionDiscoveryWatcher(daemon.discoveryWatcher))
|
||||
}
|
||||
|
||||
if dconfig.ClusterAdvertise != "" {
|
||||
options = append(options, nwconfig.OptionDiscoveryAddress(dconfig.ClusterAdvertise))
|
||||
}
|
||||
|
||||
options = append(options, nwconfig.OptionLabels(dconfig.Labels))
|
||||
options = append(options, driverOptions(dconfig))
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ func (daemon *Daemon) SystemInfo() *types.Info {
|
|||
Isolation: daemon.defaultIsolation,
|
||||
}
|
||||
|
||||
daemon.fillClusterInfo(v)
|
||||
daemon.fillAPIInfo(v)
|
||||
// Retrieve platform specific info
|
||||
daemon.fillPlatformInfo(v, sysInfo)
|
||||
|
@ -131,16 +130,6 @@ func (daemon *Daemon) SystemVersion() types.Version {
|
|||
return v
|
||||
}
|
||||
|
||||
func (daemon *Daemon) fillClusterInfo(v *types.Info) {
|
||||
v.ClusterAdvertise = daemon.configStore.ClusterAdvertise
|
||||
v.ClusterStore = daemon.configStore.ClusterStore
|
||||
|
||||
if v.ClusterAdvertise != "" || v.ClusterStore != "" {
|
||||
v.Warnings = append(v.Warnings, `WARNING: node discovery and overlay networks with an external k/v store (cluster-advertise,
|
||||
cluster-store, cluster-store-opt) are deprecated and will be removed in a future release.`)
|
||||
}
|
||||
}
|
||||
|
||||
func (daemon *Daemon) fillDriverInfo(v *types.Info) {
|
||||
switch daemon.graphDriver {
|
||||
case "aufs", "devicemapper", "overlay":
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/daemon/discovery"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -63,9 +62,6 @@ func (daemon *Daemon) Reload(conf *config.Config) (err error) {
|
|||
daemon.reloadShutdownTimeout(conf, attributes)
|
||||
daemon.reloadFeatures(conf, attributes)
|
||||
|
||||
if err := daemon.reloadClusterDiscovery(conf, attributes); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := daemon.reloadLabels(conf, attributes); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -160,81 +156,6 @@ func (daemon *Daemon) reloadShutdownTimeout(conf *config.Config, attributes map[
|
|||
attributes["shutdown-timeout"] = fmt.Sprintf("%d", daemon.configStore.ShutdownTimeout)
|
||||
}
|
||||
|
||||
// reloadClusterDiscovery updates configuration with cluster discovery options
|
||||
// and updates the passed attributes
|
||||
func (daemon *Daemon) reloadClusterDiscovery(conf *config.Config, attributes map[string]string) (err error) {
|
||||
defer func() {
|
||||
// prepare reload event attributes with updatable configurations
|
||||
attributes["cluster-store"] = conf.ClusterStore
|
||||
attributes["cluster-advertise"] = conf.ClusterAdvertise
|
||||
|
||||
attributes["cluster-store-opts"] = "{}"
|
||||
if daemon.configStore.ClusterOpts != nil {
|
||||
opts, err2 := json.Marshal(conf.ClusterOpts)
|
||||
if err != nil {
|
||||
err = err2
|
||||
}
|
||||
attributes["cluster-store-opts"] = string(opts)
|
||||
}
|
||||
}()
|
||||
|
||||
newAdvertise := conf.ClusterAdvertise
|
||||
newClusterStore := daemon.configStore.ClusterStore
|
||||
if conf.IsValueSet("cluster-advertise") {
|
||||
if conf.IsValueSet("cluster-store") {
|
||||
newClusterStore = conf.ClusterStore
|
||||
}
|
||||
newAdvertise, err = config.ParseClusterAdvertiseSettings(newClusterStore, conf.ClusterAdvertise)
|
||||
if err != nil && err != discovery.ErrDiscoveryDisabled {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if daemon.clusterProvider != nil {
|
||||
if err := conf.IsSwarmCompatible(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// check discovery modifications
|
||||
if !config.ModifiedDiscoverySettings(daemon.configStore, newClusterStore, newAdvertise, conf.ClusterOpts) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// enable discovery for the first time if it was not previously enabled
|
||||
if daemon.discoveryWatcher == nil {
|
||||
discoveryWatcher, err := discovery.Init(newClusterStore, newAdvertise, conf.ClusterOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to initialize discovery: %v", err)
|
||||
}
|
||||
daemon.discoveryWatcher = discoveryWatcher
|
||||
} else if err == discovery.ErrDiscoveryDisabled {
|
||||
// disable discovery if it was previously enabled and it's disabled now
|
||||
daemon.discoveryWatcher.Stop()
|
||||
} else if err = daemon.discoveryWatcher.Reload(conf.ClusterStore, newAdvertise, conf.ClusterOpts); err != nil {
|
||||
// reload discovery
|
||||
return err
|
||||
}
|
||||
|
||||
daemon.configStore.ClusterStore = newClusterStore
|
||||
daemon.configStore.ClusterOpts = conf.ClusterOpts
|
||||
daemon.configStore.ClusterAdvertise = newAdvertise
|
||||
|
||||
if daemon.netController == nil {
|
||||
return nil
|
||||
}
|
||||
netOptions, err := daemon.networkOptions(daemon.configStore, daemon.PluginStore, nil)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Warn("failed to get options with network controller")
|
||||
return nil
|
||||
}
|
||||
err = daemon.netController.ReloadConfiguration(netOptions...)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to reload configuration with network controller: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// reloadLabels updates configuration with engine labels
|
||||
// and updates the passed attributes
|
||||
func (daemon *Daemon) reloadLabels(conf *config.Config, attributes map[string]string) error {
|
||||
|
|
Loading…
Reference in a new issue