summaryrefslogtreecommitdiff
path: root/ironic_python_agent/extensions
diff options
context:
space:
mode:
authorJulia Kreger <juliaashleykreger@gmail.com>2019-11-01 06:40:13 -0700
committerJulia Kreger <juliaashleykreger@gmail.com>2019-11-01 06:57:58 -0700
commitc5956bdada2442a9051d33dd19b59fce3bdd45be (patch)
tree2df363b51438fc06b0d38a9b80ca61ecc29d6c3b /ironic_python_agent/extensions
parent68fb8006e0e339282226662ac68ae2273ad5fd85 (diff)
downloadironic-python-agent-c5956bdada2442a9051d33dd19b59fce3bdd45be.tar.gz
Suppress errors from iscsi session cleanup
In some cases, where the rts library is not installed, IPA was recently changed to try and tear down the local side of the iscsi connection by trying to tear down bond and target being offered. The whole attempt with this is to ensure that no disk locks are in place which can prevent partition table updates. Since we added this logic, in some cases these commands can fail and cause the deployment process to fail when it would have otherwise succeeded. As such, suppress the errors. Change-Id: I0e04936ad337b394dd68e9b0396a9f1203218f9f
Diffstat (limited to 'ironic_python_agent/extensions')
-rw-r--r--ironic_python_agent/extensions/iscsi.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/ironic_python_agent/extensions/iscsi.py b/ironic_python_agent/extensions/iscsi.py
index 7fca4154..21dfba39 100644
--- a/ironic_python_agent/extensions/iscsi.py
+++ b/ironic_python_agent/extensions/iscsi.py
@@ -114,18 +114,28 @@ def clean_up(device):
try:
rts_root = rtslib_fb.RTSRoot()
except (OSError, EnvironmentError, rtslib_fb.RTSLibError) as exc:
- LOG.info('Linux-IO is not available, attemting to stop tgtd mapping. '
- 'Error: %s.', exc)
- cmd = ['tgtadm', '--lld', 'iscsi', '--mode', 'target', '--op',
- 'unbind', '--tid', '1', '--initiator-address', 'ALL']
- _execute(cmd, "Error when cleaning up iscsi binds.")
-
+ try:
+ LOG.info('Linux-IO is not available, attemting to stop tgtd '
+ 'mapping. Error: %s.', exc)
+ cmd = ['tgtadm', '--lld', 'iscsi', '--mode', 'target', '--op',
+ 'unbind', '--tid', '1', '--initiator-address', 'ALL']
+ _execute(cmd, "Error when cleaning up iscsi binds.")
+ except errors.ISCSICommandError:
+ # This command may fail if the target was already torn down
+ # and that is okay, we just want to ensure it has been torn
+ # down so there should be no disk locks persisting.
+ pass
cmd = ['sync']
_execute(cmd, "Error flushing buffers to disk.")
-
- cmd = ['tgtadm', '--lld', 'iscsi', '--mode', 'target', '--op',
- 'delete', '--tid', '1']
- _execute(cmd, "Error deleting the iscsi target configuration.")
+ try:
+ cmd = ['tgtadm', '--lld', 'iscsi', '--mode', 'target', '--op',
+ 'delete', '--tid', '1']
+ _execute(cmd, "Error deleting the iscsi target configuration.")
+ except errors.ISCSICommandError:
+ # This command should remove the target from being offered.
+ # It is just proper clean-up, and often previously the IPA
+ # side, or "target" was never really torn down in many cases.
+ pass
return
storage = None