Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: [Reconfigurator] Add new Clickhouse discretionary zones #6392

Closed
wants to merge 14 commits into from
6 changes: 5 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"certificates",
"clickhouse-admin",
"clickhouse-admin/api",
"clickhouse-admin/types",
"clients/bootstrap-agent-client",
"clients/cockroach-admin-client",
"clients/ddm-admin-client",
Expand Down Expand Up @@ -315,7 +316,7 @@ ciborium = "0.2.2"
clap = { version = "4.5", features = ["cargo", "derive", "env", "wrap_help"] }
clickhouse-admin-api = { path = "clickhouse-admin/api" }
clickhouse-admin-types = { path = "clickhouse-admin/types" }
clickward = { git = "https://github.com/oxidecomputer/clickward", rev = "ceec762e6a87d2a22bf56792a3025e145caa095e" }
clickward = { git = "https://github.com/oxidecomputer/clickward", rev = "4ee0f74db55f440d589232256458c0750f6a641e" }
cockroach-admin-api = { path = "cockroach-admin/api" }
cockroach-admin-client = { path = "clients/cockroach-admin-client" }
cockroach-admin-types = { path = "cockroach-admin/types" }
Expand Down
1 change: 1 addition & 0 deletions nexus/db-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ omicron-rpaths.workspace = true
anyhow.workspace = true
camino.workspace = true
chrono.workspace = true
clickhouse-admin-types.workspace = true
derive-where.workspace = true
diesel = { workspace = true, features = ["postgres", "r2d2", "chrono", "serde_json", "network-address", "uuid"] }
hex.workspace = true
Expand Down
61 changes: 59 additions & 2 deletions nexus/db-model/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ pub struct Blueprint {
pub external_dns_version: Generation,
pub cockroachdb_fingerprint: String,
pub cockroachdb_setting_preserve_downgrade: Option<String>,
pub clickhouse_max_used_server_id: i64,
pub clickhouse_max_used_keeper_id: i64,
pub clickhouse_cluster_secret: String,
pub time_created: DateTime<Utc>,
pub creator: String,
pub comment: String,
Expand All @@ -70,13 +73,30 @@ impl From<&'_ nexus_types::deployment::Blueprint> for Blueprint {
cockroachdb_setting_preserve_downgrade: bp
.cockroachdb_setting_preserve_downgrade
.to_optional_string(),
clickhouse_max_used_server_id: bp
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove this, it's alll in a separate table now

.clickhouse_cluster_config
.max_used_server_id
.0
.try_into()
.expect("clickhouse IDs must fit in an i64"),
clickhouse_max_used_keeper_id: bp
.clickhouse_cluster_config
.max_used_keeper_id
.0
.try_into()
.expect("clickhouse IDs must fit in an i64"),
clickhouse_cluster_secret: bp
.clickhouse_cluster_config
.secret
.clone(),
time_created: bp.time_created,
creator: bp.creator.clone(),
comment: bp.comment.clone(),
}
}
}

