Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
79fb8f3
Add internal-dns service
smklein Mar 22, 2022
1a15d6c
fmt
smklein Mar 22, 2022
4faef91
wip
smklein Mar 23, 2022
5351d85
Merge branch 'main' into service-discovery
smklein Mar 24, 2022
8f373bd
Added dnsadm
smklein Mar 24, 2022
62c5778
Merge branch 'service-discovery' into service-discovery-in-a-zone
smklein Mar 24, 2022
a575e42
Add internal-dns SMF config, start it by RSS
smklein Mar 24, 2022
39758c0
Merge branch 'main' into service-discovery
smklein Mar 24, 2022
f814759
Merge branch 'service-discovery' into service-discovery-in-a-zone
smklein Mar 24, 2022
4ca5c80
Merge branch 'main' into service-discovery
smklein Mar 25, 2022
789e274
Merge branch 'service-discovery' into service-discovery-in-a-zone
smklein Mar 25, 2022
a52e4b6
review feedback
smklein Mar 25, 2022
73c0008
Merge branch 'main' into service-discovery-in-a-zone
smklein Apr 20, 2022
a9840d6
Patch addresses
smklein Apr 20, 2022
437d699
Updated cfg path
smklein Apr 20, 2022
4dc45ff
patch addresses
smklein Apr 20, 2022
528204d
Add support for 'make GZ address', add DNS addrs
smklein Apr 21, 2022
bea8c7e
Add some tests
smklein Apr 22, 2022
fcbc0ab
Correctly passing addresses, GZ addresses to DNS service for setup
smklein Apr 24, 2022
f214fcf
Avoid specifying port when not necessary
smklein Apr 24, 2022
baea4a8
safer vec access, better errors
smklein Apr 24, 2022
58744c4
fmt
smklein Apr 24, 2022
77b8840
Merge branch 'main' into service-discovery-in-a-zone
smklein Apr 24, 2022
c1e2180
updated storage path
smklein Apr 24, 2022
e8f98ad
Merge branch 'service-discovery-in-a-zone' into use-service-discovery
smklein Apr 24, 2022
39431c6
fix tests, clippy
smklein Apr 24, 2022
22dfb79
Fix another test
smklein Apr 24, 2022
9f7f55b
Bunyan formatted
smklein Apr 24, 2022
802f4e5
Merge branch 'service-discovery-in-a-zone' into internal-dns-assigned…
smklein Apr 24, 2022
981f744
Regenerate bindings
smklein Apr 24, 2022
57a6697
Start on service errors
smklein Apr 24, 2022
5031561
Push the 'find_physical' call upwards. Simplifies error handling
smklein Apr 24, 2022
37afdd6
Avoid using Result for now infallible funcs, fix tests
smklein Apr 24, 2022
1d0a5ce
More specific, contextual zone errors
smklein Apr 24, 2022
1ab32aa
dladm errors
smklein Apr 24, 2022
6d165a7
Zpool errors
smklein Apr 24, 2022
4be8ed0
zfs errors
smklein Apr 24, 2022
7dd7fd9
execution errs
smklein Apr 24, 2022
a094f8e
Running zone
smklein Apr 24, 2022
bc1c40a
fmt
smklein Apr 24, 2022
7ade540
Bootstrap params, rack setup service errors
smklein Apr 24, 2022
f09348f
Bootstrap agent, trust quorum errors
smklein Apr 25, 2022
fb40516
fmt
smklein Apr 25, 2022
25237b4
storage manager
smklein Apr 25, 2022
a9af5d1
last few
smklein Apr 25, 2022
29a1a37
Merge branch 'main' into service-discovery-in-a-zone
smklein Apr 25, 2022
432e368
Merge branch 'service-discovery-in-a-zone' into internal-dns-assigned…
smklein Apr 25, 2022
1fe140e
Merge branch 'internal-dns-assigned-ips' into better-errors
smklein Apr 25, 2022
31e3c1b
review feedback
smklein Apr 25, 2022
638d99c
Merge branch 'main' into internal-dns-assigned-ips
smklein Apr 28, 2022
857fe85
Const generic subnet prefix
smklein Apr 28, 2022
be3bc1b
Ipv6, comments
smklein Apr 28, 2022
70fbc9f
Merge branch 'main' into internal-dns-assigned-ips
smklein May 2, 2022
3f1e98c
Merge branch 'internal-dns-assigned-ips' into better-errors
smklein May 2, 2022
44139b9
fmt
smklein May 2, 2022
a26d30f
Merge branch 'main' into internal-dns-assigned-ips
smklein May 2, 2022
01e0eb8
Merge branch 'internal-dns-assigned-ips' into better-errors
smklein May 2, 2022
0de925c
Placeholder DNS setting / retreival
smklein May 3, 2022
cf65591
Share logfile for sled agent and bootstrap agent
smklein May 3, 2022
15f3efc
wip
smklein May 3, 2022
3a4896e
Merge branch 'main' into internal-dns-assigned-ips
smklein May 4, 2022
ab15634
Merge branch 'internal-dns-assigned-ips' into better-errors
smklein May 4, 2022
d1f7de2
Merge branch 'better-errors' into use-dns
smklein May 4, 2022
d0bb994
Multi-record KV pairs, utility functions, names
smklein May 4, 2022
ce3e487
RSS address allocation
smklein May 5, 2022
0090ec2
Add nexus model, disable RSS services
smklein May 5, 2022
2eb055a
Merge branch 'main' into better-errors
smklein May 5, 2022
83f4019
fmt
smklein May 5, 2022
a612848
fix illumos-only test
smklein May 5, 2022
7dcb885
Merge branch 'better-errors' into use-dns
smklein May 5, 2022
ea674f1
Use SqlU16 as port
smklein May 5, 2022
15ea043
index
smklein May 5, 2022
d2ce927
Merge branch 'main' into use-dns
smklein May 5, 2022
bef09ea
Merge branch 'main' into use-dns
smklein May 5, 2022
7157814
Merge branch 'main' into use-dns
smklein May 6, 2022
3175471
fix sql format
smklein May 6, 2022
d795406
more on upserting services
smklein May 6, 2022
61e0dfa
Merge branch 'main' into use-dns
smklein May 6, 2022
dae7b93
Merge branch 'main' into use-dns
smklein May 6, 2022
e5af9de
Merge branch 'main' into use-dns
smklein May 9, 2022
17ff5b8
Add endpoint for 'service_put'
smklein May 9, 2022
cef66af
Working on refactoring rt config
smklein May 9, 2022
186aa03
Separate rt/pkg config, start to use DNS in nexus
smklein May 11, 2022
0e74c96
Trying to fix tests, use just one config file, update bindings
smklein May 11, 2022
4c7c552
openapi re-gen, fixing servicemanager tests / config
smklein May 11, 2022
02b7533
clippy / fmt
smklein May 11, 2022
9970c10
Fix benchmark
smklein May 11, 2022
90083c0
Merge branch 'main' into use-dns
smklein May 11, 2022
5ef48d5
remove rt parts of config
smklein May 11, 2022
63b1cd6
make nexus happier w/config, fix resolver, nexus depends on routing
smklein May 12, 2022
ec88eb1
Merge branch 'main' into use-dns
smklein May 12, 2022
7d6d466
Merge branch 'main' into use-dns
smklein Jun 1, 2022
2da101d
Merge branch 'main' into use-dns
smklein Jun 8, 2022
973a1e8
Fix merge conflict
smklein Jun 8, 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
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ structopt = "0.3"
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
17 changes: 15 additions & 2 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,23 @@ pub const DNS_REDUNDANCY: usize = 1;
/// reserved for DNS servers.
pub const MAX_DNS_REDUNDANCY: usize = 5;

