Skip to content

Commit 405b29c

Browse files
committed
Merge branch 'main' into dap/sp-planning-real
2 parents ac66c42 + 7bd853b commit 405b29c

File tree

34 files changed

+1099
-198
lines changed

34 files changed

+1099
-198
lines changed

Cargo.lock

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ ereport-types = { path = "ereport/types" }
424424
expectorate = "1.2.0"
425425
fatfs = "0.3.6"
426426
filetime = "0.2.25"
427-
flate2 = "1.1.1"
427+
flate2 = "1.1.2"
428428
float-ord = "0.3.2"
429429
flume = "0.11.1"
430430
foreign-types = "0.3.2"
@@ -473,7 +473,7 @@ hyper = "1.6.0"
473473
hyper-util = "0.1.11"
474474
hyper-rustls = "0.26.0"
475475
hyper-staticfile = "0.10.1"
476-
iddqd = { version = "0.3.6", features = ["daft", "serde"] }
476+
iddqd = { version = "0.3.6", features = ["daft", "serde", "schemars08"] }
477477
id-map = { path = "id-map" }
478478
illumos-utils = { path = "illumos-utils" }
479479
iana-time-zone = "0.1.63"

common/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ tufaceous-artifact.workspace = true
5959
camino-tempfile.workspace = true
6060
expectorate.workspace = true
6161
libc.workspace = true
62+
proptest.workspace = true
6263
regress.workspace = true
6364
serde_urlencoded.workspace = true
65+
test-strategy.workspace = true
6466
tokio = { workspace = true, features = ["test-util"] }
6567
toml.workspace = true
6668

