Skip to content

Commit

Permalink
[spr] initial version
Browse files Browse the repository at this point in the history
Created using spr 1.3.6-beta.1
  • Loading branch information
sunshowers committed Feb 21, 2025
1 parent ead82e5 commit 3f1a941
Show file tree
Hide file tree
Showing 731 changed files with 4,294 additions and 3,783 deletions.
22 changes: 11 additions & 11 deletions bootstore/src/schemes/v0/fsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

use super::request_manager::ShareAcks;
use super::{
create_pkgs, Envelope, FsmConfig, LearnedSharePkg, Msg, MsgError, RackUuid,
Request, RequestManager, RequestType, Response, ResponseType, Share,
SharePkg, Shares, TrackableRequest,
Envelope, FsmConfig, LearnedSharePkg, Msg, MsgError, RackUuid, Request,
RequestManager, RequestType, Response, ResponseType, Share, SharePkg,
Shares, TrackableRequest, create_pkgs,
};
use crate::Sha3_256Digest;
use crate::schemes::v0::share_pkg::SharePkgCommon;
use crate::trust_quorum::{RackSecret, TrustQuorumError};
use crate::Sha3_256Digest;
use secrecy::ExposeSecret;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
Expand Down Expand Up @@ -131,15 +131,19 @@ pub enum ApiError {
#[error("critical: failed to decrypt extra shares")]
FailedToDecryptExtraShares,

#[error("unexpected response ({msg}) from ({from}) in state ({state}) with request_id ({request_id})")]
#[error(
"unexpected response ({msg}) from ({from}) in state ({state}) with request_id ({request_id})"
)]
UnexpectedResponse {
from: Baseboard,
state: &'static str,
request_id: Uuid,
msg: &'static str,
},

#[error("error response received from ({from}) in state ({state}) with request_id ({request_id}): {error:?}")]
#[error(
"error response received from ({from}) in state ({state}) with request_id ({request_id}): {error:?}"
)]
ErrorResponseReceived {
from: Baseboard,
state: &'static str,
Expand Down Expand Up @@ -360,11 +364,7 @@ impl Fsm {
}
}
}
if errors.is_empty() {
Ok(())
} else {
Err(errors)
}
if errors.is_empty() { Ok(()) } else { Err(errors) }
}

/// A peer has been connected.
Expand Down
2 changes: 1 addition & 1 deletion bootstore/src/schemes/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use messages::{
};
pub use peer::{Config, Node, NodeHandle, NodeRequestError, Status};
pub use request_manager::{RequestManager, TrackableRequest};
pub use share_pkg::{create_pkgs, LearnedSharePkg, SharePkg, SharePkgCommon};
pub use share_pkg::{LearnedSharePkg, SharePkg, SharePkgCommon, create_pkgs};
pub use storage::NetworkConfig;

/// The current version of supported messages within the v0 scheme
Expand Down
34 changes: 16 additions & 18 deletions bootstore/src/schemes/v0/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
//! The entrypoint of the v0 scheme for use by bootstrap agent
use super::peer_networking::{
spawn_accepted_connection_management_task, spawn_connection_initiator_task,
AcceptedConnHandle, ConnToMainMsg, ConnToMainMsgInner, MainToConnMsg, Msg,
PeerConnHandle,
PeerConnHandle, spawn_accepted_connection_management_task,
spawn_connection_initiator_task,
};
use super::storage::{NetworkConfig, PersistentFsmState};
use super::{ApiError, ApiOutput, Fsm, FsmConfig, RackUuid};
use crate::trust_quorum::RackSecret;
use camino::Utf8PathBuf;
use derive_more::From;
use sled_hardware_types::Baseboard;
use slog::{error, info, o, warn, Logger};
use slog::{Logger, error, info, o, warn};
use std::collections::{BTreeMap, BTreeSet};
use std::net::{SocketAddr, SocketAddrV6};
use std::time::Duration;
use thiserror::Error;
use tokio::net::{TcpListener, TcpStream};
use tokio::sync::{mpsc, oneshot};
use tokio::time::{interval, Instant, MissedTickBehavior};
use tokio::time::{Instant, MissedTickBehavior, interval};

