Skip to content

Commit fd19273

Browse files
committed
fix: include unmapped targets with most queries
1 parent 56db1ce commit fd19273

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

mgmtd/src/db/schema/4.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
DROP VIEW targets_ext;
2+
3+
CREATE VIEW targets_ext AS
4+
SELECT e.alias, t.*, n.node_uid
5+
FROM targets AS t
6+
INNER JOIN entities AS e ON e.uid = t.target_uid
7+
LEFT JOIN nodes AS n USING(node_type, node_id)
8+
;

mgmtd/src/grpc/delete_target.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,5 @@ pub(crate) async fn delete_target(
6363

6464
let target = Some(target.into());
6565

66-
log::warn!("{target:?}");
67-
6866
Ok(pm::DeleteTargetResponse { target })
6967
}

mgmtd/src/grpc/get_targets.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(crate) async fn get_targets(
2929
t.free_space, t.free_inodes, t.total_space, t.total_inodes,
3030
gp.p_target_id, gs.s_target_id
3131
FROM targets_ext AS t
32-
INNER JOIN nodes_ext AS n USING(node_uid)
32+
LEFT JOIN nodes_ext AS n USING(node_uid)
3333
LEFT JOIN pools_ext AS p USING(node_type, pool_id)
3434
LEFT JOIN buddy_groups AS gp ON gp.p_target_id = t.target_id
3535
AND gp.node_type = t.node_type
@@ -43,6 +43,19 @@ pub(crate) async fn get_targets(
4343
let is_primary = row.get::<_, Option<TargetId>>(16)?.is_some();
4444
let is_secondary = row.get::<_, Option<TargetId>>(17)?.is_some();
4545

46+
let node = if let Some(node_id) = row.get::<_, Option<NodeId>>(6)? {
47+
Some(pb::EntityIdSet {
48+
uid: row.get(4)?,
49+
legacy_id: Some(pb::LegacyId {
50+
num_id: node_id,
51+
node_type,
52+
}),
53+
alias: row.get(5)?,
54+
})
55+
} else {
56+
None
57+
};
58+
4659
Ok(pm::get_targets_response::Target {
4760
id: Some(pb::EntityIdSet {
4861
uid: row.get(0)?,
@@ -53,14 +66,7 @@ pub(crate) async fn get_targets(
5366
alias: row.get(1)?,
5467
}),
5568
node_type,
56-
node: Some(pb::EntityIdSet {
57-
uid: row.get(4)?,
58-
legacy_id: Some(pb::LegacyId {
59-
num_id: row.get(6)?,
60-
node_type,
61-
}),
62-
alias: row.get(5)?,
63-
}),
69+
node,
6470
storage_pool: if let Some(uid) = row.get::<_, Option<Uid>>(7)? {
6571
Some(pb::EntityIdSet {
6672
uid: Some(uid),

0 commit comments

Comments
 (0)