diff options
| author | Jim Rollenhagen <jim@jimrollenhagen.com> | 2014-10-01 10:59:09 -0700 |
|---|---|---|
| committer | Jim Rollenhagen <jim@jimrollenhagen.com> | 2014-10-13 11:09:09 -0700 |
| commit | 082cf29cec31efda2d63eeb9dda8c74e396be6eb (patch) | |
| tree | 22ff544ad2bc37b6c70c2678ba8ae9480cebd183 /ironic_python_agent/agent.py | |
| parent | 4f57590b2e41863770b764a8b84b8b81830ad577 (diff) | |
| download | ironic-python-agent-082cf29cec31efda2d63eeb9dda8c74e396be6eb.tar.gz | |
Force heartbeat immediately after async command completes
This change passes the agent object into extensions, such that
they may call agent methods as needed. It also causes async
commands to force a heartbeat immediately after completing the
command. This allows Ironic to get a heartbeat and continue
work as quickly as possible, while also allowing deployers to
configure Ironic (agent) to heartbeat less often.
Change-Id: Ib3c3a43dfd0ed4ed51b7d52ac099f01181ca822f
Diffstat (limited to 'ironic_python_agent/agent.py')
| -rw-r--r-- | ironic_python_agent/agent.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ironic_python_agent/agent.py b/ironic_python_agent/agent.py index 079a323c..5bf2eeca 100644 --- a/ironic_python_agent/agent.py +++ b/ironic_python_agent/agent.py @@ -121,6 +121,9 @@ class IronicPythonAgentHeartbeater(threading.Thread): self.error_delay = min(self.error_delay * self.backoff_factor, self.max_delay) + def force_heartbeat(self): + os.write(self.writer, 'b') + def stop(self): """Stop the heartbeat thread.""" if self.writer is not None: @@ -140,6 +143,7 @@ class IronicPythonAgent(base.ExecuteCommandMixin): namespace='ironic_python_agent.extensions', invoke_on_load=True, propagate_map_exceptions=True, + invoke_kwds={'agent': self}, ) self.api_url = api_url self.driver_name = driver_name @@ -262,6 +266,9 @@ class IronicPythonAgent(base.ExecuteCommandMixin): raise errors.RequestedObjectNotFoundError('Command Result', result_id) + def force_heartbeat(self): + self.heartbeater.force_heartbeat() + def run(self): """Run the Ironic Python Agent.""" # Get the UUID so we can heartbeat to Ironic. Raises LookupNodeError |
