Jump to: navigation, search

Difference between revisions of "Manila/Provide private data storage API for drivers"

m (fix Github commit reference)
Line 50: Line 50:
  
 
===This concept vs model updates in Share Manager===
 
===This concept vs model updates in Share Manager===
As you can see in  https://github.com/openstack/manila/815e2c95acc402847bb497365ea5caba608fd8cc/master/manila/share/manager.py Share Manager is responsible to update information in DB. For example:
+
As you can see in  https://github.com/openstack/manila/blob/815e2c95acc402847bb497365ea5caba608fd8cc/manila/share/manager.py Share Manager is responsible to update information in DB. For example:
 
<source lang="python">
 
<source lang="python">
 
         # ...
 
         # ...

Revision as of 05:34, 20 April 2015

Provide limited data API for drivers

Problem

Drivers haven’t possibility to store key/value pairs in the database for each share (and probably for share snapshots too). These values are not visible to the tenants, they're just for the drivers.

Use cases

Use case #1: Generic driver should store volume id instead of renaming volume (current behaviour)
Use case #2: Some backends that can't create 32-character share names and need to maintain a mapping from the 128-bit UUID to something smaller.

Concept

Provide share data storage (key-value) for drivers.

Implement simple storage with following interface:

class DriverShareData(object):
   def __init__(self, context, db, backend_host):
      pass

   def get(self, share_id, key=None, default_value=None):
       pass

   def update(self, share_id, share_data, delete_existing=False):
       pass

   def delete(self, share_id, key):
       pass


Provide this storage in the manager to all drivers:

class ShareManager(manager.SchedulerDependentManager):
    # …
    def __init__(self, share_driver=None, service_name=None, *args, **kwargs):
       # …
       self.share_data = DriverShareData(self.context, self.db, self.host)
       self.driver = importutils.import_object(
           share_driver, 
           self.share_data,
           #...
       )
       # ...


This storage will allow to get/update/delete private data of any share managed by the driver. Drivers will be able to create mappings between data in manila (Share) and backends (NAS). Also, drivers could use this storage for caching purposes - to minimize an amount of requests to the backend.

Default implementation will store data in separate table in Manila database.

This concept vs model updates in Share Manager

As you can see in https://github.com/openstack/manila/blob/815e2c95acc402847bb497365ea5caba608fd8cc/manila/share/manager.py Share Manager is responsible to update information in DB. For example:

        # ...
        try:
            if snapshot_ref:
                export_locations = self.driver.create_share_from_snapshot(
                    context, share_ref, snapshot_ref,
                    share_server=share_server)
            else:
                export_locations = self.driver.create_share(
                    context, share_ref, share_server=share_server)

            self.db.share_export_locations_update(context, share_id,
                                                  export_locations)
       # ...


We could follow this rule and simply replace return value by dictionary with optional keys:

        # ...
        try:
            if snapshot_ref:
                data = self.driver.create_share_from_snapshot(
                    context, share_ref, snapshot_ref,
                    share_server=share_server)
            else:
                data = self.driver.create_share(
                    context, share_ref, share_server=share_server)

            self.db.share_export_locations_update(context, share_id,
                                                  data['export_locations'])
            # New code
            private_share_data = data.get('private_share_data')
            if private_share_data:
              self.db.private_share_data_update(context, share_id, private_share_data)
       # ...

But in this case we will be forced to do so in each method where drivers require private share data. Furthermore, we will be forced to retrieve and pass private share data to drivers through argument even if they don't require this data. This will cause performance penalty and code will look like a mess :)

That's why my (u_glide) proposal is: Leave current model updates in Share manager as is and provide DriverShareData interface to all drivers in the manager.

DB scaling risks

By default, all private share data will be stored in manila SQL DB and we have a risk that DB becomes a bottleneck in large deployments. This risk (in a scope of this feature) can be addressed by implementation of different storage backends for this interface. As we can see backends don’t share data, so storage can be easily horizontally scaled. We can move private share data to any distributed key-value storage.