Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
33 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
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
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
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
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
fd8286a
Merge branch 'main' into dns-client
smklein Jun 22, 2022
b959c39
Merge branch 'main' into dns-client
smklein Jun 23, 2022
470da8b
review feedback
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
559 changes: 231 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
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
128 changes: 128 additions & 0 deletions common/src/nexus_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// 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,
/// 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.
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