]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/rook: change storage class module option name and default value
authorJoseph Sawaya <jsawaya@redhat.com>
Fri, 2 Jul 2021 13:27:49 +0000 (09:27 -0400)
committerJoseph Sawaya <jsawaya@redhat.com>
Tue, 13 Jul 2021 17:55:05 +0000 (13:55 -0400)
This commit changes the storage_class_name module option to storage_class
and changes the default value for that module option from local_sc to local.

Signed-off-by: Joseph Sawaya <jsawaya@redhat.com>
src/pybind/mgr/rook/module.py
src/pybind/mgr/rook/rook_cluster.py

index f947bec9b0cbfb0b747cdaf14620df76b56c65a5..36294ac4827cbd261a1d8047b724e30b159e93c0 100644 (file)
@@ -74,9 +74,9 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
     MODULE_OPTIONS: List[Option] = [
         # TODO: configure k8s API addr instead of assuming local
         Option(
-            'storage_class_name',
+            'storage_class',
             type='str',
-            default='local-sc',
+            default='local',
             desc='storage class name for LSO-discovered PVs',
         ),
     ]
@@ -112,9 +112,10 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
         self._k8s_StorageV1_api: Optional[client.StorageV1Api] = None
         self._rook_cluster: Optional[RookCluster] = None
         self._rook_env = RookEnv()
-        self.storage_class_name = self.get_module_option('storage_class_name')
+        self.storage_class = self.get_module_option('storage_class')
 
         self._shutdown = threading.Event()
+        
     def config_notify(self) -> None:
         """
         This method is called whenever one of our config options is changed.
@@ -127,8 +128,8 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
                     self.get_module_option(opt['name']))  # type: ignore
             self.log.debug(' mgr option %s = %s',
                            opt['name'], getattr(self, opt['name']))  # type: ignore
-        assert isinstance(self.storage_class_name, str)
-        self.rook_cluster.storage_class_name = self.storage_class_name
+        assert isinstance(self.storage_class, str)
+        self.rook_cluster.storage_class = self.storage_class
 
     def shutdown(self) -> None:
         self._shutdown.set()
@@ -177,7 +178,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
             # Ignore here to make self.available() fail with a proper error message
             pass
 
-        assert isinstance(self.storage_class_name, str)
+        assert isinstance(self.storage_class, str)
 
         self._rook_cluster = RookCluster(
             self._k8s_CoreV1_api,
@@ -185,7 +186,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
             self._k8s_CustomObjects_api,
             self._k8s_StorageV1_api,
             self._rook_env,
-            self.storage_class_name)
+            self.storage_class)
 
         self._initialized.set()
 
index fd6c7dd5ac0038d6aead2957668b04847c3a550a..44b208053af7bb35573ba679217bd115d958a81e 100644 (file)
@@ -198,13 +198,13 @@ class KubernetesResource(Generic[T]):
 class RookCluster(object):
     # import of client.CoreV1Api must be optional at import time.
     # Instead allow mgr/rook to be imported anyway.
-    def __init__(self, coreV1_api: 'client.CoreV1Api', batchV1_api: 'client.BatchV1Api', customObjects_api: 'client.CustomObjectsApi', storageV1_api: 'client.StorageV1Api', rook_env: 'RookEnv', storage_class_name: 'str'):
+    def __init__(self, coreV1_api: 'client.CoreV1Api', batchV1_api: 'client.BatchV1Api', customObjects_api: 'client.CustomObjectsApi', storageV1_api: 'client.StorageV1Api', rook_env: 'RookEnv', storage_class: 'str'):
         self.rook_env = rook_env  # type: RookEnv
         self.coreV1_api = coreV1_api  # client.CoreV1Api
         self.batchV1_api = batchV1_api
         self.customObjects_api = customObjects_api
         self.storageV1_api = storageV1_api  # client.StorageV1Api
-        self.storage_class_name = storage_class_name # type: str
+        self.storage_class = storage_class # type: str
 
         #  TODO: replace direct k8s calls with Rook API calls
         # when they're implemented
@@ -262,13 +262,13 @@ class RookCluster(object):
                 return item['spec']['nodeName'] in nodenames
             else:
                 return True
-        matching_sc = [i for i in self.storage_classes.items if self.storage_class_name == i.metadata.name]
+        matching_sc = [i for i in self.storage_classes.items if self.storage_class == i.metadata.name]
         if len(matching_sc) == 0:
-            log.exception("no storage class exists matching name provided in ceph config at mgr/rook/storage_class_name")
-            raise Exception('No storage class exists matching name provided in ceph config at mgr/rook/storage_class_name')
+            log.exception("no storage class exists matching name provided in ceph config at mgr/rook/storage_class")
+            raise Exception('No storage class exists matching name provided in ceph config at mgr/rook/storage_class')
         if len(matching_sc) > 1:
-            log.exception("too many storage classes matching name provided in ceph config at mgr/rook/storage_class_name")
-            raise Exception('Too many storage classes matching name provided in ceph config at mgr/rook/storage_class_name')
+            log.exception("too many storage classes matching name provided in ceph config at mgr/rook/storage_class")
+            raise Exception('Too many storage classes matching name provided in ceph config at mgr/rook/storage_class')
         storage_class = matching_sc[0]
 
         lso_discovery_results = []
@@ -285,7 +285,7 @@ class RookCluster(object):
             drives = i['status']['discoveredDevices']
             for drive in drives:
                 lso_devices[drive['deviceID'].split('/')[-1]] = drive
-        pvs_in_sc = [i for i in self.pvs.items if i.spec.storage_class_name == self.storage_class_name]
+        pvs_in_sc = [i for i in self.pvs.items if i.spec.storage_class_name == self.storage_class]
 
         def convert_size(size_str: str) -> int:
             units = ("", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei")