← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1132138] Re: Unused kernels and ramdisks not removed by libvirt image cache manager

 

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

** Changed in: nova
    Milestone: None => grizzly-rc1

-- 
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/1132138

Title:
  Unused kernels and ramdisks not removed by libvirt image cache manager

Status in OpenStack Compute (Nova):
  Fix Released

Bug description:
  When the image cache manager runs, it only cleans up unused base disk
  images ... not kernels and ramdisks

  This is clearly the understood behaviour of the code:

      def _list_base_images(self, base_dir):
          """Return a list of the images present in _base.                                                                                    
                                                                                                                                              
          Determine what images we have on disk. There will be other files in                                                                 
          this directory (for example kernels) so we only grab the ones which                                                                 
          are the right length to be disk images.                                                                                             
          ...
          """
          digest_size = hashlib.sha1().digestsize * 2
          for ent in os.listdir(base_dir):
              if len(ent) == digest_size:
                  self._store_image(base_dir, ent, original=True)

  and it's only the base disk images which are stored using their sha1
  sum as their filename:

          if disk_images['kernel_id']:
              fname = disk_images['kernel_id']
              raw('kernel').cache(fetch_func=libvirt_utils.fetch_image,
                                  context=context,
                                  filename=fname,
                                  ...)
              if disk_images['ramdisk_id']:
                  fname = disk_images['ramdisk_id']
                  raw('ramdisk').cache(fetch_func=libvirt_utils.fetch_image,
                                       context=context,
                                       filename=fname,
                                       ...)

          root_fname = hashlib.sha1(str(disk_images['image_id'])).hexdigest()
          ...
          if 'disk' in disk_mapping:
              image('disk').cache(fetch_func=libvirt_utils.fetch_image,
                                  context=context,
                                  filename=root_fname,
                                  ...)

  Assuming I'm not missing something and it does make sense to clean
  these up, I guess we can:

    1) start storing kernels and ramdisks using their sha1 sum as their
  filename or

    2) have the image cache manager somehow recognize the kernel/ramdisk
  filenames as images to examine

  We also need the image cache manager to track kernels and ramdisks as
  used images when listing instances

  i.e. need to include kernel_id and ramdisk_id here:

              image_ref_str = str(instance['image_ref'])
              local, remote, insts = self.used_images.get(image_ref_str,
                                                          (0, 0, []))

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