Skip to content

Commit 2481b77

Browse files
authored
Bump to 2024 edition (#1799)
I got tired of my editor's LSP complaining about `gen`, and decided to update everything to Rust 2024. This was mostly mechanical renaming of `gen` → `generation`, Clippy fixes, and `rustfmt`. `VolumeConstructionRequest` has to have a `#[serde(rename = "gen")]` annotation, because it's been stored on disk.
1 parent f33e4c8 commit 2481b77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1165
-983
lines changed

agent-antagonist/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "agent-antagonist"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

agent-antagonist/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use anyhow::bail;
21
use anyhow::Result;
2+
use anyhow::bail;
33
use clap::Parser;
44
use crucible_common::build_logger;
55
use futures::StreamExt;
@@ -11,14 +11,14 @@ use slog::{info, warn};
1111
use std::net::SocketAddr;
1212
use std::process::Command;
1313
use std::sync::{
14-
atomic::{AtomicBool, Ordering},
1514
Arc,
15+
atomic::{AtomicBool, Ordering},
1616
};
1717
use uuid::Uuid;
1818

1919
use crucible_agent_client::{
20-
types::{CreateRegion, RegionId, State as RegionState},
2120
Client as CrucibleAgentClient,
21+
types::{CreateRegion, RegionId, State as RegionState},
2222
};
2323

2424
#[derive(Debug, Parser)]

agent-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "crucible-agent-client"
33
version = "0.0.1"
44
license = "MPL-2.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[dependencies]
88
anyhow.workspace = true

agent/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "crucible-agent"
33
version = "0.0.1"
44
license = "MPL-2.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[dependencies]
88
anyhow.workspace = true

agent/src/datafile.rs

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
// Copyright 2021 Oxide Computer Company
22

3-
use anyhow::{anyhow, bail, Result};
3+
use anyhow::{Result, anyhow, bail};
44
use crucible_agent_types::{region::*, snapshot::*};
55
use crucible_common::write_json;
66
use serde::{Deserialize, Serialize};
7-
use slog::{crit, error, info, Logger};
7+
use slog::{Logger, crit, error, info};
88
use std::collections::BTreeMap;
99
use std::net::SocketAddr;
1010
use std::path::Path;
1111
use std::path::PathBuf;
1212
use std::sync::{Arc, Condvar, Mutex, MutexGuard};
1313

14+
use crate::ZFSDataset;
1415
use crate::resource::Resource;
1516
use crate::snapshot_interface::SnapshotInterface;
16-
use crate::ZFSDataset;
1717

1818
pub struct DataFile {
1919
log: Logger,
@@ -434,31 +434,29 @@ impl DataFile {
434434
*/
435435
if let Some(running_snapshots) =
436436
inner.running_snapshots.get(&request.id)
437+
&& let Some(running_snapshot) = running_snapshots.get(&request.name)
437438
{
438-
if let Some(running_snapshot) = running_snapshots.get(&request.name)
439-
{
440-
match running_snapshot.state {
441-
State::Requested | State::Created | State::Tombstoned => {
442-
bail!(
443-
"read-only downstairs running for region {} snapshot {}",
444-
request.id.0,
445-
request.name
446-
);
447-
}
439+
match running_snapshot.state {
440+
State::Requested | State::Created | State::Tombstoned => {
441+
bail!(
442+
"read-only downstairs running for region {} snapshot {}",
443+
request.id.0,
444+
request.name
445+
);
446+
}
448447

449-
State::Destroyed => {
450-
// ok to delete
451-
}
448+
State::Destroyed => {
449+
// ok to delete
450+
}
452451

453-
State::Failed => {
454-
// Something has set the running snapshot to state
455-
// failed, so we can't delete this snapshot.
456-
bail!(
457-
"read-only downstairs state set to failed for region {} snapshot {}",
458-
request.id.0,
459-
request.name
460-
);
461-
}
452+
State::Failed => {
453+
// Something has set the running snapshot to state
454+
// failed, so we can't delete this snapshot.
455+
bail!(
456+
"read-only downstairs state set to failed for region {} snapshot {}",
457+
request.id.0,
458+
request.name
459+
);
462460
}
463461
}
464462
}
@@ -489,7 +487,10 @@ impl DataFile {
489487
// This is a bug: according to the agent's datafile,
490488
// the region exists, but according to zfs list, it
491489
// does not
492-
bail!("Agent thinks region {} exists but zfs list does not! {e}", request.id.0);
490+
bail!(
491+
"Agent thinks region {} exists but zfs list does not! {e}",
492+
request.id.0
493+
);
493494
}
494495

495496
State::Failed => {
@@ -503,7 +504,11 @@ impl DataFile {
503504
}
504505
} else {
505506
// In here, the region never existed!
506-
bail!("Inside region {} snapshot {} delete, region never existed! {e}", request.id.0, request.name);
507+
bail!(
508+
"Inside region {} snapshot {} delete, region never existed! {e}",
509+
request.id.0,
510+
request.name
511+
);
507512
}
508513
}
509514
};
@@ -863,7 +868,7 @@ impl DataFile {
863868

864869
#[cfg(test)]
865870
mod test {
866-
use anyhow::{bail, Result};
871+
use anyhow::{Result, bail};
867872
use chrono::{DateTime, TimeZone, Utc};
868873
use std::process::Command;
869874

@@ -901,9 +906,8 @@ mod test {
901906
let cmd_stdout = String::from_utf8_lossy(&cmd.stdout);
902907

903908
// Remove newline
904-
let cmd_stdout = cmd_stdout.trim_end().to_string();
905909

906-
cmd_stdout
910+
cmd_stdout.trim_end().to_string()
907911
};
908912

909913
let _date = Utc.timestamp_opt(cmd_stdout.parse()?, 0).unwrap();

agent/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright 2021 Oxide Computer Company
22

3-
use anyhow::{anyhow, bail, Result};
3+
use anyhow::{Result, anyhow, bail};
44
use clap::Parser;
55
use crucible_agent_types::smf::SmfProperty;
66
use dropshot::{ConfigLogging, ConfigLoggingIfExists, ConfigLoggingLevel};
7-
use slog::{debug, error, info, o, Logger};
7+
use slog::{Logger, debug, error, info, o};
88
use std::collections::HashSet;
99
use std::net::SocketAddr;
1010
use std::path::{Path, PathBuf};
@@ -1195,7 +1195,7 @@ mod test {
11951195
use crate::snapshot_interface::TestSnapshotInterface;
11961196

11971197
use crucible_agent_types::{region::*, snapshot::*};
1198-
use slog::{o, Drain, Logger};
1198+
use slog::{Drain, Logger, o};
11991199
use std::collections::BTreeMap;
12001200
use tempfile::*;
12011201
use uuid::Uuid;

agent/src/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright 2024 Oxide Computer Company
22
use super::datafile::DataFile;
3-
use anyhow::{anyhow, Result};
3+
use anyhow::{Result, anyhow};
44
use crucible_agent_api::*;
55
use crucible_agent_types::{region, snapshot};
66
use dropshot::{
77
ClientSpecifiesVersionInHeader, HandlerTaskMode, HttpError,
88
HttpResponseDeleted, HttpResponseOk, Path as TypedPath, RequestContext,
99
TypedBody, VersionPolicy,
1010
};
11-
use slog::{o, Logger};
11+
use slog::{Logger, o};
1212
use std::net::SocketAddr;
1313
use std::result::Result as SResult;
1414
use std::sync::Arc;

agent/src/snapshot_interface.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2023 Oxide Computer Company
22

3-
use anyhow::{bail, Result};
3+
use anyhow::{Result, bail};
44
use crucible_agent_types::snapshot::Snapshot;
5-
use slog::{error, info, Logger};
5+
use slog::{Logger, error, info};
66
#[cfg(test)]
77
use std::collections::HashSet;
88
use std::process::Command;
@@ -113,9 +113,8 @@ impl SnapshotInterface for ZfsSnapshotInterface {
113113
let cmd_stdout = String::from_utf8_lossy(&cmd.stdout);
114114

115115
// Remove newline
116-
let cmd_stdout = cmd_stdout.trim_end().to_string();
117116

118-
cmd_stdout
117+
cmd_stdout.trim_end().to_string()
119118
};
120119

121120
if !cmd.status.success() {

cmon/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "cmon"
33
version = "0.1.0"
44
license = "MPL-2.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[dependencies]
88
clap.workspace = true

cmon/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::fmt;
66
use std::io::{self, BufRead};
77
use strum::IntoEnumIterator;
88
use strum_macros::EnumIter;
9-
use tokio::time::{sleep, Duration};
9+
use tokio::time::{Duration, sleep};
1010

1111
use crucible::DtraceInfo;
1212

0 commit comments

Comments
 (0)