← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1322847] [NEW] Simultaneous requests for creating an instance result in recopying the image to _base before it is cached

 

Public bug reported:

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)

** Affects: nova
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1322847

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

Status in OpenStack Compute (Nova):
  New

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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1322847/+subscriptions


Follow ups

References