diff --git a/ironic_python_agent/agent.py b/ironic_python_agent/agent.py index 50a30d0b0..0fa51ccd2 100644 --- a/ironic_python_agent/agent.py +++ b/ironic_python_agent/agent.py @@ -275,6 +275,10 @@ class IronicPythonAgent(base.ExecuteCommandMixin): # Get the UUID so we can heartbeat to Ironic. Raises LookupNodeError # if there is an issue (uncaught, restart agent) self.started_at = _time() + + # Cached hw managers at runtime, not load time. See bug 1490008. + hardware.load_managers() + if not self.standalone: content = self.api_client.lookup_node( hardware_info=hardware.dispatch_to_managers( diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 8d517d2eb..d5c0aed91 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -716,3 +716,15 @@ def dispatch_to_managers(method, *args, **kwargs): .format(manager, method)) raise errors.HardwareManagerMethodNotFound(method) + + +def load_managers(): + """Preload hardware managers into the cache. + + This method is to help warm up the cache for hardware managers when + called. Used to resolve bug 1490008, where agents can crash the first + time a hardware manager is needed. + + :raises HardwareManagerNotFound: if no valid hardware managers found + """ + _get_managers()