/// The port for the UDP-based internal DNS name server.
pub const DNS_PORT: u16 = 53;
/// The port for the HTTP-based internal DNS dropshot server.
pub const DNS_SERVER_PORT: u16 = 5353;
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 COCKROACH_PORT: u16 = 32221;
pub const CRUCIBLE_PORT: u16 = 32345;

pub const NEXUS_EXTERNAL_PORT: u16 = 12220;
pub const NEXUS_INTERNAL_PORT: u16 = 12221;

pub const COCKROACH_DNS_NAME: &str =
"_cockroachdb._tcp.control-plane.oxide.internal";


// 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 Expand Up @@ -124,14 +135,16 @@ impl ReservedRackSubnet {
}
}

const SLED_AGENT_ADDRESS_INDEX: usize = 1;
pub const SLED_AGENT_ADDRESS_INDEX: u16 = 1;
/// The maximum number of addresses per sled subnet reserved for RSS.
pub const RSS_RESERVED_ADDRESSES: u16 = 10;

/// Return the sled agent address for a subnet.
///
/// This address will come from the first address of the [`SLED_PREFIX`] subnet.
pub fn get_sled_address(sled_subnet: Ipv6Subnet<SLED_PREFIX>) -> SocketAddrV6 {
let sled_agent_ip =
sled_subnet.net().iter().nth(SLED_AGENT_ADDRESS_INDEX).unwrap();
sled_subnet.net().iter().nth(SLED_AGENT_ADDRESS_INDEX.into()).unwrap();
SocketAddrV6::new(sled_agent_ip, SLED_AGENT_PORT, 0, 0)
}

Expand Down
1 change: 1 addition & 0 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ pub enum ResourceType {
Instance,
NetworkInterface,
Rack,
Service,
Sled,
SagaDbg,
Snapshot,
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 runtime.

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 RuntimeConfig {
/// 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 RuntimeConfig {
/// Load a `RuntimeConfig` 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.
28 changes: 28 additions & 0 deletions common/src/sql/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,34 @@ CREATE TABLE omicron.public.sled (
last_used_address INET NOT NULL
);

/*
* Services
*/

CREATE TABLE omicron.public.service (
/* Identity metadata (asset) */
id UUID PRIMARY KEY,
time_created TIMESTAMPTZ NOT NULL,
time_modified TIMESTAMPTZ NOT NULL,

/* FK into the Sled table */
sled_id UUID NOT NULL,

/* The IP address and bound port of the service. */
ip INET NOT NULL,
port INT4 CHECK (port BETWEEN 0 AND 65535) NOT NULL
);

/* Add an index which lets us look up the services on a sled */
CREATE INDEX ON omicron.public.service (
sled_id
);

CREATE TYPE omicron.public.service_kind AS ENUM (
'nexus',
'oximeter'
);

/*
* ZPools of Storage, attached to Sleds.
* Typically these are backed by a single physical disk.
Expand Down
6 changes: 5 additions & 1 deletion internal-dns-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ edition = "2021"
license = "MPL-2.0"

[dependencies]
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" ] }
structopt = "0.3"
reqwest = { version = "0.11", features = ["json", "rustls-tls", "stream"] }
trust-dns-proto = "0.21"
trust-dns-resolver = "0.21"
uuid = { version = "1.1.0", features = [ "v4", "serde" ] }
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