]> xenbits.xensource.com Git - osstest/openstack-nova.git/commitdiff
Correct _ensure_console_log_for_instance implementation
authorcedric.brandily <cedric.brandily@thalesgroup.com>
Thu, 18 May 2017 19:26:09 +0000 (21:26 +0200)
committerStephen Finucane <sfinucan@redhat.com>
Tue, 30 May 2017 08:16:50 +0000 (08:16 +0000)
_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
nova/virt/libvirt/driver.py

index 3be22f6eb642ab668612923320f27d791f4aa2da..2647cc27002eb924715513f8975cec82222afe14 100644 (file)
@@ -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()
index 0e8fe0702c149e7a11c4f9a37beea89407e483e3..73c4ca02be2d82eb5494f779c7a1f81bb7e91288 100644 (file)
@@ -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)