Skip to content

Commit

Permalink
add cockroach-admin to self-assembling CRDB zone
Browse files Browse the repository at this point in the history
  • Loading branch information
jgallagher committed May 24, 2024
1 parent 66ba1b3 commit ccb8d78
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
1 change: 1 addition & 0 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub const DNS_HTTP_PORT: u16 = 5353;
pub const SLED_AGENT_PORT: u16 = 12345;

pub const COCKROACH_PORT: u16 = 32221;
pub const COCKROACH_ADMIN_PORT: u16 = 32222;
pub const CRUCIBLE_PORT: u16 = 32345;
pub const CLICKHOUSE_PORT: u16 = 8123;
pub const CLICKHOUSE_KEEPER_PORT: u16 = 9181;
Expand Down
2 changes: 1 addition & 1 deletion package-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ source.type = "local"
source.rust.binary_names = ["cockroach-admin"]
source.rust.release = true
source.paths = [
{ from = "smf/cockroach-admin/manifest.xml", to = "/opt/oxide/lib/svc/cockroach-admin/manifest.xml" },
{ from = "smf/cockroach-admin/manifest.xml", to = "/var/svc/manifest/site/cockroach-admin/manifest.xml" },
{ from = "smf/cockroach-admin/config.toml", to = "/opt/oxide/lib/svc/cockroach-admin/config.toml" },
{ from = "smf/cockroach-admin/method_script.sh", to = "/opt/oxide/lib/svc/manifest/cockroach-admin.sh" },
]
Expand Down
38 changes: 31 additions & 7 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use illumos_utils::{execute, PFEXEC};
use internal_dns::resolver::Resolver;
use itertools::Itertools;
use nexus_config::{ConfigDropshotWithTls, DeploymentConfig};
use omicron_common::address::BOOTSTRAP_ARTIFACT_PORT;
use omicron_common::address::{BOOTSTRAP_ARTIFACT_PORT, COCKROACH_ADMIN_PORT};
use omicron_common::address::CLICKHOUSE_KEEPER_PORT;
use omicron_common::address::CLICKHOUSE_PORT;
use omicron_common::address::COCKROACH_PORT;
Expand Down Expand Up @@ -1694,36 +1694,60 @@ impl ServiceManager {
return Err(Error::SledAgentNotReady);
};

let address = SocketAddr::new(
let crdb_address = SocketAddr::new(
IpAddr::V6(*underlay_address),
COCKROACH_PORT,
);
let listen_addr = &address.ip().to_string();
let listen_port = &address.port().to_string();
let admin_address = SocketAddr::new(
IpAddr::V6(*underlay_address),
COCKROACH_ADMIN_PORT,
);
let crdb_listen_addr = &crdb_address.ip().to_string();
let crdb_listen_port = &crdb_address.port().to_string();

let nw_setup_service = Self::zone_network_setup_install(
&info.underlay_address,
&installed_zone,
listen_addr,
crdb_listen_addr,
)?;

let dns_service = Self::dns_install(info, None, &None).await?;

// Configure the CockroachDB service.
let cockroachdb_config = PropertyGroupBuilder::new("config")
.add_property("listen_addr", "astring", listen_addr)
.add_property("listen_port", "astring", listen_port)
.add_property("listen_addr", "astring", crdb_listen_addr)
.add_property("listen_port", "astring", crdb_listen_port)
.add_property("store", "astring", "/data");
let cockroachdb_service =
ServiceBuilder::new("oxide/cockroachdb").add_instance(
ServiceInstanceBuilder::new("default")
.add_property_group(cockroachdb_config),
);

// Configure the Omicron cockroach-admin service.
let cockroach_admin_config =
PropertyGroupBuilder::new("config")
.add_property(
"cockroach_address",
"astring",
&crdb_address.to_string(),
)
.add_property(
"http_address",
"astring",
&admin_address.to_string(),
);
let cockroach_admin_service =
ServiceBuilder::new("oxide/cockroach-admin").add_instance(
ServiceInstanceBuilder::new("default")
.add_property_group(cockroach_admin_config),
);

let profile = ProfileBuilder::new("omicron")
.add_service(nw_setup_service)
.add_service(disabled_ssh_service)
.add_service(cockroachdb_service)
.add_service(cockroach_admin_service)
.add_service(dns_service)
.add_service(enabled_dns_client_service);
profile
Expand Down
1 change: 1 addition & 0 deletions smf/cockroach-admin/method_script.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ COCKROACH_ADDR="$(svcprop -c -p config/cockroach_address "${SMF_FMRI}")"
HTTP_ADDR="$(svcprop -c -p config/http_address "${SMF_FMRI}")"

args=(
'run'
'--config-file-path' "/opt/oxide/lib/svc/cockroach-admin/config.toml"
'--path-to-cockroach-binary' "/opt/oxide/cockroachdb/bin/cockroach"
'--cockroach-address' "$COCKROACH_ADDR"
Expand Down

0 comments on commit ccb8d78

Please sign in to comment.