From: cedric.brandily Date: Thu, 18 May 2017 19:26:09 +0000 (+0200) Subject: Correct _ensure_console_log_for_instance implementation X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=81838f1ae910383bf0992684e6b0ef30a6d943ba;p=osstest%2Fopenstack-nova.git 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 3072b0afbc157eef5e72f191525296cfa2b014cb) --- diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 3be22f6eb6..2647cc2700 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -10926,7 +10926,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() diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 0e8fe0702c..73c4ca02be 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2964,7 +2964,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)