Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b78ff98
[nexus] Split Nexus configuration (package vs runtime)
smklein Jun 8, 2022
cca5795
Merge branch 'main' into nexus-argsplit
smklein Jun 8, 2022
fccc15c
Ensure postgres config was just a rename
smklein Jun 8, 2022
2443215
Merge branch 'main' into nexus-argsplit
smklein Jun 8, 2022
a077bd4
review feedback
smklein Jun 8, 2022
f91cea1
Merge branch 'main' into nexus-argsplit
smklein Jun 8, 2022
d16eda2
DNS client
smklein Jun 8, 2022
8db30b7
Add concurrency
smklein Jun 8, 2022
3a0c6ba
comment
smklein Jun 8, 2022
33b3e02
fmt
smklein Jun 8, 2022
3eb57dc
lockfile
smklein Jun 8, 2022
39aa9ff
Merge branch 'main' into nexus-argsplit
smklein Jun 15, 2022
dd04a67
s/runtime/deployment
smklein Jun 15, 2022
63b6379
Merge branch 'nexus-argsplit' into dns-client
smklein Jun 15, 2022
e1dc941
[nexus][sled-agent] Generate rack ID in RSS, plumb it through Nexus
smklein Jun 15, 2022
a4309ac
need rack_id in the test config too
smklein Jun 15, 2022
02f592d
Merge branch 'main' into nexus-argsplit
smklein Jun 20, 2022
ff2d7b9
[internal-dns] Avoid 'picking ports'
smklein Jun 20, 2022
a261155
Merge branch 'nexus-argsplit' into dns-client
smklein Jun 20, 2022
6cc7864
Merge branch 'fix-internal-dns-api' into dns-client
smklein Jun 20, 2022
2a035a5
Changes from rss-handoff
smklein Jun 20, 2022
e84faaf
Merge branch 'dns-client' into rack-id
smklein Jun 20, 2022
1e0b8fe
Merge branch 'main' into nexus-argsplit
smklein Jun 21, 2022
da4a2b8
Merge branch 'nexus-argsplit' into fix-internal-dns-api
smklein Jun 21, 2022
d7b10cf
Merge branch 'fix-internal-dns-api' into dns-client
smklein Jun 21, 2022
bb9a3af
Merge branch 'dns-client' into rack-id
smklein Jun 21, 2022
4df23c2
jgallagher feedback
smklein Jun 21, 2022
71f3aac
Merge branch 'fix-internal-dns-api' into dns-client
smklein Jun 21, 2022
5556d5f
Patch tests
smklein Jun 21, 2022
226fd94
Merge branch 'fix-internal-dns-api' into dns-client
smklein Jun 21, 2022
6126e41
merge
smklein Jun 21, 2022
b01bffd
Merge branch 'dns-client' into rack-id
smklein Jun 21, 2022
e4f434f
Merge branch 'main' into nexus-argsplit
smklein Jun 21, 2022
62fccb2
Merge branch 'nexus-argsplit' into fix-internal-dns-api
smklein Jun 21, 2022
1905985
Merge branch 'fix-internal-dns-api' into dns-client
smklein Jun 21, 2022
1a0b61b
Merge branch 'dns-client' into rack-id
smklein Jun 21, 2022
fd8286a
Merge branch 'main' into dns-client
smklein Jun 22, 2022
bed0269
Merge branch 'dns-client' into rack-id
smklein Jun 22, 2022
b959c39
Merge branch 'main' into dns-client
smklein Jun 23, 2022
470da8b
review feedback
smklein Jun 24, 2022
a23a036
Merge branch 'dns-client' into rack-id
smklein Jun 24, 2022
13b9825
Merge branch 'main' into dns-client
smklein Jun 24, 2022
e1a912f
Merge branch 'dns-client' into rack-id
smklein Jun 24, 2022
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
2 changes: 2 additions & 0 deletions common/src/nexus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ pub enum Database {
pub struct DeploymentConfig {
/// Uuid of the Nexus instance
pub id: Uuid,
/// Uuid of the Rack where Nexus is executing.
pub rack_id: Uuid,
/// Dropshot configuration for external API server
pub dropshot_external: ConfigDropshot,
/// Dropshot configuration for internal API server
Expand Down
8 changes: 8 additions & 0 deletions common/src/sql/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ CREATE TABLE omicron.public.sled (
time_deleted TIMESTAMPTZ,
rcgen INT NOT NULL,

/* FK into the Rack table */
rack_id UUID NOT NULL,

/* The IP address and bound port of the sled agent server. */
ip INET NOT NULL,
port INT4 CHECK (port BETWEEN 0 AND 65535) NOT NULL,
Expand All @@ -83,6 +86,11 @@ CREATE TABLE omicron.public.sled (
last_used_address INET NOT NULL
);

/* Add an index which lets us look up sleds on a rack */
CREATE INDEX ON omicron.public.sled (
rack_id
) WHERE time_deleted IS NULL;

/*
* Services
*/
Expand Down
1 change: 1 addition & 0 deletions nexus/examples/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ address = "[::1]:8123"
[deployment]
# Identifier for this instance of Nexus
id = "e6bff1ff-24fb-49dc-a54e-c6a350cd4d6c"
rack_id = "c19a698f-c6f9-4a17-ae30-20d711b8f7dc"

[deployment.dropshot_external]
# IP address and TCP port on which to listen for the external API
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl super::Nexus {
address: SocketAddrV6,
) -> Result<(), Error> {
info!(self.log, "registered sled agent"; "sled_uuid" => id.to_string());
let sled = db::model::Sled::new(id, address);
let sled = db::model::Sled::new(id, address, self.rack_id);
self.db_datastore.sled_upsert(sled).await?;
Ok(())
}
Expand Down
7 changes: 7 additions & 0 deletions nexus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ mod test {
max_vpc_ipv4_subnet_prefix = 27
[deployment]
id = "28b90dc4-c22a-65ba-f49a-f051fe01208f"
rack_id = "38b90dc4-c22a-65ba-f49a-f051fe01208f"
[deployment.dropshot_external]
bind_address = "10.1.2.3:4567"
request_body_max_bytes = 1024
Expand All @@ -348,6 +349,9 @@ mod test {
Config {
deployment: DeploymentConfig {
id: "28b90dc4-c22a-65ba-f49a-f051fe01208f".parse().unwrap(),
rack_id: "38b90dc4-c22a-65ba-f49a-f051fe01208f"
.parse()
.unwrap(),
dropshot_external: ConfigDropshot {
bind_address: "10.1.2.3:4567"
.parse::<SocketAddr>()
Expand Down Expand Up @@ -407,6 +411,7 @@ mod test {
address = "[::1]:8123"
[deployment]
id = "28b90dc4-c22a-65ba-f49a-f051fe01208f"
rack_id = "38b90dc4-c22a-65ba-f49a-f051fe01208f"
[deployment.dropshot_external]
bind_address = "10.1.2.3:4567"
request_body_max_bytes = 1024
Expand Down Expand Up @@ -448,6 +453,7 @@ mod test {
address = "[::1]:8123"
[deployment]
id = "28b90dc4-c22a-65ba-f49a-f051fe01208f"
rack_id = "38b90dc4-c22a-65ba-f49a-f051fe01208f"
[deployment.dropshot_external]
bind_address = "10.1.2.3:4567"
request_body_max_bytes = 1024
Expand Down Expand Up @@ -503,6 +509,7 @@ mod test {
max_vpc_ipv4_subnet_prefix = 100
[deployment]
id = "28b90dc4-c22a-65ba-f49a-f051fe01208f"
rack_id = "38b90dc4-c22a-65ba-f49a-f051fe01208f"
[deployment.dropshot_external]
bind_address = "10.1.2.3:4567"
request_body_max_bytes = 1024
Expand Down
8 changes: 5 additions & 3 deletions nexus/src/db/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4034,8 +4034,9 @@ mod test {
0,
0,
);
let rack_id = Uuid::new_v4();
let sled_id = Uuid::new_v4();
let sled = Sled::new(sled_id, bogus_addr.clone());
let sled = Sled::new(sled_id, bogus_addr.clone(), rack_id);
datastore.sled_upsert(sled).await.unwrap();
sled_id
}
Expand Down Expand Up @@ -4391,14 +4392,15 @@ mod test {
let opctx =
OpContext::for_tests(logctx.log.new(o!()), datastore.clone());

let rack_id = Uuid::new_v4();
let addr1 = "[fd00:1de::1]:12345".parse().unwrap();
let sled1_id = "0de4b299-e0b4-46f0-d528-85de81a7095f".parse().unwrap();
let sled1 = db::model::Sled::new(sled1_id, addr1);
let sled1 = db::model::Sled::new(sled1_id, addr1, rack_id);
datastore.sled_upsert(sled1).await.unwrap();

let addr2 = "[fd00:1df::1]:12345".parse().unwrap();
let sled2_id = "66285c18-0c79-43e0-e54f-95271f271314".parse().unwrap();
let sled2 = db::model::Sled::new(sled2_id, addr2);
let sled2 = db::model::Sled::new(sled2_id, addr2, rack_id);
datastore.sled_upsert(sled2).await.unwrap();

let ip = datastore.next_ipv6_address(&opctx, sled1_id).await.unwrap();
Expand Down
5 changes: 4 additions & 1 deletion nexus/src/db/model/sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub struct Sled {
time_deleted: Option<DateTime<Utc>>,
rcgen: Generation,

pub rack_id: Uuid,

// ServiceAddress (Sled Agent).
pub ip: ipv6::Ipv6Addr,
pub port: SqlU16,
Expand All @@ -30,7 +32,7 @@ pub struct Sled {
}

impl Sled {
pub fn new(id: Uuid, addr: SocketAddrV6) -> Self {
pub fn new(id: Uuid, addr: SocketAddrV6, rack_id: Uuid) -> Self {
let last_used_address = {
let mut segments = addr.ip().segments();
segments[7] += omicron_common::address::RSS_RESERVED_ADDRESSES;
Expand All @@ -40,6 +42,7 @@ impl Sled {
identity: SledIdentity::new(id),
time_deleted: None,
rcgen: Generation::new(),
rack_id,
ip: ipv6::Ipv6Addr::from(addr.ip()),
port: addr.port().into(),
last_used_address,
Expand Down
1 change: 1 addition & 0 deletions nexus/src/db/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ table! {
time_deleted -> Nullable<Timestamptz>,
rcgen -> Int8,

rack_id -> Uuid,
ip -> Inet,
port -> Int4,
last_used_address -> Inet,
Expand Down
8 changes: 3 additions & 5 deletions nexus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use external_api::http_entrypoints::external_api;
use internal_api::http_entrypoints::internal_api;
use slog::Logger;
use std::sync::Arc;
use uuid::Uuid;

#[macro_use]
extern crate slog;
Expand Down Expand Up @@ -82,15 +81,15 @@ impl Server {
/// Start a nexus server.
pub async fn start(
config: &Config,
rack_id: Uuid,
log: &Logger,
) -> Result<Server, String> {
let log = log.new(o!("name" => config.deployment.id.to_string()));
info!(log, "setting up nexus server");

let ctxlog = log.new(o!("component" => "ServerContext"));

let apictx = ServerContext::new(rack_id, ctxlog, &config)?;
let apictx =
ServerContext::new(config.deployment.rack_id, ctxlog, &config)?;

let http_server_starter_external = dropshot::HttpServerStarter::new(
&config.deployment.dropshot_external,
Expand Down Expand Up @@ -167,8 +166,7 @@ pub async fn run_server(config: &Config) -> Result<(), String> {
} else {
debug!(log, "registered DTrace probes");
}
let rack_id = Uuid::new_v4();
let server = Server::start(config, rack_id, &log).await?;
let server = Server::start(config, &log).await?;
server.register_as_producer().await;
server.wait_for_finish().await
}
6 changes: 2 additions & 4 deletions nexus/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub async fn test_setup_with_config(
config: &mut omicron_nexus::Config,
) -> ControlPlaneTestContext {
let logctx = LogContext::new(test_name, &config.pkg.log);
let rack_id = Uuid::parse_str(RACK_UUID).unwrap();
let log = &logctx.log;

// Start up CockroachDB.
Expand All @@ -104,9 +103,8 @@ pub async fn test_setup_with_config(
nexus_config::Database::FromUrl { url: database.pg_config().clone() };
config.pkg.timeseries_db.address.set_port(clickhouse.port());

let server = omicron_nexus::Server::start(&config, rack_id, &logctx.log)
.await
.unwrap();
let server =
omicron_nexus::Server::start(&config, &logctx.log).await.unwrap();
server
.apictx
.nexus
Expand Down
1 change: 1 addition & 0 deletions nexus/tests/config.test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ max_vpc_ipv4_subnet_prefix = 29
# Identifier for this instance of Nexus.
# NOTE: The test suite always overrides this.
id = "e6bff1ff-24fb-49dc-a54e-c6a350cd4d6c"
rack_id = "c19a698f-c6f9-4a17-ae30-20d711b8f7dc"

#
# NOTE: for the test suite, the port MUST be 0 (in order to bind to any
Expand Down
1 change: 1 addition & 0 deletions sled-agent/src/bootstrap/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ impl Agent {
&self.sled_config,
self.parent_log.clone(),
sled_address,
request.rack_id,
)
.await
.map_err(|e| {
Expand Down
7 changes: 7 additions & 0 deletions sled-agent/src/bootstrap/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ use super::trust_quorum::ShareDistribution;
use omicron_common::address::{Ipv6Subnet, SLED_PREFIX};
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use uuid::Uuid;

/// Configuration information for launching a Sled Agent.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SledAgentRequest {
/// Uuid of the Sled Agent to be created.
pub id: Uuid,

/// Portion of the IP space to be managed by the Sled Agent.
pub subnet: Ipv6Subnet<SLED_PREFIX>,

/// Uuid of the rack to which this sled agent belongs.
pub rack_id: Uuid,

/// Share of the rack secret for this Sled Agent.
// TODO-cleanup This is currently optional because we don't do trust quorum
// shares for single-node deployments (i.e., most dev/test environments),
Expand Down
3 changes: 3 additions & 0 deletions sled-agent/src/rack_setup/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ impl ServiceInner {
(request, (idx, bootstrap_addr))
});

let rack_id = Uuid::new_v4();
let allocations = requests_and_sleds.map(|(request, sled)| {
let (idx, bootstrap_addr) = sled;
info!(
Expand All @@ -373,7 +374,9 @@ impl ServiceInner {
bootstrap_addr,
SledAllocation {
initialization_request: SledAgentRequest {
id: Uuid::new_v4(),
subnet,
rack_id,
trust_quorum_share: maybe_rack_secret_shares
.as_mut()
.map(|shares_iter| {
Expand Down
14 changes: 10 additions & 4 deletions sled-agent/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl Server {
config: &Config,
log: Logger,
addr: SocketAddrV6,
rack_id: Uuid,
) -> Result<Server, String> {
info!(log, "setting up sled agent server");

Expand All @@ -47,10 +48,15 @@ impl Server {
client_log,
));

let sled_agent =
SledAgent::new(&config, log.clone(), nexus_client.clone(), addr)
.await
.map_err(|e| e.to_string())?;
let sled_agent = SledAgent::new(
&config,
log.clone(),
nexus_client.clone(),
addr,
rack_id,
)
.await
.map_err(|e| e.to_string())?;

let mut dropshot_config = dropshot::ConfigDropshot::default();
dropshot_config.request_body_max_bytes = 1024 * 1024;
Expand Down
11 changes: 11 additions & 0 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use tokio::io::AsyncWriteExt;
use tokio::sync::Mutex;
use uuid::Uuid;

// The filename of ServiceManager's internal storage.
const SERVICE_CONFIG_FILENAME: &str = "service.toml";
Expand Down Expand Up @@ -124,6 +125,7 @@ pub struct ServiceManager {
vnic_allocator: VnicAllocator,
underlay_vnic: EtherstubVnic,
underlay_address: Ipv6Addr,
rack_id: Uuid,
}

impl ServiceManager {
Expand All @@ -143,6 +145,7 @@ impl ServiceManager {
underlay_vnic: EtherstubVnic,
underlay_address: Ipv6Addr,
config: Config,
rack_id: Uuid,
) -> Result<Self, Error> {
debug!(log, "Creating new ServiceManager");
let mgr = Self {
Expand All @@ -152,6 +155,7 @@ impl ServiceManager {
vnic_allocator: VnicAllocator::new("Service", etherstub),
underlay_vnic,
underlay_address,
rack_id,
};

let config_path = mgr.services_config_path();
Expand Down Expand Up @@ -316,6 +320,7 @@ impl ServiceManager {
// cannot be known at packaging time.
let deployment_config = NexusDeploymentConfig {
id: service.id,
rack_id: self.rack_id,
dropshot_external: ConfigDropshot {
bind_address: SocketAddr::V6(external_address),
request_body_max_bytes: 1048576,
Expand Down Expand Up @@ -702,6 +707,7 @@ mod test {
EtherstubVnic(ETHERSTUB_VNIC_NAME.to_string()),
Ipv6Addr::LOCALHOST,
test_config.make_config(),
Uuid::new_v4(),
)
.await
.unwrap();
Expand All @@ -728,6 +734,7 @@ mod test {
EtherstubVnic(ETHERSTUB_VNIC_NAME.to_string()),
Ipv6Addr::LOCALHOST,
test_config.make_config(),
Uuid::new_v4(),
)
.await
.unwrap();
Expand Down Expand Up @@ -756,6 +763,7 @@ mod test {
EtherstubVnic(ETHERSTUB_VNIC_NAME.to_string()),
Ipv6Addr::LOCALHOST,
test_config.make_config(),
Uuid::new_v4(),
)
.await
.unwrap();
Expand All @@ -773,6 +781,7 @@ mod test {
EtherstubVnic(ETHERSTUB_VNIC_NAME.to_string()),
Ipv6Addr::LOCALHOST,
test_config.make_config(),
Uuid::new_v4(),
)
.await
.unwrap();
Expand All @@ -797,6 +806,7 @@ mod test {
EtherstubVnic(ETHERSTUB_VNIC_NAME.to_string()),
Ipv6Addr::LOCALHOST,
test_config.make_config(),
Uuid::new_v4(),
)
.await
.unwrap();
Expand All @@ -816,6 +826,7 @@ mod test {
EtherstubVnic(ETHERSTUB_VNIC_NAME.to_string()),
Ipv6Addr::LOCALHOST,
config,
Uuid::new_v4(),
)
.await
.unwrap();
Expand Down
2 changes: 2 additions & 0 deletions sled-agent/src/sled_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl SledAgent {
log: Logger,
nexus_client: Arc<NexusClient>,
sled_address: SocketAddrV6,
rack_id: Uuid,
) -> Result<SledAgent, Error> {
let id = &config.id;

Expand Down Expand Up @@ -266,6 +267,7 @@ impl SledAgent {
etherstub_vnic.clone(),
*sled_address.ip(),
services::Config::default(),
rack_id,
)
.await?;

Expand Down