Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
72 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
c3a49bb
[nexus] Add a new user for background tasks
smklein Jun 20, 2022
5440cbf
[rss] Set DNS records during RSS initialization
smklein Jun 20, 2022
3e1495f
[oximeter] Rely on dynamically set arguments within Oximeter
smklein Jun 20, 2022
5d330bc
fix import
smklein Jun 20, 2022
130ffa0
okay not THAT dynamic just yet
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
fed4a3d
Merge branch 'rack-id' into background-work-user
smklein Jun 21, 2022
6f75649
Merge branch 'background-work-user' into rss-set-dns
smklein Jun 21, 2022
c7ea709
Merge branch 'rss-set-dns' into oximeter-resolves-nexus-address
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
d09c8d5
Merge branch 'rack-id' into background-work-user
smklein Jun 21, 2022
d764d2a
Merge branch 'background-work-user' into rss-set-dns
smklein Jun 21, 2022
ad0ddce
Merge branch 'rss-set-dns' into oximeter-resolves-nexus-address
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
f5ee394
Merge branch 'rack-id' into background-work-user
smklein Jun 21, 2022
588fe8f
Merge branch 'background-work-user' into rss-set-dns
smklein Jun 21, 2022
fed243d
Merge branch 'rss-set-dns' into oximeter-resolves-nexus-address
smklein Jun 21, 2022
d6e3c9d
background-work -> service-balancer
smklein Jun 22, 2022
fd8286a
Merge branch 'main' into dns-client
smklein Jun 22, 2022
bed0269
Merge branch 'dns-client' into rack-id
smklein Jun 22, 2022
ef6072d
Merge branch 'rack-id' into background-work-user
smklein Jun 22, 2022
4c53d4a
Merge branch 'background-work-user' into rss-set-dns
smklein Jun 22, 2022
05da5db
Merge branch 'rss-set-dns' into oximeter-resolves-nexus-address
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
56d2e1c
Merge branch 'rack-id' into background-work-user
smklein Jun 24, 2022
155fd10
Merge branch 'background-work-user' into rss-set-dns
smklein Jun 24, 2022
b5916e0
merge
smklein Jun 24, 2022
3bd9f7a
Merge branch 'rss-set-dns' into oximeter-resolves-nexus-address
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
28d87f5
Merge branch 'rack-id' into background-work-user
smklein Jun 24, 2022
f7c897a
Merge branch 'background-work-user' into rss-set-dns
smklein Jun 24, 2022
bf687b9
Merge branch 'rss-set-dns' into oximeter-resolves-nexus-address
smklein Jun 24, 2022
f1b6e20
Merge branch 'main' into rss-set-dns
smklein Jun 26, 2022
756114d
Merge branch 'rss-set-dns' into oximeter-resolves-nexus-address
smklein Jun 26, 2022
debe96d
Merge branch 'main' into rss-set-dns
smklein Jun 26, 2022
b24dd68
Merge branch 'rss-set-dns' into oximeter-resolves-nexus-address
smklein Jun 26, 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
561 changes: 233 additions & 328 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ steno = { git = "https://github.com/oxidecomputer/steno", branch = "main" }
thiserror = "1.0"
tokio = { version = "1.18", features = [ "full" ] }
tokio-postgres = { version = "0.7", features = [ "with-chrono-0_4", "with-uuid-1" ] }
toml = "0.5.9"
uuid = { version = "1.1.0", features = [ "serde", "v4" ] }
parse-display = "0.5.4"
progenitor = { git = "https://github.com/oxidecomputer/progenitor" }
Expand Down
4 changes: 4 additions & 0 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ pub const SLED_AGENT_PORT: u16 = 12345;

/// The port propolis-server listens on inside the propolis zone.
pub const PROPOLIS_PORT: u16 = 12400;
pub const CLICKHOUSE_PORT: u16 = 8123;
pub const OXIMETER_PORT: u16 = 12223;

pub const NEXUS_INTERNAL_PORT: u16 = 12221;

// Anycast is a mechanism in which a single IP address is shared by multiple
// devices, and the destination is located based on routing distance.
Expand Down
3 changes: 2 additions & 1 deletion common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ pub mod address;
pub mod api;
pub mod backoff;
pub mod cmd;
pub mod config;
pub mod nexus_config;
pub mod postgres_config;

