Skip to content

Commit

Permalink
representative inventory and deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjstone committed Oct 10, 2024
1 parent b4b0c74 commit c557922
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clients/clickhouse-admin-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ progenitor::generate_api!(
TypedUuidForOmicronZoneKind = omicron_uuid_kinds::OmicronZoneUuid,
KeeperConfigurableSettings = clickhouse_admin_api::KeeperConfigurableSettings,
ServerConfigurableSettings = clickhouse_admin_api::ServerConfigurableSettings,
ClickhouseKeeperClusterMembership = clickhouse_admin_types::ClickhouseKeeperClusterMembership
ClickhouseKeeperClusterMembership = clickhouse_admin_types::ClickhouseKeeperClusterMembership,
KeeperId = clickhouse_admin_types::KeeperId
}
);
15 changes: 15 additions & 0 deletions nexus/db-queries/src/db/datastore/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ impl DataStore {
nnics,
nzpools,
nerrors,
nclickhouse_keeper_membership,
) = conn
.transaction_async(|conn| async move {
// Remove the record describing the collection itself.
Expand Down Expand Up @@ -1396,6 +1397,18 @@ impl DataStore {
.await?
};

// Remove rows for clickhouse keeper membership
let nclickhouse_keeper_membership = {
use db::schema::inv_clickhouse_keeper_membership::dsl;
diesel::delete(
dsl::inv_clickhouse_keeper_membership.filter(
dsl::inv_collection_id.eq(db_collection_id),
),
)
.execute_async(&conn)
.await?
};

Ok((
ncollections,
nsps,
Expand All @@ -1411,6 +1424,7 @@ impl DataStore {
nnics,
nzpools,
nerrors,
nclickhouse_keeper_membership,
))
})
.await
Expand All @@ -1437,6 +1451,7 @@ impl DataStore {
"nnics" => nnics,
"nzpools" => nzpools,
"nerrors" => nerrors,
"nclickhouse_keeper_membership" => nclickhouse_keeper_membership
);

Ok(())
Expand Down
10 changes: 10 additions & 0 deletions nexus/inventory/src/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//! Example collections used for testing

use crate::CollectionBuilder;
use clickhouse_admin_types::ClickhouseKeeperClusterMembership;
use clickhouse_admin_types::KeeperId;
use gateway_client::types::PowerState;
use gateway_client::types::RotSlot;
use gateway_client::types::RotState;
Expand Down Expand Up @@ -472,6 +474,14 @@ pub fn representative() -> Representative {
.found_sled_omicron_zones("fake sled 15 agent", sled17_id, sled17)
.unwrap();

builder.found_clickhouse_keeper_cluster_membership(
ClickhouseKeeperClusterMembership {
queried_keeper: KeeperId(1),
leader_committed_log_index: 1000,
raft_config: [KeeperId(1)].into_iter().collect(),
},
);

Representative {
builder,
sleds: [sled1_bb, sled2_bb, sled3_bb, sled4_bb],
Expand Down

0 comments on commit c557922

Please sign in to comment.