Always fall back to sysrq when power off fails
The line we're looking for is not there when IPA is in a container, at least for CentOS based containers. Just fall back to sysrq on errors. Change-Id: Ie4ee605ad9c6cda58808512a563247175859c71e
This commit is contained in:
parent
993f9a0ceb
commit
b395181b1b
ironic_python_agent
releasenotes/notes
@ -748,15 +748,24 @@ class StandbyExtension(base.BaseAgentExtension):
|
|||||||
self.sync()
|
self.sync()
|
||||||
except errors.CommandExecutionError as e:
|
except errors.CommandExecutionError as e:
|
||||||
LOG.warning('Failed to sync file system buffers: % s', e)
|
LOG.warning('Failed to sync file system buffers: % s', e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_, stderr = utils.execute(command, use_standard_locale=True)
|
_, stderr = utils.execute(command, use_standard_locale=True)
|
||||||
if 'ignoring request.' in stderr:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.debug('%s command failed with error %s, '
|
LOG.warning('%s command failed with error %s, '
|
||||||
'falling back to sysrq-trigger.', command, stderr)
|
'falling back to sysrq-trigger', command, e)
|
||||||
if command == 'poweroff':
|
else:
|
||||||
utils.execute("echo o > /proc/sysrq-trigger", shell=True)
|
if 'ignoring request' in stderr:
|
||||||
elif command == 'reboot':
|
LOG.warning('%s command has been ignored, '
|
||||||
utils.execute("echo b > /proc/sysrq-trigger", shell=True)
|
'falling back to sysrq-trigger', command)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
if command == 'poweroff':
|
||||||
|
utils.execute("echo o > /proc/sysrq-trigger", shell=True)
|
||||||
|
elif command == 'reboot':
|
||||||
|
utils.execute("echo b > /proc/sysrq-trigger", shell=True)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
raise errors.SystemRebootError(e.exit_code, e.stdout, e.stderr)
|
raise errors.SystemRebootError(e.exit_code, e.stdout, e.stderr)
|
||||||
|
|
||||||
|
@ -1049,9 +1049,10 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch('ironic_python_agent.utils.execute', autospec=True)
|
@mock.patch('ironic_python_agent.utils.execute', autospec=True)
|
||||||
def test_run_shutdown_command_valid_poweroff_sysrq(self, execute_mock):
|
def test_run_shutdown_command_valid_poweroff_sysrq(self, execute_mock):
|
||||||
execute_mock.side_effect = [('', ''), ('', ''), ('',
|
execute_mock.side_effect = [
|
||||||
'Running in chroot, ignoring request.'),
|
('', ''), ('', ''),
|
||||||
('', '')]
|
processutils.ProcessExecutionError(''),
|
||||||
|
('', '')]
|
||||||
|
|
||||||
self.agent_extension._run_shutdown_command('poweroff')
|
self.agent_extension._run_shutdown_command('poweroff')
|
||||||
calls = [mock.call('hwclock', '-v', '--systohc'),
|
calls = [mock.call('hwclock', '-v', '--systohc'),
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes fall-back to sysrq when powering off or rebooting the node from
|
||||||
|
inside a container.
|
Loading…
x
Reference in New Issue
Block a user