Skip to content

Service management and rss handoff #1541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 202 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
202 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
7f1087d
Pull in RSS changes from 'use-dns' branch
smklein Jun 9, 2022
eca5484
RSS performs config by itself, mostly
smklein Jun 9, 2022
565862e
RSS side of handoff to Nexus mostly complete
smklein Jun 9, 2022
dfa614b
Handoff to Nexus is hacky, but working
smklein Jun 10, 2022
dc3b84b
Add bg work user, rack insert populate, patch tests
smklein Jun 12, 2022
e265f0d
Await RSS handoff, even in tests
smklein Jun 12, 2022
b5ca139
Partway through service allocation - still very WIP
smklein Jun 13, 2022
7e986b8
v1 of nexus-managed services is code complete; no tests yet
smklein Jun 14, 2022
95a5873
Add indices, add tests, fix bugs
smklein Jun 15, 2022
2a28eb9
It's hacky, but it's working. I'm seeing services be re-balanced corr…
smklein Jun 15, 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
248d4cb
Merge branch 'dns-client' into rss-handoff
smklein Jun 15, 2022
b07322c
clippy, fmt
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
7f41e42
Strongly-typed DNS service names
smklein Jun 15, 2022
a68de33
Populate DNS records
smklein Jun 16, 2022
746114b
Fix dns client bug, start shortening timeouts
smklein Jun 16, 2022
1b019b1
clippy
smklein Jun 16, 2022
94b4b46
Concurrent provisioning
smklein Jun 16, 2022
a02e009
Dynamic oximeter config
smklein Jun 16, 2022
a5be4d0
Allow oximeter to use config-provided addresses
smklein Jun 17, 2022
59dc382
Fix command-based tests
smklein Jun 17, 2022
81bf2d4
Nexus lazily accessing timeseries DB
smklein Jun 20, 2022
aed3ba6
Cleanup TODOs
smklein Jun 20, 2022
8fce9a1
Box resolver to make clippy happy
smklein Jun 20, 2022
d26ee14
Internal DNS tests
smklein Jun 20, 2022
4b5dab7
Clean up test code
smklein Jun 20, 2022
db2b545
no retry in client library
smklein Jun 20, 2022
027fb3b
Fix internal-dns
smklein Jun 20, 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
bccb416
Merge branch 'dns-client' into rss-handoff
smklein Jun 20, 2022
bce58f4
Merge branch 'rack-id' into rss-handoff
smklein Jun 20, 2022
c3a49bb
[nexus] Add a new user for background tasks
smklein Jun 20, 2022
089623e
Merge branch 'background-work-user' into rss-handoff
smklein Jun 20, 2022
e33fb4b
fix typos, warnings
smklein Jun 20, 2022
5440cbf
[rss] Set DNS records during RSS initialization
smklein Jun 20, 2022
9a9ca35
Merge branch 'rss-set-dns' into rss-handoff
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
36135b2
Merge branch 'oximeter-resolves-nexus-address' into rss-handoff
smklein Jun 20, 2022
7ceb8fa
[nexus] Populate rack during initialization
smklein Jun 21, 2022
a82b653
Merge branch 'rack-populate' into rss-handoff
smklein Jun 21, 2022
9fc4994
Cleanup imports
smklein Jun 21, 2022
11ebb7b
[nexus] Add tests for rack endpoints
smklein Jun 21, 2022
5188880
[nexus] Add tests for rack endpoints
smklein Jun 21, 2022
19356a8
Merge branch 'rack-populate' into rss-handoff
smklein Jun 21, 2022
7cbac9f
[nexus] Optionally resolve clickhouse, cockroach from DNS names
smklein Jun 21, 2022
e6dc594
Merge branch 'nexus-resolves-clickhouse' into rss-handoff
smklein Jun 21, 2022
1822762
[nexus] Add tunable to disable background tasks
smklein Jun 21, 2022
01c7465
[nexus] Add service manager to Nexus
smklein Jun 21, 2022
55feaf6
Merge branch 'nexus-service-management' into rss-handoff
smklein Jun 21, 2022
d2536d7
Delete out-dated docs
smklein Jun 21, 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
5c00d54
Merge branch 'oximeter-resolves-nexus-address' into rack-populate
smklein Jun 21, 2022
77d626f
Merge branch 'rack-populate' into nexus-resolves-clickhouse
smklein Jun 21, 2022
9dd6b27
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jun 21, 2022
7fb947b
Merge branch 'nexus-service-management' into rss-handoff
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
d4cbe41
Merge branch 'oximeter-resolves-nexus-address' into rack-populate
smklein Jun 21, 2022
41d5503
Merge branch 'rack-populate' into nexus-resolves-clickhouse
smklein Jun 21, 2022
6427eeb
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jun 21, 2022
6c5e035
Merge branch 'nexus-service-management' into rss-handoff
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
a6b5240
Merge branch 'oximeter-resolves-nexus-address' into rack-populate
smklein Jun 21, 2022
d53c426
Merge branch 'rack-populate' into nexus-resolves-clickhouse
smklein Jun 21, 2022
30ec2f9
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jun 21, 2022
768221d
Merge branch 'nexus-service-management' into rss-handoff
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
83eb272
Merge branch 'oximeter-resolves-nexus-address' into rack-populate
smklein Jun 22, 2022
84ed8ad
Merge branch 'rack-populate' into nexus-resolves-clickhouse
smklein Jun 22, 2022
8940d4e
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jun 22, 2022
b6434e3
Merge branch 'nexus-service-management' into rss-handoff
smklein Jun 22, 2022
8150d60
background opctx -> service balancer opctx
smklein Jun 22, 2022
c5bd827
Merge branch 'nexus-service-management' into rss-handoff
smklein Jun 22, 2022
0ff033a
renamed opctx
smklein Jun 22, 2022
4d7a46c
in tests too
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
b8a3ffc
Merge branch 'oximeter-resolves-nexus-address' into rack-populate
smklein Jun 24, 2022
ba72abd
Merge branch 'rack-populate' into nexus-resolves-clickhouse
smklein Jun 24, 2022
542a9fd
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jun 24, 2022
b5f1e92
merge
smklein Jun 24, 2022
5fc64aa
merge
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
40a2433
Merge branch 'oximeter-resolves-nexus-address' into rack-populate
smklein Jun 24, 2022
5516746
Merge branch 'rack-populate' into nexus-resolves-clickhouse
smklein Jun 24, 2022
0837415
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jun 24, 2022
286699c
Merge branch 'nexus-service-management' into rss-handoff
smklein Jun 24, 2022
364efb3
rack ID to test interfaces
smklein Jun 24, 2022
40d6126
Merge branch 'rack-populate' into nexus-resolves-clickhouse
smklein Jun 24, 2022
3c8dc52
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jun 24, 2022
eed9437
Merge branch 'nexus-service-management' into rss-handoff
smklein Jun 24, 2022
19deb80
comments
smklein Jun 24, 2022
900cd38
Merge branch 'nexus-service-management' into rss-handoff
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
ba5275f
Merge branch 'oximeter-resolves-nexus-address' into rack-populate
smklein Jun 26, 2022
6a789fc
Merge branch 'rack-populate' into nexus-resolves-clickhouse
smklein Jun 26, 2022
394c803
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jun 26, 2022
f540d3a
Merge branch 'nexus-service-management' into rss-handoff
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
c526eba
WIP - test skeleton
smklein Jun 27, 2022
a7bd0d5
Merge branch 'main' into rss-set-dns
smklein Jun 27, 2022
ea84b79
Merge branch 'rss-set-dns' into oximeter-resolves-nexus-address
smklein Jun 27, 2022
91656e8
Merge branch 'oximeter-resolves-nexus-address' into rack-populate
smklein Jun 27, 2022
a2bf4d3
Merge branch 'rack-populate' into nexus-resolves-clickhouse
smklein Jun 27, 2022
8369b8b
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jun 27, 2022
f258488
More work towards tests
smklein Jun 28, 2022
c6a50b4
Merge branch 'main' into nexus-resolves-clickhouse
smklein Jul 5, 2022
7882416
Merge branch 'main' into nexus-resolves-clickhouse
smklein Jul 5, 2022
fdb8ee4
Merge branch 'nexus-resolves-clickhouse' into nexus-service-management
smklein Jul 5, 2022
c56a6fd
Fmt, expand on tests
smklein Jul 5, 2022
8cf9ad4
Merge branch 'nexus-service-management' into rss-handoff
smklein Jul 6, 2022
f11200e
Merge branch 'main' into nexus-service-management
smklein Jul 11, 2022
1a7bb40
partial merge
smklein Jul 11, 2022
7e4a1ed
Merge with dendrite
smklein Jul 11, 2022
ba1a731
Merge branch 'nexus-service-management' into rss-handoff
smklein Jul 11, 2022
6047b93
remove unused
smklein Jul 11, 2022
eba4486
Finish merge
smklein Jul 11, 2022
dbfc993
Merge branch 'main' into nexus-service-management
smklein Jul 27, 2022
9b07d55
Merge branch 'nexus-service-management' into rss-handoff
smklein Jul 27, 2022
65ac8e5
Fix multi-rack test
smklein Jul 28, 2022
c33119b
Reduce hacks, docs cleanup
smklein Jul 28, 2022
0becaa5
Add expectation for Dendrite - will rely on isScrimletOrNot functiona…
smklein Jul 28, 2022
bed3151
Expand tests, impl 'alloc-per-scrimlet'
smklein Jul 29, 2022
a27011a
Merge branch 'main' into nexus-service-management
smklein Aug 1, 2022
09e6345
Merge branch 'nexus-service-management' into rss-handoff
smklein Aug 1, 2022
029603d
Start plumbing auxiliary nexus info through RSS handoff
smklein Aug 1, 2022
83999a3
Merge branch 'main' into service-management-and-rss-handoff
smklein Aug 4, 2022
3c899d4
Merge branch 'main' into service-management-and-rss-handoff
smklein Aug 16, 2022
75ea3d6
Add support for allocating external service IP addresses
smklein Aug 17, 2022
c19c217
nexus config in DB, starting to move service allocation to saga
smklein Aug 18, 2022
c1bea5b
Merge branch 'main' into service-management-and-rss-handoff
smklein Sep 12, 2022
e9944ba
partway through patching sync errors
smklein Sep 12, 2022
f97c438
Merge branch 'main' into service-management-and-rss-handoff
smklein Sep 12, 2022
80f9ffd
Welp, it compiles
smklein Sep 12, 2022
7bb170e
Add service provision CTE sketch
smklein Sep 12, 2022
19dde72
add sql proof-of-concept
smklein Sep 14, 2022
6860048
Not quite working, but compiling with CTEs
smklein Sep 15, 2022
3ef71f8
Making some progress by exploiting the 'table' macro
smklein Sep 16, 2022
6406ec6
significantly more of the CTE implemented
smklein Sep 19, 2022
8b3fcc5
Aliases seem to be working
smklein Sep 20, 2022
92250b1
splitting up CTE stuff
smklein Sep 20, 2022
4f8c43c
using macros for assistance
smklein Sep 21, 2022
62616f4
Escaping impld
smklein Sep 21, 2022
762dc0d
Merge
smklein Oct 3, 2022
e246cea
Merged, but kinda roughly
smklein Oct 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
256 changes: 181 additions & 75 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ pub const SLED_PREFIX: u8 = 64;
/// The amount of redundancy for DNS servers.
///
/// Must be less than MAX_DNS_REDUNDANCY.
pub const DNS_REDUNDANCY: usize = 1;
pub const DNS_REDUNDANCY: u32 = 1;
/// The maximum amount of redundancy for DNS servers.
///
/// This determines the number of addresses which are
/// reserved for DNS servers.
pub const MAX_DNS_REDUNDANCY: usize = 5;
pub const MAX_DNS_REDUNDANCY: u32 = 5;

