Optimize PTP Hieradata Generation

During an upgrade, the "software deploy start" step triggers the
creation of hieradata for the TO_RELEASE. On systems with many
interfaces (e.g., SR-IOV) and PTP configurations, generating the
PTP-related hieradata can take over 4 minutes.
The primary bottleneck is a database query inside a for loop,
each query takes over 25 seconds in our tests.
However, this DB access is unnecessary because the required interface
data is already available in context["interfaces"].
This context is populated during hieradata generation via
get_host_config in interface.py:

a553b78ced/sysinv/sysinv/sysinv/sysinv/puppet/interface.py (L119)

Tests Done:

- Upgrade: software deploy start with the fix
         the PTP data creation took 5 seconds
         instead of 4 min
- AIO-SX fresh install
- AIO-SX PTP tests in real lab:
   - 2 ptp instances with 1 interface each
   - PTP with HA support
   - PTP clock SMA1 config
- AIO-DX fresh install on vbox
         Create PTP config for controller-0
         and controller-1
         ptp was assign for multiple interfaces
         on controller-0/1
         e.g:
           "controller-0/oam0",
	   "controller-0/data0",
	   "controller-0/vlan100",
	   "controller-0/vlan101",
	   "controller-1/oam0",
	   "controller-1/data0",
	   "controller-1/vlan100",
	   "controller-1/vlan101"

         Generate the hieradata in the code with
         the fix and without the fix.
         The PTP config for controller-0/1
         was the same in both cases

Closes-Bug: 2110689

Change-Id: Ifd589316f8b4145eb7d1d7aab038581a07b17b42
Signed-off-by: Fabiano Correa Mercer <fabiano.correamercer@windriver.com>
This commit is contained in:
Fabiano Correa Mercer
2025-05-14 11:23:55 -03:00
parent a553b78ced
commit 37f04198ff

View File

@@ -497,8 +497,10 @@ class NetworkingPuppet(base.BasePuppet):
temp_host = hostinterface.split('/')[0]
temp_interface = hostinterface.split('/')[1]
if host.hostname == temp_host:
iinterface = self.dbapi.iinterface_get(
temp_interface, host.uuid)
iinterface = self.context['interfaces'].get(temp_interface)
if (iinterface is None or iinterface.ihost_uuid != host.uuid):
iinterface = self.dbapi.iinterface_get(
temp_interface, host.uuid)
if iinterface['iftype'] == constants.INTERFACE_TYPE_AE:
if_devices = [temp_interface]
elif iinterface['iftype'] == constants.INTERFACE_TYPE_VLAN: