libvirt imagebackend cache code encapsulation needs refactoring

Bug #1152748 reported by Rafi Khardalian
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Anton

Bug Description

libvirt.imagebackend.cache needs to be refactored to eliminate the callback to call_if_not_exists(). The only way it could meet all the requirements while remaining a callback is if the os.path.exists() check were removed from the function, which would then require path checks in each of the backend classes where prepare_template() is called. Ultimately, this is a lot more code than simply adding a backend-specific call to each class.

There's too much risk associated with such a refactor at such a late stage for Grizzly, so we'll look to tackle this for Havana.

description: updated
description: updated
Changed in nova:
status: New → Confirmed
importance: Undecided → Low
milestone: none → havana-1
Changed in nova:
milestone: havana-1 → none
Anton (agorenkov)
Changed in nova:
assignee: nobody → Anton (agorenkov)
Revision history for this message
Anton (agorenkov) wrote :

Ok, finally I have found time to perform the mentioned refactoring, but I have a few questions. Rafi, as a bug reporter could you please clarify a few details:
1. From the bug description I cannot figure out should call_if_not_exists() be completely removed or just the "os.path.exists()" check should be removed from it (but leave and possibly rename call_if_not_exists())? If it should be removed, what about synchronization (there is a @utils.synchronized decorator)?
2. The other question is about unit tests. There are a few test cases (e.g. nova.tests.virt.libvirt.test_imagebackend.LvmTestCase.test_cache_template_exists, nova.tests.virt.libvirt.test_imagebackend.Qcow2TestCase.test_cache, ...) that expect that exists() should be called. They should be updated, as the client should perform the check now, right? Or am I misunderstanding something?

Note. I have attached a patch with the changes I have already made, so you could look through them if you have questions. I could put them on review, but I want to update the tests (or implementation) first.

One more note. I'm quite new to OpenStack development, so I'd very appreciate your help even if the questions look stupid. Thanks.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/61138

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/61138
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=7eedeb2e5db4cfcd8505cc74d85ec625b7069302
Submitter: Jenkins
Branch: master

commit 7eedeb2e5db4cfcd8505cc74d85ec625b7069302
Author: Anton Gorenkov <email address hidden>
Date: Mon Dec 9 11:50:43 2013 +0200

    Move calls to os.path.exists() in libvirt imagebackend

    The checks for the path existence were removed from the base Image class
    to avoid redundant checks (some of implementations also perform them and
    behave differently depending on the results). Also special handling for
    some backends were removed from the base Image class.

    Change-Id: Ie6cdf0d6d9801f84fae7a58c1034547611712323
    Closes-Bug: #1152748

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → icehouse-2
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-2 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.