#[derive(Debug, Clone)]
pub struct Config {
Expand Down Expand Up @@ -1172,12 +1172,12 @@ mod tests {
learn_timeout: Duration::from_secs(5),
rack_init_timeout: Duration::from_secs(10),
rack_secret_request_timeout: Duration::from_secs(1),
fsm_state_ledger_paths: vec![tempdir
.path()
.join(&fsm_file)],
network_config_ledger_paths: vec![tempdir
.path()
.join(&network_file)],
fsm_state_ledger_paths: vec![
tempdir.path().join(&fsm_file),
],
network_config_ledger_paths: vec![
tempdir.path().join(&network_file),
],
};

TestNode::new(config, log.clone())
Expand Down Expand Up @@ -1240,14 +1240,12 @@ mod tests {
learn_timeout: Duration::from_secs(5),
rack_init_timeout: Duration::from_secs(10),
rack_secret_request_timeout: Duration::from_secs(1),
fsm_state_ledger_paths: vec![self
.tempdir
.path()
.join(&fsm_file)],
network_config_ledger_paths: vec![self
.tempdir
.path()
.join(&network_file)],
fsm_state_ledger_paths: vec![
self.tempdir.path().join(&fsm_file),
],
network_config_ledger_paths: vec![
self.tempdir.path().join(&network_file),
],
};

self.learner = Some(TestNode::new(config, self.log.clone()));
Expand Down
8 changes: 4 additions & 4 deletions bootstore/src/schemes/v0/peer_networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

//! Async networking used by peer.rs
use super::Msg as FsmMsg;
use super::messages::Identify;
use super::storage::NetworkConfig;
use super::Msg as FsmMsg;
use crate::schemes::Hello;
use bytes::Buf;
use derive_more::From;
use serde::{Deserialize, Serialize};
use sled_hardware_types::Baseboard;
use slog::{debug, error, info, o, warn, Logger};
use slog::{Logger, debug, error, info, o, warn};
use std::collections::VecDeque;
use std::io::Cursor;
use std::net::SocketAddrV6;
use std::time::Duration;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf};
use tokio::net::TcpStream;
use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf};
use tokio::sync::mpsc;
use tokio::task::JoinHandle;
use tokio::time::{interval, sleep, Instant, MissedTickBehavior};
use tokio::time::{Instant, MissedTickBehavior, interval, sleep};

const CONN_BUF_SIZE: usize = 512 * 1024;
const CONNECTION_RETRY_TIMEOUT: Duration = Duration::from_secs(1);
Expand Down
6 changes: 3 additions & 3 deletions bootstore/src/schemes/v0/share_pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

//! Distributable data packages containing key shares and metadata
use crate::trust_quorum::{RackSecret, TrustQuorumError};
use crate::Sha3_256Digest;
use chacha20poly1305::{aead::Aead, ChaCha20Poly1305, Key, KeyInit};
use crate::trust_quorum::{RackSecret, TrustQuorumError};
use chacha20poly1305::{ChaCha20Poly1305, Key, KeyInit, aead::Aead};
use hkdf::Hkdf;
use rand::{rngs::OsRng, RngCore};
use rand::{RngCore, rngs::OsRng};
use secrecy::{ExposeSecret, Secret};
use serde::{Deserialize, Serialize};
use sha3::{Digest, Sha3_256};
Expand Down
2 changes: 1 addition & 1 deletion bootstore/src/schemes/v0/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use camino::Utf8PathBuf;
use omicron_common::ledger::{Ledger, Ledgerable};
use serde::{Deserialize, Serialize};
use sled_hardware_types::Baseboard;
use slog::{info, Logger};
use slog::{Logger, info};

/// A persistent version of `Fsm::State`
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand Down
22 changes: 12 additions & 10 deletions bootstore/tests/v0-fsm-proptest-learner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ mod common;

use assert_matches::assert_matches;
use bootstore::schemes::v0::{
create_pkgs, ApiError, ApiOutput, Envelope, Fsm, FsmConfig,
LearnedSharePkg, Msg, MsgError, RackUuid, Request, RequestType, Response,
ResponseType, Share, SharePkg, State,
ApiError, ApiOutput, Envelope, Fsm, FsmConfig, LearnedSharePkg, Msg,
MsgError, RackUuid, Request, RequestType, Response, ResponseType, Share,
SharePkg, State, create_pkgs,
};
use bootstore::trust_quorum::RackSecret;
use common::CommonTestState;
Expand All @@ -24,8 +24,9 @@ use std::collections::{BTreeMap, BTreeSet};
use uuid::Uuid;

