From 3072b0afbc157eef5e72f191525296cfa2b014cb 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 --- 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 ed5f364a41ad..c15837dac46b 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -10991,7 +10991,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 67b4bf5f76af..8cfb7d59f663 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -3006,7 +3006,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)