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:
parent
4b6afe4db7
commit
4ec9ea7b16
1 changed files with 9 additions and 11 deletions
|
@ -13,7 +13,7 @@ import tempfile
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
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 import constants, utils
|
||||||
from core.configservice.manager import ConfigServiceManager
|
from core.configservice.manager import ConfigServiceManager
|
||||||
|
@ -571,11 +571,11 @@ class Session:
|
||||||
if isinstance(node, WlanNode):
|
if isinstance(node, WlanNode):
|
||||||
self.mobility.set_model_config(_id, BasicRangeModel.name)
|
self.mobility.set_model_config(_id, BasicRangeModel.name)
|
||||||
|
|
||||||
# boot nodes after runtime, CoreNodes, Physical, and RJ45 are all nodes
|
# boot nodes after runtime CoreNodes and PhysicalNodes
|
||||||
is_boot_node = isinstance(node, CoreNodeBase) and not isinstance(node, Rj45Node)
|
is_boot_node = isinstance(node, (CoreNode, PhysicalNode))
|
||||||
if self.state == EventTypes.RUNTIME_STATE and is_boot_node:
|
if self.state == EventTypes.RUNTIME_STATE and is_boot_node:
|
||||||
self.write_nodes()
|
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.services.boot_services(node)
|
||||||
|
|
||||||
self.sdt.add_node(node)
|
self.sdt.add_node(node)
|
||||||
|
@ -1310,7 +1310,6 @@ class Session:
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
logging.info("booting node(%s): %s", node.name, [x.name for x in node.services])
|
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)
|
self.services.boot_services(node)
|
||||||
node.start_config_services()
|
node.start_config_services()
|
||||||
|
|
||||||
|
@ -1325,11 +1324,10 @@ class Session:
|
||||||
with self.nodes_lock:
|
with self.nodes_lock:
|
||||||
funcs = []
|
funcs = []
|
||||||
start = time.monotonic()
|
start = time.monotonic()
|
||||||
for _id in self.nodes:
|
for node in self.nodes.values():
|
||||||
node = self.nodes[_id]
|
if isinstance(node, (CoreNode, PhysicalNode)):
|
||||||
if isinstance(node, CoreNodeBase) and not isinstance(node, Rj45Node):
|
self.add_remove_control_iface(node, remove=False)
|
||||||
args = (node,)
|
funcs.append((self.boot_node, (node,), {}))
|
||||||
funcs.append((self.boot_node, args, {}))
|
|
||||||
results, exceptions = utils.threadpool(funcs)
|
results, exceptions = utils.threadpool(funcs)
|
||||||
total = time.monotonic() - start
|
total = time.monotonic() - start
|
||||||
logging.debug("boot run time: %s", total)
|
logging.debug("boot run time: %s", total)
|
||||||
|
@ -1477,7 +1475,7 @@ class Session:
|
||||||
|
|
||||||
def add_remove_control_iface(
|
def add_remove_control_iface(
|
||||||
self,
|
self,
|
||||||
node: CoreNode,
|
node: Union[CoreNode, PhysicalNode],
|
||||||
net_index: int = 0,
|
net_index: int = 0,
|
||||||
remove: bool = False,
|
remove: bool = False,
|
||||||
conf_required: bool = True,
|
conf_required: bool = True,
|
||||||
|
|
Loading…
Add table
Reference in a new issue