From 7b692a421b12d32d92c88e99cdf5638db2ee475c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 22 Dec 2021 10:42:13 +0100 Subject: [PATCH] libnetwork: remove more config bits related to external k/v stores Signed-off-by: Sebastiaan van Stijn --- libnetwork/config/config.go | 8 -------- libnetwork/controller.go | 22 +++------------------- libnetwork/endpoint.go | 6 ------ libnetwork/network.go | 1 - 4 files changed, 3 insertions(+), 34 deletions(-) diff --git a/libnetwork/config/config.go b/libnetwork/config/config.go index 366c484817..33ece12d9f 100644 --- a/libnetwork/config/config.go +++ b/libnetwork/config/config.go @@ -25,7 +25,6 @@ const ( // Config encapsulates configurations of various Libnetwork components type Config struct { Daemon DaemonCfg - Cluster ClusterCfg Scopes map[string]*datastore.ScopeCfg ActiveSandboxes map[string]interface{} PluginGetter plugingetter.PluginGetter @@ -46,13 +45,6 @@ type DaemonCfg struct { DefaultAddressPool []*ipamutils.NetworkToSplit } -// ClusterCfg represents cluster configuration -type ClusterCfg struct { - Address string - Discovery string - Heartbeat uint64 -} - // LoadDefaultScopes loads default scope configs for scopes which // doesn't have explicit user specified configs. func (c *Config) LoadDefaultScopes(dataDir string) { diff --git a/libnetwork/controller.go b/libnetwork/controller.go index 2dfafdde4e..4901c0e701 100644 --- a/libnetwork/controller.go +++ b/libnetwork/controller.go @@ -536,16 +536,6 @@ func (c *controller) BuiltinIPAMDrivers() []string { return drivers } -func (c *controller) clusterHostID() string { - c.Lock() - defer c.Unlock() - if c.cfg == nil || c.cfg.Cluster.Address == "" { - return "" - } - addr := strings.Split(c.cfg.Cluster.Address, ":") - return addr[0] -} - func (c *controller) processNodeDiscovery(nodes []net.IP, add bool) { c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool { c.pushNodeDiscovery(driver, capability, nodes, add) @@ -555,15 +545,9 @@ func (c *controller) processNodeDiscovery(nodes []net.IP, add bool) { func (c *controller) pushNodeDiscovery(d driverapi.Driver, cap driverapi.Capability, nodes []net.IP, add bool) { var self net.IP - if c.cfg != nil { - addr := strings.Split(c.cfg.Cluster.Address, ":") - self = net.ParseIP(addr[0]) - // if external kvstore is not configured, try swarm-mode config - if self == nil { - if agent := c.getAgent(); agent != nil { - self = net.ParseIP(agent.advertiseAddr) - } - } + // try swarm-mode config + if agent := c.getAgent(); agent != nil { + self = net.ParseIP(agent.advertiseAddr) } if d == nil || cap.ConnectivityScope != datastore.GlobalScope || nodes == nil { diff --git a/libnetwork/endpoint.go b/libnetwork/endpoint.go index 4a9d02cfc8..40fadfe1cb 100644 --- a/libnetwork/endpoint.go +++ b/libnetwork/endpoint.go @@ -54,7 +54,6 @@ type endpoint struct { iface *endpointInterface joinInfo *endpointJoinInfo sandboxID string - locator string exposedPorts []types.TransportPort anonymous bool disableResolution bool @@ -90,7 +89,6 @@ func (ep *endpoint) MarshalJSON() ([]byte, error) { epMap["generic"] = ep.generic } epMap["sandbox"] = ep.sandboxID - epMap["locator"] = ep.locator epMap["anonymous"] = ep.anonymous epMap["disableResolution"] = ep.disableResolution epMap["myAliases"] = ep.myAliases @@ -190,9 +188,6 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) { if v, ok := epMap["disableResolution"]; ok { ep.disableResolution = v.(bool) } - if l, ok := epMap["locator"]; ok { - ep.locator = l.(string) - } if sn, ok := epMap["svcName"]; ok { ep.svcName = sn.(string) @@ -239,7 +234,6 @@ func (ep *endpoint) CopyTo(o datastore.KVObject) error { dstEp.name = ep.name dstEp.id = ep.id dstEp.sandboxID = ep.sandboxID - dstEp.locator = ep.locator dstEp.dbIndex = ep.dbIndex dstEp.dbExists = ep.dbExists dstEp.anonymous = ep.anonymous diff --git a/libnetwork/network.go b/libnetwork/network.go index 207138f674..60822f4104 100644 --- a/libnetwork/network.go +++ b/libnetwork/network.go @@ -1175,7 +1175,6 @@ func (n *network) createEndpoint(name string, options ...EndpointOption) (Endpoi // Initialize ep.network with a possibly stale copy of n. We need this to get network from // store. But once we get it from store we will have the most uptodate copy possibly. ep.network = n - ep.locator = n.getController().clusterHostID() ep.network, err = ep.getNetworkFromStore() if err != nil { logrus.Errorf("failed to get network during CreateEndpoint: %v", err)