From: Joseph Sawaya Date: Thu, 15 Jul 2021 17:23:11 +0000 (-0400) Subject: mgr/rook: add node and PV name information to Device in DefaultFetcher X-Git-Tag: v17.1.0~1144^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8066c630cf101c3cb9a2d72b379d6a9c2cdccdd6;p=ceph.git mgr/rook: add node and PV name information to Device in DefaultFetcher 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 --- diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index 10d307d900ba..dc16b7f3a3d9 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -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)