def node_storage(self, node): """ Retrieve a summary of storage on a node. """ def listdir(path, only_dirs=False): ents = node.account.sftp_client.listdir(path) if not only_dirs: return ents paths = map(lambda fn: (fn, os.path.join(path, fn)), ents) return [p[0] for p in paths if node.account.isdir(p[1])] store = NodeStorage(RedpandaService.DATA_DIR) for ns in listdir(store.data_dir, True): ns = store.add_namespace(ns, os.path.join(store.data_dir, ns)) for topic in listdir(ns.path): topic = ns.add_topic(topic, os.path.join(ns.path, topic)) for num in listdir(topic.path): partition = topic.add_partition( num, node, os.path.join(topic.path, num)) partition.add_files(listdir(partition.path)) return store
def node_storage(self, node): """ Retrieve a summary of storage on a node. """ def listdir(path, only_dirs=False): try: ents = node.account.sftp_client.listdir(path) except FileNotFoundError: # Perhaps the directory has been deleted since we saw it. # This is normal if doing a listing concurrently with topic deletion. return [] if not only_dirs: return ents paths = map(lambda fn: (fn, os.path.join(path, fn)), ents) def safe_isdir(path): try: return node.account.isdir(path) except FileNotFoundError: # Things that no longer exist are also no longer directories return False return [p[0] for p in paths if safe_isdir(p[1])] store = NodeStorage(RedpandaService.DATA_DIR) for ns in listdir(store.data_dir, True): if ns == '.coprocessor_offset_checkpoints': continue ns = store.add_namespace(ns, os.path.join(store.data_dir, ns)) for topic in listdir(ns.path): topic = ns.add_topic(topic, os.path.join(ns.path, topic)) for num in listdir(topic.path): partition = topic.add_partition( num, node, os.path.join(topic.path, num)) partition.add_files(listdir(partition.path)) return store