Correct _ensure_console_log_for_instance implementation

_ensure_console_log_for_instance[1] ensures VM console.log existence.

A change[2] updated in order to succeed if the file exists without nova
being able to read it (typically happens when libvirt rewrites uid/gid)
by ignoring EPERM errors.

It seems the method should ignore EACCES errors. Indeed EACCES errors
are raised when an action is not permitted because of insufficient
permissions where EPERM errors when an action is not permitted at all.

[1] nova.virt.libvirt.driver
[2] https://review.openstack.org/392643

Closes-Bug: #1691831
Change-Id: Ifc075a0fd91fc87651fcb306d6439be5369009b6
(cherry picked from commit 3072b0afbc)
This commit is contained in:
cedric.brandily 2017-05-18 21:26:09 +02:00 committed by Stephen Finucane
parent d756b78e30
commit 9d299ae50e
2 changed files with 2 additions and 2 deletions

View File

@ -10868,7 +10868,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
with test.nested(
mock.patch.object(drvr, '_get_console_log_path'),
mock.patch.object(fake_libvirt_utils, 'file_open',
side_effect=IOError(errno.EPERM, 'exc'))
side_effect=IOError(errno.EACCES, 'exc'))
) as (mock_path, mock_open):
drvr._ensure_console_log_for_instance(mock.ANY)
mock_path.assert_called_once()

View File

@ -2874,7 +2874,7 @@ class LibvirtDriver(driver.ComputeDriver):
# NOTE(sfinucan): We can safely ignore permission issues here and
# assume that it is libvirt that has taken ownership of this file.
except IOError as ex:
if ex.errno != errno.EPERM:
if ex.errno != errno.EACCES:
raise
LOG.debug('Console file already exists: %s.', console_file)