Simultaneous requests for creating an instance result in recopying the image to _base before it is cached

Bug #1322847 reported by Alexei Karve
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
New
Undecided
Unassigned

Bug Description

Simultaneous requests for creating an instance result in unnecessary recopying of the image with ".part" extension to _base directory (one for each request) before it is cached. The fetch_func_sync needs to check again inside the synchronized whether the earlier copy was completed as indicated below in https://github.com/openstack/nova/blob/master/nova/virt/libvirt/imagebackend.py

    def cache(self, fetch_func, filename, size=None, *args, **kwargs):
        """Creates image from template.

        Ensures that template and image not already exists.
        Ensures that base directory exists.
        Synchronizes on template fetching.

        :fetch_func: Function that creates the base image
                     Should accept `target` argument.
        :filename: Name of the file in the image directory
        :size: Size of created image in bytes (optional)
        """
        @utils.synchronized(filename, external=True, lock_path=self.lock_path)
        def fetch_func_sync(target, *args, **kwargs):
            if not os.path.exists(target):
                fetch_func(target=target, *args, **kwargs)

Tags: compute
Tracy Jones (tjones-i)
tags: added: compute
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.