use common::generators::{
arb_action, arb_config, arb_initial_member_ids, arb_learner_id, Action,
MAX_ACTIONS, MAX_INITIAL_MEMBERS, MIN_INITIAL_MEMBERS, TICK_TIMEOUT,
Action, MAX_ACTIONS, MAX_INITIAL_MEMBERS, MIN_INITIAL_MEMBERS,
TICK_TIMEOUT, arb_action, arb_config, arb_initial_member_ids,
arb_learner_id,
};

/// Actions run during the learning phase of the test
Expand Down Expand Up @@ -237,11 +238,12 @@ impl TestState {
peer_id: Baseboard,
) -> Uuid {
self.common.connected_peers.insert(peer_id.clone());
assert!(self
.common
.sut
.on_connected(self.common.now, peer_id.clone())
.is_ok());
assert!(
self.common
.sut
.on_connected(self.common.now, peer_id.clone())
.is_ok()
);
let mut iter = self.common.sut.drain_envelopes();
let envelope = iter.next().unwrap();
assert_matches!(envelope,
Expand Down
12 changes: 7 additions & 5 deletions bootstore/tests/v0-fsm-proptest-rack-coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use std::collections::{BTreeMap, BTreeSet};
use uuid::Uuid;

use common::generators::{
arb_action, arb_config, arb_initial_member_ids, Action, MAX_ACTIONS,
MAX_INITIAL_MEMBERS, MIN_INITIAL_MEMBERS,
Action, MAX_ACTIONS, MAX_INITIAL_MEMBERS, MIN_INITIAL_MEMBERS, arb_action,
arb_config, arb_initial_member_ids,
};
use common::{CommonTestState, TestRequest};

Expand Down Expand Up @@ -360,9 +360,11 @@ impl TestState {
{
assert!(!test_req.acks.contains(&envelope.to));
} else {
assert!(!self.learn_requests[&request_id]
.acks
.contains(&envelope.to));
assert!(
!self.learn_requests[&request_id]
.acks
.contains(&envelope.to)
);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion certificates/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ pub enum CertificateError {
#[error("Error validating certificate hostname")]
ErrorValidatingHostname(#[source] openssl::error::ErrorStack),

#[error("Certificate not valid for given hostnames {hostname:?}: {cert_description}")]
#[error(
"Certificate not valid for given hostnames {hostname:?}: {cert_description}"
)]
NoDnsNameMatchingHostname { hostname: String, cert_description: String },

#[error("Unsupported certificate purpose (not usable for server auth)")]
Expand Down
2 changes: 1 addition & 1 deletion certificates/src/openssl_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use openssl::error::ErrorStack;
use openssl::nid::Nid;
use openssl::x509::X509Ref;
use openssl_sys::X509 as RawX509;
use std::ffi::CStr;
use std::ffi::c_char;
use std::ffi::c_int;
use std::ffi::c_uint;
use std::ffi::CStr;
use std::ptr;

extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion clickhouse-admin/src/bin/clickhouse-admin-keeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use anyhow::anyhow;
use camino::Utf8PathBuf;
use clap::Parser;
use omicron_clickhouse_admin::Config;
use omicron_common::cmd::fatal;
use omicron_common::cmd::CmdError;
use omicron_common::cmd::fatal;
use std::net::{SocketAddr, SocketAddrV6};

#[derive(Debug, Parser)]
Expand Down
2 changes: 1 addition & 1 deletion clickhouse-admin/src/bin/clickhouse-admin-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use anyhow::anyhow;
use camino::Utf8PathBuf;
use clap::Parser;
use omicron_clickhouse_admin::Config;
use omicron_common::cmd::fatal;
use omicron_common::cmd::CmdError;
use omicron_common::cmd::fatal;
use std::net::{SocketAddr, SocketAddrV6};

#[derive(Debug, Parser)]
Expand Down
2 changes: 1 addition & 1 deletion clickhouse-admin/src/bin/clickhouse-admin-single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use anyhow::anyhow;
use camino::Utf8PathBuf;
use clap::Parser;
use omicron_clickhouse_admin::Config;
use omicron_common::cmd::fatal;
use omicron_common::cmd::CmdError;
use omicron_common::cmd::fatal;
use std::net::{SocketAddr, SocketAddrV6};

#[derive(Debug, Parser)]
Expand Down
10 changes: 5 additions & 5 deletions clickhouse-admin/src/clickhouse_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use anyhow::Result;
use camino::Utf8PathBuf;
use clickhouse_admin_types::{
ClickhouseKeeperClusterMembership, DistributedDdlQueue, KeeperConf,
KeeperId, Lgif, RaftConfig, SystemTimeSeries, SystemTimeSeriesSettings,
OXIMETER_CLUSTER,
KeeperId, Lgif, OXIMETER_CLUSTER, RaftConfig, SystemTimeSeries,
SystemTimeSeriesSettings,
};
use dropshot::HttpError;
use illumos_utils::{output_to_exec_error, ExecutionError};
use slog::{debug, Logger};
use illumos_utils::{ExecutionError, output_to_exec_error};
use slog::{Logger, debug};
use slog_error_chain::{InlineErrorChain, SlogInlineError};
use std::collections::BTreeSet;
use std::ffi::OsStr;
Expand Down Expand Up @@ -234,7 +234,7 @@ impl ClickhouseCli {
Err(e) => {
return Err(ClickhouseCliError::ServerUnavailable(format!(
"command timed out after {elapsed:?}: {e}"
)))
)));
}
};

Expand Down
15 changes: 7 additions & 8 deletions clickhouse-admin/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use crate::{ClickhouseCli, Clickward};

use anyhow::{anyhow, bail, Context, Result};
use anyhow::{Context, Result, anyhow, bail};
use camino::Utf8PathBuf;
use clickhouse_admin_types::{
CLICKHOUSE_KEEPER_CONFIG_DIR, CLICKHOUSE_KEEPER_CONFIG_FILE,
CLICKHOUSE_SERVER_CONFIG_DIR, CLICKHOUSE_SERVER_CONFIG_FILE,
GenerateConfigResult, KeeperConfigurableSettings,
ServerConfigurableSettings, CLICKHOUSE_KEEPER_CONFIG_DIR,
CLICKHOUSE_KEEPER_CONFIG_FILE, CLICKHOUSE_SERVER_CONFIG_DIR,
CLICKHOUSE_SERVER_CONFIG_FILE,
ServerConfigurableSettings,
};
use dropshot::{ClientErrorStatusCode, HttpError};
use flume::{Receiver, Sender, TrySendError};
Expand Down Expand Up @@ -342,9 +342,8 @@ fn generate_config_and_enable_svc(
ClientErrorStatusCode::CONFLICT,
format!(
"current generation '{}' is greater than incoming generation '{}'",
current,
incoming_generation,
)
current, incoming_generation,
),
));
}
};
Expand Down Expand Up @@ -573,7 +572,7 @@ mod tests {

assert_eq!(
format!("{}", root_cause),
"first line of configuration file 'types/testutils/malformed_3.xml' is malformed: <!-- generation:2 --> -->"
"first line of configuration file 'types/testutils/malformed_3.xml' is malformed: <!-- generation:2 --> -->"
);
}
}
4 changes: 2 additions & 2 deletions clickhouse-admin/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl ClickhouseAdminServerApi for ClickhouseAdminServerImpl {
Some(String::from("ObjectNotFound")),
ClientErrorStatusCode::NOT_FOUND,
"no generation number found".to_string(),
))
));
}
};
Ok(HttpResponseOk(gen))
Expand Down Expand Up @@ -127,7 +127,7 @@ impl ClickhouseAdminKeeperApi for ClickhouseAdminKeeperImpl {
Some(String::from("ObjectNotFound")),
ClientErrorStatusCode::NOT_FOUND,
"no generation number found".to_string(),
))
));
}
};
Ok(HttpResponseOk(gen))
Expand Down
2 changes: 1 addition & 1 deletion clickhouse-admin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use camino::Utf8PathBuf;
use context::{KeeperServerContext, ServerContext};
use dropshot::HttpServer;
use omicron_common::FileKv;
use slog::{debug, error, Drain};
use slog::{Drain, debug, error};
use slog_dtrace::ProbeRegistration;
use slog_error_chain::SlogInlineError;
use std::io;
Expand Down
Loading

0 comments on commit 3f1a941

Please sign in to comment.