common/src/api/internal/shared.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ pub struct ExternalIpGatewayMap {
920920
#[derive(
921921
Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Hash, EnumCount, Diffable,
922922
)]
923-
#[cfg_attr(feature = "testing", derive(test_strategy::Arbitrary))]
923+
#[cfg_attr(any(test, feature = "testing"), derive(test_strategy::Arbitrary))]
924924
pub enum DatasetKind {
925925
// Durable datasets for zones
926926
Cockroach,
@@ -942,8 +942,6 @@ pub enum DatasetKind {
942942

943943
// Other datasets
944944
Debug,
945-
// Stores update artifacts (the "TUF Repo Depot")
946-
Update,
947945
}
948946

949947
impl Serialize for DatasetKind {
@@ -1004,7 +1002,7 @@ impl DatasetKind {
10041002
match self {
10051003
Cockroach | Crucible | Clickhouse | ClickhouseKeeper
10061004
| ClickhouseServer | ExternalDns | InternalDns => true,
1007-
TransientZoneRoot | TransientZone { .. } | Debug | Update => false,
1005+
TransientZoneRoot | TransientZone { .. } | Debug => false,
10081006
}
10091007
}
10101008

@@ -1042,7 +1040,6 @@ impl fmt::Display for DatasetKind {
10421040
return Ok(());
10431041
}
10441042
Debug => "debug",
1045-
Update => "update",
10461043
};
10471044
write!(f, "{}", s)
10481045
}
@@ -1069,7 +1066,6 @@ impl FromStr for DatasetKind {
10691066
"internal_dns" => InternalDns,
10701067
"zone" => TransientZoneRoot,
10711068
"debug" => Debug,
1072-
"update" => Update,
10731069
other => {
10741070
if let Some(name) = other.strip_prefix("zone/") {
10751071
TransientZone { name: name.to_string() }
@@ -1165,7 +1161,6 @@ mod tests {
11651161
DatasetKind::TransientZoneRoot,
11661162
DatasetKind::TransientZone { name: String::from("myzone") },
11671163
DatasetKind::Debug,
1168-
DatasetKind::Update,
11691164
];
11701165

11711166
assert_eq!(kinds.len(), DatasetKind::COUNT);

common/src/disk.rs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::collections::BTreeMap;
1717
use std::fmt;
1818
use std::str::FromStr;
1919

20+
use crate::api::internal::shared::DatasetKindParseError;
2021
use crate::{
2122
api::external::{ByteCount, Generation},
2223
ledger::Ledgerable,
@@ -172,6 +173,69 @@ impl DatasetName {
172173
}
173174
}
174175

176+
#[derive(Debug, thiserror::Error)]
177+
pub enum DatasetNameParseError {
178+
#[error("missing '/' separator in dataset name {0}")]
179+
MissingSlash(String),
180+
#[error("could not parse zpool name {zpool}: {err}")]
181+
ParseZpoolName { zpool: String, err: String },
182+
#[error("could not parse dataset kind {kind}")]
183+
ParseDatasetKind {
184+
kind: String,
185+
#[source]
186+
err: DatasetKindParseError,
187+
},
188+
#[error("expected `crypt/` for kind {kind:?} in dataset name {name}")]
189+
MissingCryptInName { kind: DatasetKind, name: String },
190+
#[error("unexpected `crypt/` for kind {kind:?} in dataset name {name}")]
191+
UnexpectedCryptInName { kind: DatasetKind, name: String },
192+
}
193+
194+
impl FromStr for DatasetName {
195+
type Err = DatasetNameParseError;
196+
197+
fn from_str(s: &str) -> Result<Self, Self::Err> {
198+
let (pool_name, remainder) = s.split_once('/').ok_or_else(|| {
199+
DatasetNameParseError::MissingSlash(s.to_string())
200+
})?;
201+
202+
let pool_name = ZpoolName::from_str(pool_name).map_err(|err| {
203+
DatasetNameParseError::ParseZpoolName {
204+
zpool: pool_name.to_string(),
205+
err,
206+
}
207+
})?;
208+
209+
let (kind_str, name_has_crypt) =
210+
if let Some(remainder) = remainder.strip_prefix("crypt/") {
211+
(remainder, true)
212+
} else {
213+
(remainder, false)
214+
};
215+
216+
let kind = DatasetKind::from_str(kind_str).map_err(|err| {
217+
DatasetNameParseError::ParseDatasetKind {
218+
kind: kind_str.to_string(),
219+
err,
220+
}
221+
})?;
222+
223+
match (kind.dataset_should_be_encrypted(), name_has_crypt) {
224+
(true, true) | (false, false) => Ok(Self { pool_name, kind }),
225+
(true, false) => Err(DatasetNameParseError::MissingCryptInName {
226+
kind,
227+
name: s.to_string(),
228+
}),
229+
(false, true) => {
230+
Err(DatasetNameParseError::UnexpectedCryptInName {
231+
kind,
232+
name: s.to_string(),
233+
})
234+
}
235+
}
236+
}
237+
}
238+
175239
#[derive(
176240
Copy,
177241
Clone,
@@ -583,3 +647,24 @@ impl TryFrom<i64> for M2Slot {
583647
}
584648
}
585649
}
650+
651+
#[cfg(test)]
652+
mod tests {
653+
use super::*;
654+
use test_strategy::proptest;
655+
656+
#[proptest]
657+
fn parse_dataset_name(pool_id: [u8; 16], kind: DatasetKind) {
658+
let pool_id = ZpoolUuid::from_bytes(pool_id);
659+
for pool in
660+
[ZpoolName::new_internal(pool_id), ZpoolName::new_external(pool_id)]
661+
{
662+
let dataset_name = DatasetName::new(pool, kind.clone());
663+
let s = dataset_name.full_name();
664+
match DatasetName::from_str(&s) {
665+
Ok(d) => assert_eq!(d, dataset_name),
666+
Err(err) => panic!("failed to parse dataset name {s}: {err}"),
667+
}
668+
}
669+
}
670+
}

dev-tools/ls-apis/README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Crucible Pantry
9595
The `servers` and `deployment-units` commands accept a `--dot` argument to print output in a format that `dot(1)` can process:
9696

9797
```
98-
$ cargo xtask ls-apis deployment-units --dot > deployment-units.dot
98+
$ cargo xtask ls-apis deployment-units --output-format dot > deployment-units.dot
9999
```
100100

101101
You can generate a PNG image of the graph like this:

dev-tools/ls-apis/api-manifest.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ packages = [ "oximeter-collector" ]
149149
# tooling supports this value so that during development you can
150150
# relax these constraints.
151151
#
152+
# "server" and "client" versioning is elaborated on more in RFD 532. Note that
153+
# "lockstep" collapses into "server" here, as it's trivially the case that if
154+
# the server and client(s) are updated atomically the server does not have to
155+
# support older clients. Additionally, the "updated before" relationship is
156+
# discussed some in RFD 565, [Update
157+
# sequence](https://rfd.shared.oxide.computer/rfd/0565#_update_sequence).
158+
#
152159
# [`versioned_how_reason`]: free text string explaining why `versioned_how` must
153160
# be "client" for this API. This is printed in documentation and command output
154161
# and serves as documentation for developers to understand why we made this

dev-tools/omdb/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ gateway-test-utils.workspace = true
3131
gateway-types.workspace = true
3232
http.workspace = true
3333
humantime.workspace = true
34+
iddqd.workspace = true
3435
internal-dns-resolver.workspace = true
3536
internal-dns-types.workspace = true
3637
itertools.workspace = true

0 commit comments

Comments
 (0)