From 9d299ae50ea52c63811eba11ee974643c17079ad Mon Sep 17 00:00:00 2001 From: "cedric.brandily" Date: Thu, 18 May 2017 21:26:09 +0200 Subject: [PATCH] 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) --- nova/tests/unit/virt/libvirt/test_driver.py | 2 +- nova/virt/libvirt/driver.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 3a121f63b62a..45018f5451b2 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -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() diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 9b1cab215169..0d2d0ce708ba 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -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)