Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion agent-antagonist/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "agent-antagonist"
version = "0.1.0"
edition = "2021"
edition = "2024"

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

Expand Down
6 changes: 3 additions & 3 deletions agent-antagonist/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::bail;
use anyhow::Result;
use anyhow::bail;
use clap::Parser;
use crucible_common::build_logger;
use futures::StreamExt;
Expand All @@ -11,14 +11,14 @@ use slog::{info, warn};
use std::net::SocketAddr;
use std::process::Command;
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
atomic::{AtomicBool, Ordering},
};
use uuid::Uuid;

use crucible_agent_client::{
types::{CreateRegion, RegionId, State as RegionState},
Client as CrucibleAgentClient,
types::{CreateRegion, RegionId, State as RegionState},
};

#[derive(Debug, Parser)]
Expand Down
2 changes: 1 addition & 1 deletion agent-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "crucible-agent-client"
version = "0.0.1"
license = "MPL-2.0"
edition = "2021"
edition = "2024"

[dependencies]
anyhow.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "crucible-agent"
version = "0.0.1"
license = "MPL-2.0"
edition = "2021"
edition = "2024"

[dependencies]
anyhow.workspace = true
Expand Down
64 changes: 34 additions & 30 deletions agent/src/datafile.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Copyright 2021 Oxide Computer Company

use anyhow::{anyhow, bail, Result};
use anyhow::{Result, anyhow, bail};
use crucible_agent_types::{region::*, snapshot::*};
use crucible_common::write_json;
use serde::{Deserialize, Serialize};
use slog::{crit, error, info, Logger};
use slog::{Logger, crit, error, info};
use std::collections::BTreeMap;
use std::net::SocketAddr;
use std::path::Path;
use std::path::PathBuf;
use std::sync::{Arc, Condvar, Mutex, MutexGuard};

use crate::ZFSDataset;
use crate::resource::Resource;
use crate::snapshot_interface::SnapshotInterface;
use crate::ZFSDataset;

