summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ironic/drivers/modules/image_utils.py10
-rw-r--r--ironic/drivers/modules/redfish/raid.py8
-rw-r--r--ironic/tests/unit/drivers/modules/irmc/test_inspect.py25
-rw-r--r--ironic/tests/unit/drivers/modules/redfish/test_raid.py4
-rw-r--r--ironic/tests/unit/drivers/modules/test_image_utils.py47
-rw-r--r--releasenotes/config.yaml5
-rw-r--r--releasenotes/notes/fix-context-image-hardlink-16f452974abc7327.yaml7
-rw-r--r--releasenotes/notes/fix-nonetype-object-is-not-iterable-0592926d890d6c11.yaml7
-rw-r--r--reno.yaml4
-rw-r--r--tox.ini19
10 files changed, 99 insertions, 37 deletions
diff --git a/ironic/drivers/modules/image_utils.py b/ironic/drivers/modules/image_utils.py
index 304c199bf..86607ee25 100644
--- a/ironic/drivers/modules/image_utils.py
+++ b/ironic/drivers/modules/image_utils.py
@@ -211,6 +211,16 @@ class ImageHandler(object):
try:
os.link(image_file, published_file)
os.chmod(image_file, self._file_permission)
+ try:
+ utils.execute(
+ '/usr/sbin/restorecon', '-i', '-R', 'v', public_dir)
+ except FileNotFoundError as exc:
+ LOG.debug(
+ "Could not restore SELinux context on "
+ "%(public_dir)s, restorecon command not found.\n"
+ "Error: %(error)s",
+ {'public_dir': public_dir,
+ 'error': exc})
except OSError as exc:
LOG.debug(
diff --git a/ironic/drivers/modules/redfish/raid.py b/ironic/drivers/modules/redfish/raid.py
index 809ec59c6..154cd53d3 100644
--- a/ironic/drivers/modules/redfish/raid.py
+++ b/ironic/drivers/modules/redfish/raid.py
@@ -1120,7 +1120,9 @@ class RedfishRAID(base.RAIDInterface):
raid_configs['pending'].setdefault(controller, []).append(
logical_disk)
- node.set_driver_internal_info('raid_configs', raid_configs)
+ # Store only when async operation
+ if reboot_required:
+ node.set_driver_internal_info('raid_configs', raid_configs)
return raid_configs, reboot_required
@@ -1182,7 +1184,9 @@ class RedfishRAID(base.RAIDInterface):
response.task_monitor_uri)
reboot_required = True
- node.set_driver_internal_info('raid_configs', raid_configs)
+ # Store only when async operation
+ if reboot_required:
+ node.set_driver_internal_info('raid_configs', raid_configs)
return raid_configs, reboot_required
diff --git a/ironic/tests/unit/drivers/modules/irmc/test_inspect.py b/ironic/tests/unit/drivers/modules/irmc/test_inspect.py
index 5c66cb96a..da91ec61d 100644
--- a/ironic/tests/unit/drivers/modules/irmc/test_inspect.py
+++ b/ironic/tests/unit/drivers/modules/irmc/test_inspect.py
@@ -204,8 +204,8 @@ class IRMCInspectTestCase(test_common.BaseIRMCTest):
_inspect_hardware_mock.return_value = (inspected_props,
inspected_macs,
new_traits)
- new_port_mock1 = mock.MagicMock(spec=objects.Port)
- new_port_mock2 = mock.MagicMock(spec=objects.Port)
+ new_port_mock1 = objects.Port
+ new_port_mock2 = objects.Port
port_mock.side_effect = [new_port_mock1, new_port_mock2]
@@ -220,11 +220,11 @@ class IRMCInspectTestCase(test_common.BaseIRMCTest):
port_mock.assert_has_calls([
mock.call(task.context, address=inspected_macs[0],
node_id=node_id),
+ mock.call.create(),
mock.call(task.context, address=inspected_macs[1],
- node_id=node_id)
- ])
- new_port_mock1.create.assert_called_once_with()
- new_port_mock2.create.assert_called_once_with()
+ node_id=node_id),
+ mock.call.create()
+ ], any_order=False)
self.assertTrue(info_mock.called)
task.node.refresh()
@@ -259,8 +259,9 @@ class IRMCInspectTestCase(test_common.BaseIRMCTest):
_inspect_hardware_mock.return_value = (inspected_props,
inspected_macs,
new_traits)
- new_port_mock1 = mock.MagicMock(spec=objects.Port)
- new_port_mock2 = mock.MagicMock(spec=objects.Port)
+
+ new_port_mock1 = objects.Port
+ new_port_mock2 = objects.Port
port_mock.side_effect = [new_port_mock1, new_port_mock2]
@@ -276,11 +277,11 @@ class IRMCInspectTestCase(test_common.BaseIRMCTest):
port_mock.assert_has_calls([
mock.call(task.context, address=inspected_macs[0],
node_id=node_id),
+ mock.call.create(),
mock.call(task.context, address=inspected_macs[1],
- node_id=node_id)
- ])
- new_port_mock1.create.assert_called_once_with()
- new_port_mock2.create.assert_called_once_with()
+ node_id=node_id),
+ mock.call.create()
+ ], any_order=False)
self.assertTrue(info_mock.called)
task.node.refresh()
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_raid.py b/ironic/tests/unit/drivers/modules/redfish/test_raid.py
index dfb3c1473..843be735c 100644
--- a/ironic/tests/unit/drivers/modules/redfish/test_raid.py
+++ b/ironic/tests/unit/drivers/modules/redfish/test_raid.py
@@ -336,6 +336,8 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
self.assertEqual(mock_node_power_action.call_count, 0)
self.assertEqual(mock_build_agent_options.call_count, 0)
self.assertEqual(mock_prepare_ramdisk.call_count, 0)
+ self.assertIsNone(
+ task.node.driver_internal_info.get('raid_configs'))
self.assertEqual(
[{'controller': 'RAID controller 1',
'id': '1',
@@ -1066,6 +1068,8 @@ class RedfishRAIDTestCase(db_base.DbTestCase):
self.assertEqual(mock_node_power_action.call_count, 0)
self.assertEqual(mock_build_agent_options.call_count, 0)
self.assertEqual(mock_prepare_ramdisk.call_count, 0)
+ self.assertIsNone(
+ task.node.driver_internal_info.get('raid_configs'))
self.assertEqual([], task.node.raid_config['logical_disks'])
self.assertNotEqual(
last_updated, task.node.raid_config['last_updated'])
diff --git a/ironic/tests/unit/drivers/modules/test_image_utils.py b/ironic/tests/unit/drivers/modules/test_image_utils.py
index 753452f5d..b6c572125 100644
--- a/ironic/tests/unit/drivers/modules/test_image_utils.py
+++ b/ironic/tests/unit/drivers/modules/test_image_utils.py
@@ -105,73 +105,96 @@ class RedfishImageHandlerTestCase(db_base.DbTestCase):
mock_swift_api.delete_object.assert_called_once_with(
'ironic_redfish_container', object_name)
+ @mock.patch.object(utils, 'execute', autospec=True)
@mock.patch.object(os, 'chmod', autospec=True)
@mock.patch.object(image_utils, 'shutil', autospec=True)
@mock.patch.object(os, 'link', autospec=True)
@mock.patch.object(os, 'mkdir', autospec=True)
def test_publish_image_local_link(
- self, mock_mkdir, mock_link, mock_shutil, mock_chmod):
+ self, mock_mkdir, mock_link, mock_shutil, mock_chmod,
+ mock_execute):
self.config(use_swift=False, group='redfish')
self.config(http_url='http://localhost', group='deploy')
img_handler_obj = image_utils.ImageHandler(self.node.driver)
-
url = img_handler_obj.publish_image('file.iso', 'boot.iso')
-
self.assertEqual(
'http://localhost/redfish/boot.iso', url)
+ mock_mkdir.assert_called_once_with('/httpboot/redfish', 0o755)
+ mock_link.assert_called_once_with(
+ 'file.iso', '/httpboot/redfish/boot.iso')
+ mock_chmod.assert_called_once_with('file.iso', 0o644)
+ mock_execute.assert_called_once_with(
+ '/usr/sbin/restorecon', '-i', '-R', 'v', '/httpboot/redfish')
+ @mock.patch.object(utils, 'execute', autospec=True)
+ @mock.patch.object(os, 'chmod', autospec=True)
+ @mock.patch.object(image_utils, 'shutil', autospec=True)
+ @mock.patch.object(os, 'link', autospec=True)
+ @mock.patch.object(os, 'mkdir', autospec=True)
+ def test_publish_image_local_link_no_restorecon(
+ self, mock_mkdir, mock_link, mock_shutil, mock_chmod,
+ mock_execute):
+ self.config(use_swift=False, group='redfish')
+ self.config(http_url='http://localhost', group='deploy')
+ img_handler_obj = image_utils.ImageHandler(self.node.driver)
+ url = img_handler_obj.publish_image('file.iso', 'boot.iso')
+ self.assertEqual(
+ 'http://localhost/redfish/boot.iso', url)
mock_mkdir.assert_called_once_with('/httpboot/redfish', 0o755)
mock_link.assert_called_once_with(
'file.iso', '/httpboot/redfish/boot.iso')
mock_chmod.assert_called_once_with('file.iso', 0o644)
+ mock_execute.return_value = FileNotFoundError
+ mock_shutil.assert_not_called()
+ @mock.patch.object(utils, 'execute', autospec=True)
@mock.patch.object(os, 'chmod', autospec=True)
@mock.patch.object(image_utils, 'shutil', autospec=True)
@mock.patch.object(os, 'link', autospec=True)
@mock.patch.object(os, 'mkdir', autospec=True)
def test_publish_image_external_ip(
- self, mock_mkdir, mock_link, mock_shutil, mock_chmod):
+ self, mock_mkdir, mock_link, mock_shutil, mock_chmod,
+ mock_execute):
self.config(use_swift=False, group='redfish')
self.config(http_url='http://localhost',
external_http_url='http://non-local.host',
group='deploy')
img_handler_obj = image_utils.ImageHandler(self.node.driver)
-
url = img_handler_obj.publish_image('file.iso', 'boot.iso')
-
self.assertEqual(
'http://non-local.host/redfish/boot.iso', url)
-
mock_mkdir.assert_called_once_with('/httpboot/redfish', 0o755)
mock_link.assert_called_once_with(
'file.iso', '/httpboot/redfish/boot.iso')
mock_chmod.assert_called_once_with('file.iso', 0o644)
+ mock_execute.assert_called_once_with(
+ '/usr/sbin/restorecon', '-i', '-R', 'v', '/httpboot/redfish')
+ @mock.patch.object(utils, 'execute', autospec=True)
@mock.patch.object(os, 'chmod', autospec=True)
@mock.patch.object(image_utils, 'shutil', autospec=True)
@mock.patch.object(os, 'link', autospec=True)
@mock.patch.object(os, 'mkdir', autospec=True)
def test_publish_image_external_ip_node_override(
- self, mock_mkdir, mock_link, mock_shutil, mock_chmod):
+ self, mock_mkdir, mock_link, mock_shutil, mock_chmod,
+ mock_execute):
self.config(use_swift=False, group='redfish')
self.config(http_url='http://localhost',
external_http_url='http://non-local.host',
group='deploy')
img_handler_obj = image_utils.ImageHandler(self.node.driver)
self.node.driver_info["external_http_url"] = "http://node.override.url"
-
override_url = self.node.driver_info.get("external_http_url")
-
url = img_handler_obj.publish_image('file.iso', 'boot.iso',
override_url)
-
self.assertEqual(
'http://node.override.url/redfish/boot.iso', url)
-
mock_mkdir.assert_called_once_with('/httpboot/redfish', 0o755)
mock_link.assert_called_once_with(
'file.iso', '/httpboot/redfish/boot.iso')
mock_chmod.assert_called_once_with('file.iso', 0o644)
+ mock_execute.assert_called_once_with(
+ '/usr/sbin/restorecon', '-i', '-R', 'v', '/httpboot/redfish')
@mock.patch.object(os, 'chmod', autospec=True)
@mock.patch.object(image_utils, 'shutil', autospec=True)
diff --git a/releasenotes/config.yaml b/releasenotes/config.yaml
new file mode 100644
index 000000000..26538010e
--- /dev/null
+++ b/releasenotes/config.yaml
@@ -0,0 +1,5 @@
+---
+# Ignore the kilo-eol tag because that branch does not work with reno
+# and contains no release notes.
+# Ignore bugfix tags because their releasenotes are covered under stable
+closed_branch_tag_re: 'r"(?!^(kilo-|bugfix-)).+-eol$"'
diff --git a/releasenotes/notes/fix-context-image-hardlink-16f452974abc7327.yaml b/releasenotes/notes/fix-context-image-hardlink-16f452974abc7327.yaml
new file mode 100644
index 000000000..90d38d5cc
--- /dev/null
+++ b/releasenotes/notes/fix-context-image-hardlink-16f452974abc7327.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+ - |
+ Fixes an issue where if selinux is enabled and enforcing, and
+ the published image is a hardlink, the source selinux context
+ is preserved, causing access denied when retrieving the image
+ using hardlink URL.
diff --git a/releasenotes/notes/fix-nonetype-object-is-not-iterable-0592926d890d6c11.yaml b/releasenotes/notes/fix-nonetype-object-is-not-iterable-0592926d890d6c11.yaml
new file mode 100644
index 000000000..ec9043adb
--- /dev/null
+++ b/releasenotes/notes/fix-nonetype-object-is-not-iterable-0592926d890d6c11.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+ - |
+ Fixes ``'NoneType' object is not iterable`` in conductor logs for
+ ``redfish`` and ``idrac-redfish`` RAID clean and deploy steps. The message
+ should no longer appear. For affected nodes re-create the node or delete
+ ``raid_configs`` entry from ``driver_internal_info`` field.
diff --git a/reno.yaml b/reno.yaml
deleted file mode 100644
index dd0aac790..000000000
--- a/reno.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
----
-# Ignore the kilo-eol tag because that branch does not work with reno
-# and contains no release notes.
-closed_branch_tag_re: "(.+)(?<!kilo)-eol"
diff --git a/tox.ini b/tox.ini
index 247e819a4..b42a0a8d6 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,16 +8,21 @@ ignore_basepython_conflict=true
usedevelop = True
basepython = python3
setenv = VIRTUAL_ENV={envdir}
- PYTHONDONTWRITEBYTECODE = 1
+ PYTHONDONTWRITEBYTECODE=1
LANGUAGE=en_US
LC_ALL=en_US.UTF-8
deps =
- -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/zed}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
stestr run --slowest {posargs}
-passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
+passenv = http_proxy
+ HTTP_PROXY
+ https_proxy
+ HTTPS_PROXY
+ no_proxy
+ NO_PROXY
[testenv:unit-with-driver-libs]
deps = {[testenv]deps}
@@ -77,7 +82,7 @@ commands = oslo_debug_helper -t ironic/tests/unit {posargs}
[testenv:docs]
# NOTE(dtantsur): documentation building process requires importing ironic
deps =
- -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/zed}
-r{toxinidir}/requirements.txt
-r{toxinidir}/doc/requirements.txt
commands = sphinx-build -b html -W doc/source doc/build/html
@@ -94,7 +99,7 @@ commands =
# NOTE(Mahnoor): documentation building process requires importing ironic API modules
usedevelop = False
deps =
- -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/zed}
-r{toxinidir}/requirements.txt
-r{toxinidir}/doc/requirements.txt
allowlist_externals = bash
@@ -105,7 +110,7 @@ commands =
[testenv:releasenotes]
usedevelop = False
deps =
- -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/zed}
-r{toxinidir}/doc/requirements.txt
commands =
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
@@ -113,7 +118,7 @@ commands =
[testenv:venv]
setenv = PYTHONHASHSEED=0
deps =
- -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/zed}
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/doc/requirements.txt
commands = {posargs}