os-brick/os_brick
Gorka Eguileor de89635ab7 Protect against race within os.path.realpath
On iSCSI connections, when we are making sure that there no links remain
like /dev/disk/by-id/scsi-* we make several calls to os.path.realpath
which normal behavior is:

- If file path doesn't exist, returns the same file path
- If file path exists, return the real path

But there is a third option, and that is when the file did exist but it
dissapear right when the  call to os.readlink in posixpath:_joinrealpath

   path, ok = _joinrealpath(path, os.readlink(newpath), seen)

Which ends up raising an exception such as:

   OSError: [Errno 2] No such file or directory:
            '/dev/disk/by-id/scsi-20024f40058540081'

And because of this exception the detach will fail when it shouldn't.

This patch adds includes the call to os.path.realpath within a
try...except clause to prevent this race condition from unexpectely
making the detach operation fail.

Change-Id: Ieb58826b28c62094c941fce10863c0a75fb4e8aa
Closes-Bug: #1719719
2017-09-26 21:01:14 +02:00
..
encryptors Merge "encryptors: Delay removal of legacy provider names" 2017-05-28 23:06:02 +00:00
initiator Protect against race within os.path.realpath 2017-09-26 21:01:14 +02:00
local_dev Revert "Don't use ignoreskipactivation for thin LVM" 2017-07-05 13:16:38 +00:00
privileged Refactor iSCSI connect 2017-06-16 16:09:35 +02:00
remotefs Stop ignoring H405 hacking rule in tox 2017-05-24 00:44:57 +02:00
tests Protect against race within os.path.realpath 2017-09-26 21:01:14 +02:00
__init__.py doc: Remove cruft from conf.py 2017-08-08 15:44:29 +01:00
exception.py Refactor iSCSI connect 2017-06-16 16:09:35 +02:00
executor.py iSCSI multipath: improve logging on connect 2017-06-26 20:31:59 +02:00
i18n.py Update and replace http with https for doc links 2017-07-26 02:18:44 +00:00
utils.py Mask passwords in utils.trace for func params 2016-11-08 12:55:46 -05:00
version.py Add reno for release notes management 2016-01-20 19:19:36 -06:00