From 821a1b4899f62a3c0b0ab000c5a69a147b925fb2 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 19 Apr 2024 15:22:06 +0300 Subject: [PATCH] Remove empty nodes from tree because PG DSL expects that all leaf nodes are OSDs --- mon/mon.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mon/mon.js b/mon/mon.js index 94036ec9..56f2c948 100644 --- a/mon/mon.js +++ b/mon/mon.js @@ -958,6 +958,25 @@ class Mon const parent = parent_level && parent_level < node_level ? node_cfg.parent : ''; tree[parent].children.push(tree[node_id]); } + // Delete empty nodes + let deleted = 0; + do + { + deleted = 0; + for (const node_id in tree) + { + if (tree[node_id].level !== 'osd' && (!tree[node_id].children || !tree[node_id].children.length)) + { + const parent = tree[node_id].parent; + if (parent) + { + tree[parent].children = tree[parent].children.filter(c => c != tree[node_id]); + } + deleted++; + delete tree[node_id]; + } + } + } while (deleted > 0); return tree; }