Merge "When reporting that agent is busy, report the executed command"

This commit is contained in:
Zuul 2020-09-23 22:00:15 +00:00 committed by Gerrit Code Review
commit 5e61ad18e3
3 changed files with 21 additions and 1 deletions

View File

@ -91,6 +91,15 @@ class RequestedObjectNotFoundError(NotFound):
super(RequestedObjectNotFoundError, self).__init__(details)
class AgentIsBusy(CommandExecutionError):
message = 'Agent is busy'
status_code = 409
def __init__(self, command_name):
super().__init__('executing command %s' % command_name)
class IronicAPIError(RESTError):
"""Error raised when a call to the agent API fails."""

View File

@ -250,7 +250,7 @@ class ExecuteCommandMixin(object):
LOG.error('Tried to execute %(command)s, agent is still '
'executing %(last)s', {'command': command_name,
'last': last_command})
raise errors.CommandExecutionError('agent is busy')
raise errors.AgentIsBusy(last_command.command_name)
try:
ext = self.get_extension(extension_part)

View File

@ -117,6 +117,17 @@ class TestExecuteCommandMixin(test_base.IronicAgentTest):
result.command_status)
self.assertEqual(exc, result.command_error)
def test_busy(self):
fake_extension = FakeExtension()
self.agent.ext_mgr = extension.ExtensionManager.make_test_instance(
[extension.Extension('fake', None, FakeExtension, fake_extension)])
self.agent.command_results = {
'fake': base.BaseCommandResult('name', {})
}
self.assertRaises(errors.AgentIsBusy,
self.agent.execute_command, 'fake.fake_sync_command')
class TestExtensionDecorators(test_base.IronicAgentTest):
def setUp(self):