pub struct DataFile {
log: Logger,
Expand Down Expand Up @@ -434,31 +434,29 @@ impl DataFile {
*/
if let Some(running_snapshots) =
inner.running_snapshots.get(&request.id)
&& let Some(running_snapshot) = running_snapshots.get(&request.name)
{
if let Some(running_snapshot) = running_snapshots.get(&request.name)
{
match running_snapshot.state {
State::Requested | State::Created | State::Tombstoned => {
bail!(
"read-only downstairs running for region {} snapshot {}",
request.id.0,
request.name
);
}
match running_snapshot.state {
State::Requested | State::Created | State::Tombstoned => {
bail!(
"read-only downstairs running for region {} snapshot {}",
request.id.0,
request.name
);
}

State::Destroyed => {
// ok to delete
}
State::Destroyed => {
// ok to delete
}

State::Failed => {
// Something has set the running snapshot to state
// failed, so we can't delete this snapshot.
bail!(
"read-only downstairs state set to failed for region {} snapshot {}",
request.id.0,
request.name
);
}
State::Failed => {
// Something has set the running snapshot to state
// failed, so we can't delete this snapshot.
bail!(
"read-only downstairs state set to failed for region {} snapshot {}",
request.id.0,
request.name
);
}
}
}
Expand Down Expand Up @@ -489,7 +487,10 @@ impl DataFile {
// This is a bug: according to the agent's datafile,
// the region exists, but according to zfs list, it
// does not
bail!("Agent thinks region {} exists but zfs list does not! {e}", request.id.0);
bail!(
"Agent thinks region {} exists but zfs list does not! {e}",
request.id.0
);
}

State::Failed => {
Expand All @@ -503,7 +504,11 @@ impl DataFile {
}
} else {
// In here, the region never existed!
bail!("Inside region {} snapshot {} delete, region never existed! {e}", request.id.0, request.name);
bail!(
"Inside region {} snapshot {} delete, region never existed! {e}",
request.id.0,
request.name
);
}
}
};
Expand Down Expand Up @@ -863,7 +868,7 @@ impl DataFile {

#[cfg(test)]
mod test {
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use chrono::{DateTime, TimeZone, Utc};
use std::process::Command;

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

// Remove newline
let cmd_stdout = cmd_stdout.trim_end().to_string();

cmd_stdout
cmd_stdout.trim_end().to_string()
};

let _date = Utc.timestamp_opt(cmd_stdout.parse()?, 0).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions agent/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright 2021 Oxide Computer Company

use anyhow::{anyhow, bail, Result};
use anyhow::{Result, anyhow, bail};
use clap::Parser;
use crucible_agent_types::smf::SmfProperty;
use dropshot::{ConfigLogging, ConfigLoggingIfExists, ConfigLoggingLevel};
use slog::{debug, error, info, o, Logger};
use slog::{Logger, debug, error, info, o};
use std::collections::HashSet;
use std::net::SocketAddr;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -1195,7 +1195,7 @@ mod test {
use crate::snapshot_interface::TestSnapshotInterface;

use crucible_agent_types::{region::*, snapshot::*};
use slog::{o, Drain, Logger};
use slog::{Drain, Logger, o};
use std::collections::BTreeMap;
use tempfile::*;
use uuid::Uuid;
Expand Down
4 changes: 2 additions & 2 deletions agent/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright 2024 Oxide Computer Company
use super::datafile::DataFile;
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use crucible_agent_api::*;
use crucible_agent_types::{region, snapshot};
use dropshot::{
ClientSpecifiesVersionInHeader, HandlerTaskMode, HttpError,
HttpResponseDeleted, HttpResponseOk, Path as TypedPath, RequestContext,
TypedBody, VersionPolicy,
};
use slog::{o, Logger};
use slog::{Logger, o};
use std::net::SocketAddr;
use std::result::Result as SResult;
use std::sync::Arc;
Expand Down
7 changes: 3 additions & 4 deletions agent/src/snapshot_interface.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2023 Oxide Computer Company

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

// Remove newline
let cmd_stdout = cmd_stdout.trim_end().to_string();

cmd_stdout
cmd_stdout.trim_end().to_string()
};

if !cmd.status.success() {
Expand Down
2 changes: 1 addition & 1 deletion cmon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cmon"
version = "0.1.0"
license = "MPL-2.0"
edition = "2021"
edition = "2024"

[dependencies]
clap.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion cmon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::fmt;
use std::io::{self, BufRead};
use strum::IntoEnumIterator;
use strum_macros::EnumIter;
use tokio::time::{sleep, Duration};
use tokio::time::{Duration, sleep};

use crucible::DtraceInfo;

Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "crucible-common"
version = "0.0.1"
authors = ["Joshua M. Clulow <[email protected]>", "Alan Hanson <[email protected]>"]
license = "MPL-2.0"
edition = "2021"
edition = "2024"

[dependencies]
anyhow.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions common/src/impacted_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl ImpactedBlocks {
pub fn extents(
&self,
ddef: &RegionDefinition,
) -> impl Iterator<Item = ExtentId> {
) -> impl Iterator<Item = ExtentId> + use<'_> {
let blocks_per_extent = ddef.extent_size().value;
match self {
ImpactedBlocks::Empty => None, /* empty range */
Expand Down Expand Up @@ -222,7 +222,7 @@ mod test {
use proptest::prelude::*;
use std::panic;
use std::panic::UnwindSafe;
use test_strategy::{proptest, Arbitrary};
use test_strategy::{Arbitrary, proptest};

fn basic_region_definition(
extent_size: u32,
Expand Down Expand Up @@ -574,8 +574,8 @@ mod test {

/// Generate a random region definition, and a single ImpactedBlocks range
/// within it.
fn region_and_impacted_blocks_strategy(
) -> impl Strategy<Value = (RegionDefinition, ImpactedBlocks)> {
fn region_and_impacted_blocks_strategy()
-> impl Strategy<Value = (RegionDefinition, ImpactedBlocks)> {
any::<(ArbitraryRegionDefinition, ArbitraryImpactedBlocks)>().prop_map(
|(test_ddef, test_iblocks)| {
let ddef = reify_region_definition(test_ddef);
Expand Down
12 changes: 5 additions & 7 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::path::Path;

use ErrorKind::NotFound;

use anyhow::{anyhow, bail, Context, Result};
use anyhow::{Context, Result, anyhow, bail};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use slog::Drain;
Expand All @@ -16,9 +16,9 @@ use tokio::time::Duration;

mod region;
pub use region::{
config_path, Block, BlockIndex, BlockOffset, ExtentId, RegionDefinition,
RegionOptions, DATABASE_READ_VERSION, DATABASE_WRITE_VERSION,
MAX_BLOCK_SIZE, MAX_SHIFT, MIN_BLOCK_SIZE, MIN_SHIFT,
Block, BlockIndex, BlockOffset, DATABASE_READ_VERSION,
DATABASE_WRITE_VERSION, ExtentId, MAX_BLOCK_SIZE, MAX_SHIFT,
MIN_BLOCK_SIZE, MIN_SHIFT, RegionDefinition, RegionOptions, config_path,
};

pub mod impacted_blocks;
Expand Down Expand Up @@ -225,9 +225,7 @@ pub enum NegotiationError {
)]
EncryptionMismatch { expected: bool, actual: bool },

#[error(
"Incompatible read-only settings: wanted {expected}, got {actual}"
)]
#[error("Incompatible read-only settings: wanted {expected}, got {actual}")]
ReadOnlyMismatch { expected: bool, actual: bool },

#[error("Incompatible upstairs ID: wanted {expected}, got {actual}")]
Expand Down
2 changes: 1 addition & 1 deletion common/src/region.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2021 Oxide Computer Company
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
Expand Down
2 changes: 1 addition & 1 deletion control-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "crucible-control-client"
version = "0.0.1"
license = "MPL-2.0"
edition = "2021"
edition = "2024"

[dependencies]
anyhow.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crucible-client-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "crucible-client-types"
version = "0.1.0"
edition = "2021"
edition = "2024"

[dependencies]
base64.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions crucible-client-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2022 Oxide Computer Company

use base64::{engine, Engine};
use base64::{Engine, engine};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::fmt;
Expand Down Expand Up @@ -29,7 +29,8 @@ pub enum VolumeConstructionRequest {
blocks_per_extent: u64,
extent_count: u32,
opts: CrucibleOpts,
gen: u64,
#[serde(rename = "gen")]
generation: u64,
},
File {
id: Uuid,
Expand Down
2 changes: 1 addition & 1 deletion crudd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "crudd"
version = "0.1.0"
authors = ["Artemis Everfree <[email protected]>"]
license = "MPL-2.0"
edition = "2021"
edition = "2024"

[dependencies]
anyhow.workspace = true
Expand Down
Loading