Skip to content

Commit 3894ecd

Browse files
committed
Review feedback
- mv zb.rs -> zone-bundle.rs - Add TOML extension to zone bundle metadata file - Return 404 on bad zone name - Typos, safety notes, and link to logadm(8)
1 parent bccdb26 commit 3894ecd

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

illumos-utils/src/running_zone.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,9 @@ impl RunningZone {
880880
// The rotated log files should have the same prefix as the current, but
881881
// with an index appended. We'll search the parent directory for
882882
// matching names, skipping the current file.
883+
//
884+
// See https://illumos.org/man/8/logadm for details on the naming
885+
// conventions around these files.
883886
let dir = current_log_file.parent().unwrap();
884887
let mut rotated_files = Vec::new();
885888
for entry in dir.read_dir_utf8()? {

sled-agent/src/bin/zb.rs renamed to sled-agent/src/bin/zone-bundle.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn parse_log_level(s: &str) -> anyhow::Result<Level> {
2828

2929
/// Operate on sled agent zone bundles.
3030
///
31-
/// Zoneb bundles are the collected state of a service zone. This includes
31+
/// Zone bundles are the collected state of a service zone. This includes
3232
/// information about the processes running in the zone, and the system on which
3333
/// they're running.
3434
#[derive(Clone, Debug, Parser)]
@@ -107,7 +107,12 @@ async fn main() -> anyhow::Result<()> {
107107
.context("failed to list zone bundles")?
108108
.into_inner();
109109
for bundle in bundles {
110-
println!("{}/{}", bundle.id.zone_name, bundle.id.bundle_id);
110+
println!(
111+
"{}/{} {}",
112+
bundle.id.zone_name,
113+
bundle.id.bundle_id,
114+
bundle.time_created
115+
);
111116
}
112117
}
113118
Cmd::Create { zone_name } => {

sled-agent/src/services.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ const BUNDLE_DIRECTORY: &str = "bundle";
258258
// The directory for zone bundles.
259259
const ZONE_BUNDLE_DIRECTORY: &str = "zone";
260260

261+
// The name for zone bundle metadata files.
262+
const ZONE_BUNDLE_METADATA_FILENAME: &str = "metadata.toml";
263+
261264
// A wrapper around `ZoneRequest`, which allows it to be serialized
262265
// to a toml file.
263266
#[derive(Clone, serde::Serialize, serde::Deserialize)]
@@ -2005,7 +2008,11 @@ impl ServiceManager {
20052008

20062009
// Write the metadata file itself, in TOML format.
20072010
let contents = toml::to_string(&zone_metadata)?;
2008-
insert_data(&mut builder, "metadata", contents.as_bytes())?;
2011+
insert_data(
2012+
&mut builder,
2013+
ZONE_BUNDLE_METADATA_FILENAME,
2014+
contents.as_bytes(),
2015+
)?;
20092016
debug!(
20102017
log,
20112018
"wrote zone bundle metadata";
@@ -2113,8 +2120,9 @@ impl ServiceManager {
21132120
// Copy any log files, current and rotated, into the tarball as
21142121
// well.
21152122
//
2116-
// Saftey: This is a log file, so we're sure it's a single, normal
2117-
// file and thus has a name.
2123+
// Safety: This pathbuf was retrieved by locating an existing file
2124+
// on the filesystem, so we're sure it has a name and the unwrap is
2125+
// safe.
21182126
debug!(
21192127
log,
21202128
"appending current log file to zone bundle";
@@ -2232,7 +2240,7 @@ impl ServiceManager {
22322240
.find(|entry| {
22332241
entry
22342242
.path()
2235-
.map(|p| p.to_str() == Some("metadata"))
2243+
.map(|p| p.to_str() == Some(ZONE_BUNDLE_METADATA_FILENAME))
22362244
.unwrap_or(false)
22372245
})
22382246
else {

sled-agent/src/sled_agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl From<Error> for dropshot::HttpError {
149149
HttpError::for_unavail(None, inner.to_string())
150150
}
151151
crate::services::BundleError::NoSuchZone { .. } => {
152-
HttpError::for_bad_request(None, inner.to_string())
152+
HttpError::for_not_found(None, inner.to_string())
153153
}
154154
_ => HttpError::for_internal_error(err.to_string()),
155155
},

0 commit comments

Comments
 (0)