#[macro_export]
macro_rules! generate_logging_api {
Expand Down
130 changes: 130 additions & 0 deletions common/src/nexus_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Configuration parameters to Nexus that are usually only known
//! at deployment time.

use super::address::{Ipv6Subnet, RACK_PREFIX};
use super::postgres_config::PostgresConfigWithUrl;
use dropshot::ConfigDropshot;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use serde_with::DisplayFromStr;
use std::fmt;
use std::path::{Path, PathBuf};
use uuid::Uuid;

#[derive(Debug)]
pub struct LoadError {
pub path: PathBuf,
pub kind: LoadErrorKind,
}

#[derive(Debug)]
pub struct InvalidTunable {
pub tunable: String,
pub message: String,
}

impl std::fmt::Display for InvalidTunable {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "invalid \"{}\": \"{}\"", self.tunable, self.message)
}
}
impl std::error::Error for InvalidTunable {}

#[derive(Debug)]
pub enum LoadErrorKind {
Io(std::io::Error),
Parse(toml::de::Error),
InvalidTunable(InvalidTunable),
}

impl From<(PathBuf, std::io::Error)> for LoadError {
fn from((path, err): (PathBuf, std::io::Error)) -> Self {
LoadError { path, kind: LoadErrorKind::Io(err) }
}
}

impl From<(PathBuf, toml::de::Error)> for LoadError {
fn from((path, err): (PathBuf, toml::de::Error)) -> Self {
LoadError { path, kind: LoadErrorKind::Parse(err) }
}
}

impl std::error::Error for LoadError {}

impl fmt::Display for LoadError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &self.kind {
LoadErrorKind::Io(e) => {
write!(f, "read \"{}\": {}", self.path.display(), e)
}
LoadErrorKind::Parse(e) => {
write!(f, "parse \"{}\": {}", self.path.display(), e)
}
LoadErrorKind::InvalidTunable(inner) => {
write!(
f,
"invalid tunable \"{}\": {}",
self.path.display(),
inner,
)
}
}
}
}

impl std::cmp::PartialEq<std::io::Error> for LoadError {
fn eq(&self, other: &std::io::Error) -> bool {
if let LoadErrorKind::Io(e) = &self.kind {
e.kind() == other.kind()
} else {
false
}
}
}

#[serde_as]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(tag = "type", rename_all = "snake_case")]
#[allow(clippy::large_enum_variant)]
pub enum Database {
FromDns,
FromUrl {
#[serde_as(as = "DisplayFromStr")]
url: PostgresConfigWithUrl,
},
}

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
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
pub dropshot_internal: ConfigDropshot,
/// Portion of the IP space to be managed by the Rack.
pub subnet: Ipv6Subnet<RACK_PREFIX>,
/// DB configuration.
pub database: Database,
}

impl DeploymentConfig {
/// Load a `DeploymentConfig` from the given TOML file
///
/// This config object can then be used to create a new `Nexus`.
/// The format is described in the README.
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, LoadError> {
let path = path.as_ref();
let file_contents = std::fs::read_to_string(path)
.map_err(|e| (path.to_path_buf(), e))?;
let config_parsed: Self = toml::from_str(&file_contents)
.map_err(|e| (path.to_path_buf(), e))?;
Ok(config_parsed)
}
}
File renamed without changes.
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
16 changes: 15 additions & 1 deletion internal-dns-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,22 @@ edition = "2021"
license = "MPL-2.0"

[dependencies]
futures = "0.3.21"
omicron-common = { path = "../common" }
progenitor = { git = "https://github.com/oxidecomputer/progenitor" }
reqwest = { version = "0.11", features = ["json", "rustls-tls", "stream"] }
serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"
slog = { version = "2.5.0", features = [ "max_level_trace", "release_max_level_debug" ] }
reqwest = { version = "0.11", features = ["json", "rustls-tls", "stream"] }
thiserror = "1.0"
trust-dns-proto = "0.21"
trust-dns-resolver = "0.21"
uuid = { version = "1.1.0", features = [ "v4", "serde" ] }

[dev-dependencies]
dropshot = { git = "https://github.com/oxidecomputer/dropshot", branch = "main", features = [ "usdt-probes" ] }
internal-dns = { path = "../internal-dns" }
omicron-test-utils = { path = "../test-utils" }
sled = "0.34"
tempfile = "3.3"
tokio = { version = "1.18", features = [ "full" ] }
3 changes: 3 additions & 0 deletions internal-dns-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ progenitor::generate_api!(
slog::debug!(log, "client response"; "result" => ?result);
}),
);

pub mod multiclient;
pub mod names;
Loading