← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1228256] Re: Glance cache cleaner wrongly deletes cache for non invalid images

 

** Changed in: glance
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1228256

Title:
  Glance cache cleaner wrongly deletes cache for non invalid images

Status in OpenStack Image Registry and Delivery Service (Glance):
  Fix Released

Bug description:
  The cache cleaner is currently cleaning invalid images like so:

  def clean(self, stall_time=None):
          """
          Delete any image files in the invalid directory and any
          files in the incomplete directory that are older than a
          configurable amount of time.
          """
          self.delete_invalid_files()

          if stall_time is None:
              stall_time = CONF.image_cache_stall_time

          now = time.time()
          older_than = now - stall_time
          self.delete_stalled_files(older_than)


  
  def delete_stalled_files(self, older_than):
          """
          Removes any incomplete cache entries older than a
          supplied modified time.

          :param older_than: Files written to on or before this timestemp
                             will be deleted.
          """
          for path in self.get_cache_files(self.incomplete_dir):
              os.unlink(path)
              LOG.info(_("Removed stalled cache file %s"), path)

  
  Although the "older_than" time is passed its not used anywhere, as a result if you run this through a cron, valid images in process for download/getting cached will be deleted from /incomplete since the cleaner does not check for time at all.

  Glance api log will complain when this happens in the middle of the
  fetch:

  Fetch finished, moving '/var/lib/glance/image-
  cache/incomplete/b9b38c90-cf64-4fa9-9e73-73da77e40074' to
  '/var/lib/glance/image-cache/b9b38c90-cf64-4fa9-9e73-73da77e40074'
  commit

  ERROR glance.image_cache [...] Exception encountered while tee'ing
  image 'b9b38c90-cf64-4fa9-9e73-73da77e40074' into cache: [Errno 2] No
  such file or directory. Continuing with response.

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