pub const DNS_PORT: u16 = 53;
pub const DNS_SERVER_PORT: u16 = 5353;
Expand All @@ -34,10 +34,12 @@ 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 CLICKHOUSE_PORT: u16 = 8123;
pub const OXIMETER_PORT: u16 = 12223;
pub const DENDRITE_PORT: u16 = 12224;

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

// Anycast is a mechanism in which a single IP address is shared by multiple
Expand Down Expand Up @@ -85,6 +87,11 @@ pub struct DnsSubnet {
}

impl DnsSubnet {
/// Creates a subnet, given an address for the DNS server itself.
pub fn from_dns_address(address: Ipv6Addr) -> Self {
Self { subnet: Ipv6Subnet::new(address) }
}

/// Returns the DNS server address within the subnet.
///
/// This is the first address within the subnet.
Expand Down Expand Up @@ -180,7 +187,7 @@ mod test {

// Observe the first DNS subnet within this reserved rack subnet.
let dns_subnets = rack_subnet.get_dns_subnets();
assert_eq!(DNS_REDUNDANCY, dns_subnets.len());
assert_eq!(DNS_REDUNDANCY, dns_subnets.len() as u32);

// The DNS address and GZ address should be only differing by one.
assert_eq!(
Expand Down
50 changes: 47 additions & 3 deletions common/src/sql/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ CREATE TABLE omicron.public.sled (
last_used_address INET NOT NULL
);

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

CREATE INDEX ON omicron.public.sled (
id
Expand Down Expand Up @@ -125,7 +126,40 @@ CREATE TABLE omicron.public.service (

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

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

/*
* Additional context for services of "kind = nexus"
* This table should be treated as an optional extension
* of the service table itself.
*/
CREATE TABLE omicron.public.nexus_service (
id UUID PRIMARY KEY,

/* FK to the service table */
service_id UUID NOT NULL,
/* FK to the instance_external_ip table */
external_ip_id UUID NOT NULL,
/* FK to the nexus_certificate table */
certificate_id UUID NOT NULL
);

/*
* Information about x509 certificates used to serve Nexus' external interface.
* These certificates may be used by multiple instantiations of the Nexus
* service simultaneously.
*/
CREATE TABLE omicron.public.nexus_certificate (
id UUID PRIMARY KEY,
public_cert BYTES NOT NULL,
private_key BYTES NOT NULL
);

/*
Expand All @@ -148,6 +182,11 @@ CREATE TABLE omicron.public.Zpool (
total_size INT NOT NULL
);

/* Create an index which allows looking up all zpools on a sled */
CREATE INDEX on omicron.public.Zpool (
sled_id
) WHERE time_deleted IS NULL;

CREATE TYPE omicron.public.dataset_kind AS ENUM (
'crucible',
'cockroach',
Expand Down Expand Up @@ -184,6 +223,11 @@ CREATE TABLE omicron.public.Dataset (
)
);

/* Create an index which allows looking up all datasets in a pool */
CREATE INDEX on omicron.public.Dataset (
pool_id
) WHERE time_deleted IS NULL;

/* Create an index on the size usage for Crucible's allocation */
CREATE INDEX on omicron.public.Dataset (
size_used
Expand Down
15 changes: 3 additions & 12 deletions docs/how-to-run.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ When we deploy, we're effectively creating a number of different zones
for all the components that make up Omicron (Nexus, Clickhouse, Crucible, etc).
Since all these services run in different zones they cannot communicate with
each other (and Sled Agent in the global zone) via `localhost`. In practice,
we'll assign addresses as per RFD 63 as well as incorporating DNS based
we assign addresses as per RFD 63 as well as incorporating DNS based
service discovery.

For the purposes of local development today, we specify some hardcoded IPv6
unique local addresses in the subnet of the first Sled Agent: `fd00:1122:3344:1::/64`.
For the purposes of local development today, we specify some hardcoded IP
addresses.

If you'd like to modify these values to suit your local network, you can modify
them within the https://github.com/oxidecomputer/omicron/tree/main/smf[`smf/` subdirectory].
Expand All @@ -171,15 +171,6 @@ be set as a default route for the Nexus zone.
|===================================================================================================
| Service | Endpoint
| Sled Agent: Bootstrap | Derived from MAC address of physical data link.
| Sled Agent: Dropshot API | `[fd00:1122:3344:0101::1]:12345`
| Cockroach DB | `[fd00:1122:3344:0101::2]:32221`
| Nexus: Internal API | `[fd00:1122:3344:0101::3]:12221`
| Oximeter | `[fd00:1122:3344:0101::4]:12223`
| Clickhouse | `[fd00:1122:3344:0101::5]:8123`
| Crucible Downstairs 1 | `[fd00:1122:3344:0101::6]:32345`
| Crucible Downstairs 2 | `[fd00:1122:3344:0101::7]:32345`
| Crucible Downstairs 3 | `[fd00:1122:3344:0101::8]:32345`
| Internal DNS Service | `[fd00:1122:3344:0001::1]:5353`
| Nexus: External API | `192.168.1.20:80`
| Internet Gateway | None, but can be set in `smf/sled-agent/config-rss.toml`
|===================================================================================================
Expand Down
1 change: 1 addition & 0 deletions nexus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ nexus-test-utils-macros = { path = "test-utils-macros" }
nexus-test-utils = { path = "test-utils" }
omicron-test-utils = { path = "../test-utils" }
openapiv3 = "1.0"
pretty_assertions = "1.3"
regex = "1.6.0"
subprocess = "0.2.9"
term = "0.7"
Expand Down
1 change: 1 addition & 0 deletions nexus/db-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ anyhow = "1.0"
chrono = { version = "0.4", features = ["serde"] }
diesel = { version = "2.0.2", features = ["postgres", "r2d2", "chrono", "serde_json", "network-address", "uuid"] }
hex = "0.4.3"
internal-dns-client = { path = "../../internal-dns-client" }
ipnetwork = "0.20"
macaddr = { version = "1.0.1", features = [ "serde_std" ]}
newtype_derive = "0.1.6"
Expand Down
31 changes: 24 additions & 7 deletions nexus/db-model/src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use super::{DatasetKind, Generation, Region, SqlU16};
use crate::collection::DatastoreCollectionConfig;
use crate::ipv6;
use crate::schema::{dataset, region};
use chrono::{DateTime, Utc};
use db_macros::Asset;
use internal_dns_client::names::{BackendName, ServiceName, AAAA, SRV};
use nexus_types::identity::Asset;
use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
use std::net::{Ipv6Addr, SocketAddrV6};
use uuid::Uuid;

/// Database representation of a Dataset.
Expand All @@ -35,18 +38,18 @@ pub struct Dataset {

pub pool_id: Uuid,

ip: ipnetwork::IpNetwork,
ip: ipv6::Ipv6Addr,
port: SqlU16,

kind: DatasetKind,
pub kind: DatasetKind,
pub size_used: Option<i64>,
}

impl Dataset {
pub fn new(
id: Uuid,
pool_id: Uuid,
addr: SocketAddr,
addr: SocketAddrV6,
kind: DatasetKind,
) -> Self {
let size_used = match kind {
Expand All @@ -65,12 +68,26 @@ impl Dataset {
}
}

pub fn address(&self) -> SocketAddr {
pub fn address(&self) -> SocketAddrV6 {
self.address_with_port(self.port.into())
}

pub fn address_with_port(&self, port: u16) -> SocketAddr {
SocketAddr::new(self.ip.ip(), port)
pub fn address_with_port(&self, port: u16) -> SocketAddrV6 {
SocketAddrV6::new(Ipv6Addr::from(self.ip), port, 0, 0)
}

pub fn aaaa(&self) -> AAAA {
AAAA::Zone(self.id())
}

pub fn srv(&self) -> SRV {
match self.kind {
DatasetKind::Crucible => {
SRV::Backend(BackendName::Crucible, self.id())
}
DatasetKind::Clickhouse => SRV::Service(ServiceName::Clickhouse),
DatasetKind::Cockroach => SRV::Service(ServiceName::Cockroach),
}
}
}

Expand Down
15 changes: 13 additions & 2 deletions nexus/db-model/src/dataset_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

use super::impl_enum_type;
use nexus_types::internal_api;
use omicron_common::address::{CLICKHOUSE_PORT, COCKROACH_PORT, CRUCIBLE_PORT};
use serde::{Deserialize, Serialize};

impl_enum_type!(
#[derive(SqlType, Debug, QueryId)]
#[derive(Clone, SqlType, Debug, QueryId)]
#[diesel(postgres_type(name = "dataset_kind"))]
pub struct DatasetKindEnum;

#[derive(Clone, Debug, AsExpression, FromSqlRow, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Copy, Debug, AsExpression, FromSqlRow, Serialize, Deserialize, PartialEq)]
#[diesel(sql_type = DatasetKindEnum)]
pub enum DatasetKind;

Expand All @@ -21,6 +22,16 @@ impl_enum_type!(
Clickhouse => b"clickhouse"
);

impl DatasetKind {
pub fn port(&self) -> u16 {
match self {
DatasetKind::Crucible => CRUCIBLE_PORT,
DatasetKind::Cockroach => COCKROACH_PORT,
DatasetKind::Clickhouse => CLICKHOUSE_PORT,
}
}
}

impl From<internal_api::params::DatasetKind> for DatasetKind {
fn from(k: internal_api::params::DatasetKind) -> Self {
match k {
Expand Down
12 changes: 11 additions & 1 deletion nexus/db-model/src/ipv6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ use diesel::sql_types::Inet;
use ipnetwork::IpNetwork;
use ipnetwork::Ipv6Network;
use omicron_common::api::external::Error;
use serde::{Deserialize, Serialize};

#[derive(
Clone, Copy, AsExpression, FromSqlRow, PartialEq, Ord, PartialOrd, Eq,
Clone,
Copy,
AsExpression,
FromSqlRow,
PartialEq,
Ord,
PartialOrd,
Eq,
Deserialize,
Serialize,
)]
#[diesel(sql_type = Inet)]
pub struct Ipv6Addr(std::net::Ipv6Addr);
Expand Down
1 change: 1 addition & 0 deletions nexus/db-model/src/queries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
//! Subqueries used in CTEs.

pub mod region_allocation;
pub mod service_provision;
3 changes: 2 additions & 1 deletion nexus/db-model/src/queries/region_allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ diesel::allow_tables_to_appear_in_same_query!(
dataset,
);

diesel::allow_tables_to_appear_in_same_query!(candidate_regions, zpool,);

diesel::allow_tables_to_appear_in_same_query!(
do_insert,
candidate_regions,
dataset,
zpool,
);

diesel::allow_tables_to_appear_in_same_query!(candidate_zpools, dataset,);
Expand Down
77 changes: 77 additions & 0 deletions nexus/db-model/src/queries/service_provision.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// 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/.

//! Service prosioning subqueries used by CTEs.

table! {
sled_allocation_pool {
id -> Uuid,
}
}

table! {
previously_allocated_services {
id -> Uuid,
time_created -> Timestamptz,
time_modified -> Timestamptz,

sled_id -> Uuid,
ip -> Inet,
kind -> crate::ServiceKindEnum,
}
}

table! {
old_service_count (count) {
count -> Int8,
}
}

table! {
new_service_count (count) {
count -> Int8,
}
}

table! {
candidate_sleds {
id -> Uuid,
}
}

table! {
new_internal_ips {
id -> Uuid,
last_used_address -> Inet,
}
}

diesel::allow_tables_to_appear_in_same_query!(
candidate_sleds,
new_internal_ips,
);

table! {
candidate_services {
id -> Uuid,
time_created -> Timestamptz,
time_modified -> Timestamptz,

sled_id -> Uuid,
ip -> Inet,
kind -> crate::ServiceKindEnum,
}
}

table! {
inserted_services {
id -> Uuid,
time_created -> Timestamptz,
time_modified -> Timestamptz,

sled_id -> Uuid,
ip -> Inet,
kind -> crate::ServiceKindEnum,
}
}
Loading