When reporting that agent is busy, report the executed command
Also make this API return a proper HTTP code (409 instead of 500). Change-Id: I5d86878b5ed6142ed2630adee78c0867c49b663f
This commit is contained in:
parent
67f053d94c
commit
fe6b687968
@ -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."""
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user