libnetwork: refactor isDistributedControl()
The meaning of the (*Controller).isDistributedControl() method is not immediately clear from the name, and it does not have any doc comment. It returns true if and only if the controller is neither a manager node nor an agent node -- that is, if the daemon is _not_ participating in a Swarm cluster. The method name likely comes from the old abandoned datastore-as-IPC control plane architecture for libnetwork. Refactor c.isDistributedControl() -> !c.isSwarmNode() to make it easier to understand code which consumes the method. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
parent
749d4abd41
commit
0456c0db87
3 changed files with 10 additions and 10 deletions
|
@ -241,7 +241,7 @@ func (c *Controller) clusterAgentInit() {
|
|||
c.mu.Unlock()
|
||||
fallthrough
|
||||
case cluster.EventSocketChange, cluster.EventNodeReady:
|
||||
if keysAvailable && !c.isDistributedControl() {
|
||||
if keysAvailable && c.isSwarmNode() {
|
||||
c.agentOperationStart()
|
||||
if err := c.agentSetup(clusterProvider); err != nil {
|
||||
c.agentStopComplete()
|
||||
|
@ -451,8 +451,8 @@ func (c *Controller) isAgent() bool {
|
|||
return c.cfg.ClusterProvider.IsAgent()
|
||||
}
|
||||
|
||||
func (c *Controller) isDistributedControl() bool {
|
||||
return !c.isManager() && !c.isAgent()
|
||||
func (c *Controller) isSwarmNode() bool {
|
||||
return c.isManager() || c.isAgent()
|
||||
}
|
||||
|
||||
func (c *Controller) GetPluginGetter() plugingetter.PluginGetter {
|
||||
|
@ -553,7 +553,7 @@ func (c *Controller) NewNetwork(networkType, name string, id string, options ...
|
|||
|
||||
// At this point the network scope is still unknown if not set by user
|
||||
if (caps.DataScope == scope.Global || nw.scope == scope.Swarm) &&
|
||||
!c.isDistributedControl() && !nw.dynamic {
|
||||
c.isSwarmNode() && !nw.dynamic {
|
||||
if c.isManager() {
|
||||
// For non-distributed controlled environment, globalscoped non-dynamic networks are redirected to Manager
|
||||
return nil, ManagerRedirectError(name)
|
||||
|
@ -561,7 +561,7 @@ func (c *Controller) NewNetwork(networkType, name string, id string, options ...
|
|||
return nil, types.ForbiddenErrorf("Cannot create a multi-host network from a worker node. Please create the network from a manager node.")
|
||||
}
|
||||
|
||||
if nw.scope == scope.Swarm && c.isDistributedControl() {
|
||||
if nw.scope == scope.Swarm && !c.isSwarmNode() {
|
||||
return nil, types.ForbiddenErrorf("cannot create a swarm scoped network when swarm is not active")
|
||||
}
|
||||
|
||||
|
@ -704,7 +704,7 @@ addToStore:
|
|||
}
|
||||
}
|
||||
|
||||
if !c.isDistributedControl() {
|
||||
if c.isSwarmNode() {
|
||||
c.mu.Lock()
|
||||
arrangeIngressFilterRule()
|
||||
c.mu.Unlock()
|
||||
|
|
|
@ -162,7 +162,7 @@ func (sb *Sandbox) delete(force bool) error {
|
|||
}
|
||||
// Retain the sanbdox if we can't obtain the network from store.
|
||||
if _, err := c.getNetworkFromStore(ep.getNetwork().ID()); err != nil {
|
||||
if c.isDistributedControl() {
|
||||
if !c.isSwarmNode() {
|
||||
retain = true
|
||||
}
|
||||
log.G(context.TODO()).Warnf("Failed getting network for ep %s during sandbox %s delete: %v", ep.ID(), sb.ID(), err)
|
||||
|
@ -459,7 +459,7 @@ func (sb *Sandbox) ResolveName(ctx context.Context, name string, ipType int) ([]
|
|||
// network, ingress network and docker_gwbridge network. Name resolution
|
||||
// should prioritize returning the VIP/IPs on user overlay network.
|
||||
newList := []*Endpoint{}
|
||||
if !sb.controller.isDistributedControl() {
|
||||
if sb.controller.isSwarmNode() {
|
||||
newList = append(newList, getDynamicNwEndpoints(epList)...)
|
||||
ingressEP := getIngressNwEndpoint(epList)
|
||||
if ingressEP != nil {
|
||||
|
|
|
@ -198,7 +198,7 @@ func (c *Controller) unWatchSvcRecord(ep *Endpoint) {
|
|||
|
||||
func (c *Controller) processEndpointCreate(ep *Endpoint) {
|
||||
n := ep.getNetwork()
|
||||
if !c.isDistributedControl() && n.Scope() == scope.Swarm && n.driverIsMultihost() {
|
||||
if c.isSwarmNode() && n.Scope() == scope.Swarm && n.driverIsMultihost() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ func (c *Controller) processEndpointCreate(ep *Endpoint) {
|
|||
|
||||
func (c *Controller) processEndpointDelete(ep *Endpoint) {
|
||||
n := ep.getNetwork()
|
||||
if !c.isDistributedControl() && n.Scope() == scope.Swarm && n.driverIsMultihost() {
|
||||
if c.isSwarmNode() && n.Scope() == scope.Swarm && n.driverIsMultihost() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue