]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/rook: add node and PV name information to Device in DefaultFetcher
authorJoseph Sawaya <jsawaya@redhat.com>
Thu, 15 Jul 2021 17:23:11 +0000 (13:23 -0400)
committerJoseph Sawaya <jsawaya@redhat.com>
Thu, 15 Jul 2021 17:23:11 +0000 (13:23 -0400)
This commit adds the information about the node and PV name to the Device object
when the DefaultFetcher generates it.

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

index 10d307d900ba076afe1d64766d9fe5f7a4f8f443..dc16b7f3a3d925ae932e519cd9b8822c4a90baa1 100644 (file)
@@ -119,24 +119,25 @@ class DefaultFetcher():
             nodename_to_devices[node].append(device)
         return nodename_to_devices
 
-    def device(self, i: client.V1PersistenVolume) -> Tuple[str, Device]:
+    def device(self, i: 'client.V1PersistentVolume') -> Tuple[str, Device]:
+        node = 'N/A'
+        if i.spec.node_affinity:
+            terms = i.spec.node_affinity.required.node_selector_terms
+            if len(terms) == 1 and len(terms[0].match_expressions) == 1 and terms[0].match_expressions[0].key == 'kubernetes.io/hostname' and len(terms[0].match_expressions[0].values) == 1:
+                node = terms[0].match_expressions[0].values[0]
         size = self.convert_size(i.spec.capacity['storage'])
         path = i.spec.host_path.path if i.spec.host_path else ('/dev/' + i.metadata.annotations['storage.openshift.com/device-name']) if i.metadata.annotations['storage.openshift.com/device-name'] else ''
-        state = i.spec.volume_mode == 'Block' and i.spec.claim_ref == None
+        state = i.spec.volume_mode == 'Block' and i.status.phase == 'Available'
+        pv_name = i.metadata.name
         device = Device(
                 path = path,
                 sys_api = dict(
-                    size = size
+                    size = size,
+                    node = node,
+                    pv_name = pv_name
                 ),
                 available = state,
         )
-
-        node = 'N/A'
-
-        if i.spec.node_affinity:
-            terms = i.spec.node_affinity.required.node_selector_terms
-            if len(terms) == 1 and len(terms[0].match_expressions) == 1 and terms[0].match_expressions[0].key == 'kubernetes.io/hostname' and len(terms[0].match_expressions[0].values) == 1:
-                node = terms[0].match_expressions[0].values[0]
         return (node, device)