Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mgmtd/src/db/schema/4.sql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion(blocking): it is unfortunate a DB migration is required for this change. So we can at least eliminate the upgrade pain for users (most who are unaffected by this particular change), what do you think about automatically applying minor DB schema updates when needed?

We could introduce a new option for this (e.g., --upgrade=auto) so it is opt in. This would be particularly helpful for environments that use tools like Ansible for automated deployments/upgrades to avoid requiring post-upgrade steps for specific minor releases.

Blocking not because we need to introduce any automatic migration in this PR, but because I want to discuss how we want to generally handle database upgrades in minor releases before we merge our first DB schema update.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DROP VIEW targets_ext;

CREATE VIEW targets_ext AS
SELECT e.alias, t.*, n.node_uid
FROM targets AS t
INNER JOIN entities AS e ON e.uid = t.target_uid
LEFT JOIN nodes AS n USING(node_type, node_id)
;
2 changes: 0 additions & 2 deletions mgmtd/src/grpc/delete_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,5 @@ pub(crate) async fn delete_target(

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

log::warn!("{target:?}");

Ok(pm::DeleteTargetResponse { target })
}
24 changes: 15 additions & 9 deletions mgmtd/src/grpc/get_targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) async fn get_targets(
t.free_space, t.free_inodes, t.total_space, t.total_inodes,
gp.p_target_id, gs.s_target_id
FROM targets_ext AS t
INNER JOIN nodes_ext AS n USING(node_uid)
LEFT JOIN nodes_ext AS n USING(node_uid)
LEFT JOIN pools_ext AS p USING(node_type, pool_id)
LEFT JOIN buddy_groups AS gp ON gp.p_target_id = t.target_id
AND gp.node_type = t.node_type
Expand All @@ -43,6 +43,19 @@ pub(crate) async fn get_targets(
let is_primary = row.get::<_, Option<TargetId>>(16)?.is_some();
let is_secondary = row.get::<_, Option<TargetId>>(17)?.is_some();

let node = if let Some(node_id) = row.get::<_, Option<NodeId>>(6)? {
Some(pb::EntityIdSet {
uid: row.get(4)?,
legacy_id: Some(pb::LegacyId {
num_id: node_id,
node_type,
}),
alias: row.get(5)?,
})
} else {
None
};

Ok(pm::get_targets_response::Target {
id: Some(pb::EntityIdSet {
uid: row.get(0)?,
Expand All @@ -53,14 +66,7 @@ pub(crate) async fn get_targets(
alias: row.get(1)?,
}),
node_type,
node: Some(pb::EntityIdSet {
uid: row.get(4)?,
legacy_id: Some(pb::LegacyId {
num_id: row.get(6)?,
node_type,
}),
alias: row.get(5)?,
}),
node,
storage_pool: if let Some(uid) = row.get::<_, Option<Uid>>(7)? {
Some(pb::EntityIdSet {
uid: Some(uid),
Expand Down
Loading