daemon: small cleanup to boot nodes logic, moved control interface creation to occur before service startup avoiding thread race conditions validating if an interface is for a control network

This commit is contained in:
Blake Harnden 2020-12-16 10:19:17 -08:00
parent 4b6afe4db7
commit 4ec9ea7b16

View file

@ -13,7 +13,7 @@ import tempfile
import threading
import time
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, TypeVar
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, TypeVar, Union
from core import constants, utils
from core.configservice.manager import ConfigServiceManager
@ -571,11 +571,11 @@ class Session:
if isinstance(node, WlanNode):
self.mobility.set_model_config(_id, BasicRangeModel.name)
# boot nodes after runtime, CoreNodes, Physical, and RJ45 are all nodes
is_boot_node = isinstance(node, CoreNodeBase) and not isinstance(node, Rj45Node)
# boot nodes after runtime CoreNodes and PhysicalNodes
is_boot_node = isinstance(node, (CoreNode, PhysicalNode))
if self.state == EventTypes.RUNTIME_STATE and is_boot_node:
self.write_nodes()
self.add_remove_control_iface(node=node, remove=False)
self.add_remove_control_iface(node, remove=False)
self.services.boot_services(node)
self.sdt.add_node(node)
@ -1310,7 +1310,6 @@ class Session:
:return: nothing
"""
logging.info("booting node(%s): %s", node.name, [x.name for x in node.services])
self.add_remove_control_iface(node=node, remove=False)
self.services.boot_services(node)
node.start_config_services()
@ -1325,11 +1324,10 @@ class Session:
with self.nodes_lock:
funcs = []
start = time.monotonic()
for _id in self.nodes:
node = self.nodes[_id]
if isinstance(node, CoreNodeBase) and not isinstance(node, Rj45Node):
args = (node,)
funcs.append((self.boot_node, args, {}))
for node in self.nodes.values():
if isinstance(node, (CoreNode, PhysicalNode)):
self.add_remove_control_iface(node, remove=False)
funcs.append((self.boot_node, (node,), {}))
results, exceptions = utils.threadpool(funcs)
total = time.monotonic() - start
logging.debug("boot run time: %s", total)
@ -1477,7 +1475,7 @@ class Session:
def add_remove_control_iface(
self,
node: CoreNode,
node: Union[CoreNode, PhysicalNode],
net_index: int = 0,
remove: bool = False,
conf_required: bool = True,