// TODO: Fill in clickhouse details?
impl From<Blueprint> for nexus_types::deployment::BlueprintMetadata {
fn from(value: Blueprint) -> Self {
Self {
Expand Down Expand Up @@ -259,6 +279,9 @@ pub struct BpOmicronZone {

pub external_ip_id: Option<DbTypedUuid<ExternalIpKind>>,
pub filesystem_pool: Option<DbTypedUuid<ZpoolKind>>,

clickhouse_keeper_id: Option<i64>,
clickhouse_server_id: Option<i64>,
}

impl BpOmicronZone {
Expand Down Expand Up @@ -308,6 +331,8 @@ impl BpOmicronZone {
snat_ip: None,
snat_first_port: None,
snat_last_port: None,
clickhouse_keeper_id: None,
clickhouse_server_id: None,
};

match &blueprint_zone.zone_type {
Expand Down Expand Up @@ -350,18 +375,40 @@ impl BpOmicronZone {
bp_omicron_zone.set_zpool_name(dataset);
}
BlueprintZoneType::ClickhouseKeeper(
blueprint_zone_type::ClickhouseKeeper { address, dataset },
blueprint_zone_type::ClickhouseKeeper {
keeper_id,
address,
dataset,
},
) => {
// Set the common fields
bp_omicron_zone.set_primary_service_ip_and_port(address);
bp_omicron_zone.set_zpool_name(dataset);

// Set the zone specific fields
bp_omicron_zone.clickhouse_keeper_id = Some(
keeper_id
.0
.try_into()
.expect("no more than 2^63 keeper IDs please"),
);
}
BlueprintZoneType::ClickhouseServer(
blueprint_zone_type::ClickhouseServer { address, dataset },
blueprint_zone_type::ClickhouseServer {
server_id,
address,
dataset,
},
) => {
// Set the common fields
bp_omicron_zone.set_primary_service_ip_and_port(address);
bp_omicron_zone.set_zpool_name(dataset);

// Set the zone specific fields
bp_omicron_zone.clickhouse_server_id =
Some(server_id.0.try_into().expect(
"no more than 2^63 clickhouse server IDs please",
));
}
BlueprintZoneType::CockroachDb(
blueprint_zone_type::CockroachDb { address, dataset },
Expand Down Expand Up @@ -588,12 +635,22 @@ impl BpOmicronZone {
}
ZoneType::ClickhouseKeeper => BlueprintZoneType::ClickhouseKeeper(
blueprint_zone_type::ClickhouseKeeper {
keeper_id: clickhouse_admin_types::KeeperId(
self.clickhouse_keeper_id.ok_or_else(|| {
anyhow!("missing clickhouse_keeper_id")
})? as u64,
),
address: primary_address,
dataset: dataset?,
},
),
ZoneType::ClickhouseServer => BlueprintZoneType::ClickhouseServer(
blueprint_zone_type::ClickhouseServer {
server_id: clickhouse_admin_types::ServerId(
self.clickhouse_server_id.ok_or_else(|| {
anyhow!("missing clickhouse_keeper_id")
})? as u64,
),
address: primary_address,
dataset: dataset?,
},
Expand Down
17 changes: 17 additions & 0 deletions nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,19 @@ table! {
cockroachdb_fingerprint -> Text,

cockroachdb_setting_preserve_downgrade -> Nullable<Text>,

}
}

table! {
bp_clickhouse_cluster_config (blueprint_id) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We really only want one of these for most blueprints, unless we are adding or removing clickhouse related zones. We should probably make the primary key generation, as the blueprint_id indicates what blueprint it was generated in. We'll want to just lookup the latest one at all times.

blueprint_id -> Uuid,

generation-> Int8,
max_used_server_id -> Int8,
max_used_keeper_id -> Int8,
cluster_name -> Text,
cluster_secret -> Text,
}
}

Expand Down Expand Up @@ -1595,6 +1608,10 @@ table! {
disposition -> crate::DbBpZoneDispositionEnum,
external_ip_id -> Nullable<Uuid>,
filesystem_pool -> Nullable<Uuid>,

clickhouse_keeper_id -> Nullable<Int8>,
clickhouse_server_id -> Nullable<Int8>

}
}

Expand Down
7 changes: 7 additions & 0 deletions nexus/db-queries/src/db/datastore/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use nexus_db_model::BpSledOmicronZones;
use nexus_db_model::BpSledState;
use nexus_db_model::BpTarget;
use nexus_types::deployment::Blueprint;
use nexus_types::deployment::ClickhouseClusterConfig;
use nexus_types::deployment::BlueprintMetadata;
use nexus_types::deployment::BlueprintPhysicalDisksConfig;
use nexus_types::deployment::BlueprintTarget;
Expand Down Expand Up @@ -290,6 +291,11 @@ impl DataStore {
external_dns_version,
cockroachdb_fingerprint,
cockroachdb_setting_preserve_downgrade,
clickhouse_cluster_generation,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove this, it's in a separate table

clickhouse_max_used_server_id,
clickhouse_max_used_keeeper_id,
clickhouse_cluster_name,
clickhouse_cluster_secret,
time_created,
creator,
comment,
Expand Down Expand Up @@ -632,6 +638,7 @@ impl DataStore {
external_dns_version,
cockroachdb_fingerprint,
cockroachdb_setting_preserve_downgrade,
clickhouse_cluster_config: ClickhouseClusterConfig::new(
time_created,
creator,
comment,
Expand Down
2 changes: 2 additions & 0 deletions nexus/db-queries/src/db/datastore/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,8 @@ impl DataStore {
rot_pages_found,
sled_agents,
omicron_zones,
// TODO: fill this in once we collect it
clickhouse_keeper_cluster_membership: BTreeMap::new(),
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions nexus/inventory/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ impl CollectionBuilder {
rot_pages_found: self.rot_pages_found,
sled_agents: self.sleds,
omicron_zones: self.omicron_zones,
// TODO: Fill when we actually gather keeper inventory
clickhouse_keeper_cluster_membership: BTreeMap::new(),
}
}

Expand Down
Loading
Loading