Load Hardware Managers at runtime
Hardware managers should load at runtime. This will ensure the agent is ready to respond to API calls before it begins heartbeating. Also, it means in case of a syntax or other error in a HardwareManager, the agent will crash before it heartbeats, which is better than it working until a hardware manager method is needed. Change-Id: I9403ce7bedc8d5af20b6d84371367253b26b74c2 Closes-bug: 1490008
This commit is contained in:
parent
3de3ca3b22
commit
09221f98cb
ironic_python_agent
@ -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(
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user