Skip to content
Open
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
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ members = [
]
resolver = "2"

[workspace.lints.clippy]
too_many_arguments = "allow"
wrong_self_convention = "allow"

[workspace.dependencies]
ansi-to-html = { version = "0.2", features = [ "lazy-init" ] }
anyhow = "1"
Expand Down
10 changes: 5 additions & 5 deletions agent/src/control/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ async fn cmd_address_list(mut l: Level<Stuff>) -> Result<()> {
let mut r = Row::default();

r.add_str("name", &addr.name);
r.add_str("cidr", &net.to_string());
r.add_str("first", &first.to_string());
r.add_str("last", &last.to_string());
r.add_str("cidr", net.to_string());
r.add_str("first", first.to_string());
r.add_str("last", last.to_string());
r.add_u64("count", addr.count.into());
r.add_str("family", "inet");
r.add_str("network", &net.network().to_string());
r.add_str("mask", &net.netmask().to_string());
r.add_str("network", net.network().to_string());
r.add_str("mask", net.netmask().to_string());
r.add_str("routed", if addr.routed { "yes" } else { "no" });
r.add_str("gateway", addr.gateway.as_deref().unwrap_or("-"));

Expand Down
9 changes: 3 additions & 6 deletions agent/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ fn spawn_reader<T>(
where
T: Read + Send + 'static,
{
let stream = match stream {
Some(stream) => stream,
None => return None,
};
let stream = stream?;

Some(std::thread::spawn(move || {
let mut r = BufReader::new(stream);
Expand Down Expand Up @@ -297,7 +294,7 @@ fn run_common(
* process.
*/
if ab.bgproc.is_none() {
tx.blocking_send(ab.exit(&start, &end, std::i32::MAX))
tx.blocking_send(ab.exit(&start, &end, i32::MAX))
.unwrap();
}

Expand Down Expand Up @@ -332,7 +329,7 @@ fn run_common(
let code = if let Some(code) = es.code() {
code
} else {
std::i32::MAX
i32::MAX
};
tx.blocking_send(ab.exit(&start, &end, code)).unwrap();
stdio_warning
Expand Down
2 changes: 1 addition & 1 deletion agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ async fn cmd_install(mut l: Level<Agent>) -> Result<()> {
let status = Command::new("/sbin/zfs")
.arg("create")
.arg("-o")
.arg(&format!("mountpoint={}", INPUT_PATH))
.arg(format!("mountpoint={INPUT_PATH}"))
.arg(INPUT_DATASET)
.env_clear()
.current_dir("/")
Expand Down
8 changes: 4 additions & 4 deletions bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ mod config;

trait FlagsExt {
#[must_use]
fn add_flags(&mut self, name: &'static str) -> Flags;
fn add_flags(&mut self, name: &'static str) -> Flags<'_>;
}

impl FlagsExt for Row {
fn add_flags(&mut self, name: &'static str) -> Flags {
fn add_flags(&mut self, name: &'static str) -> Flags<'_> {
Flags { row: self, name, out: String::new() }
}
}
Expand Down Expand Up @@ -1226,7 +1226,7 @@ async fn do_job_store_list(mut l: Level<Stuff>) -> Result<()> {
);
r.add_str(
"updated",
&ent.time_update.to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
ent.time_update.to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
);

t.add_row(r);
Expand Down Expand Up @@ -1351,7 +1351,7 @@ async fn do_user_list(mut l: Level<Stuff>) -> Result<()> {
r.add_str("name", &u.name);
r.add_str(
"creation",
&u.time_create.to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
u.time_create.to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
);
r.add_age("age", u.time_create.age());
t.add_row(r);
Expand Down
3 changes: 3 additions & 0 deletions download/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.0.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[lib]
doctest = false

Expand Down
2 changes: 1 addition & 1 deletion download/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn make_get_response<E>(
rx: mpsc::Receiver<std::result::Result<Frame<Bytes>, E>>,
) -> Result<Response<Body>>
where
E: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>
E: Into<Box<dyn std::error::Error + Send + Sync + 'static>>
+ Send
+ Sync
+ 'static,
Expand Down
9 changes: 4 additions & 5 deletions factory/aws/src/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Instance {
.try_into()
.unwrap();

(if when <= now { now - when } else { 0 }) / 1000
now.saturating_sub(when) / 1000
})
.unwrap_or(0)
}
Expand Down Expand Up @@ -188,7 +188,7 @@ async fn create_instance(

let mut instances = res
.instances()
.into_iter()
.iter()
.map(|i| Instance::from((i, config.aws.tag.as_str())))
.collect::<Vec<_>>();

Expand Down Expand Up @@ -218,13 +218,12 @@ async fn instances(
Ok(res
.reservations()
.iter()
.map(|r| {
.flat_map(|r| {
r.instances().iter().map(|i| {
let i = Instance::from((i, tag));
(i.id.to_string(), i)
})
})
.flatten()
.collect())
}

Expand Down Expand Up @@ -421,7 +420,7 @@ async fn aws_worker_one(
* There is a record of a particular instance ID for this worker.
* Check to see if that instance exists.
*/
if let Some(i) = insts.get(&instance_id.to_string()) {
if let Some(i) = insts.get(instance_id) {
if i.state == "terminated" {
/*
* The instance exists, but is terminated. Delete the
Expand Down
2 changes: 1 addition & 1 deletion factory/aws/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Central {
* Allow the per-target diagnostic configuration to override the base
* diagnostic configuration.
*/
Ok(self.config.diag.apply_overrides(&t.diag).build()?)
self.config.diag.apply_overrides(&t.diag).build()
}
}

Expand Down
3 changes: 3 additions & 0 deletions factory/gimlet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.0.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
buildomat-common = { path = "../../common" }
buildomat-database = { path = "../../database" }
Expand Down
16 changes: 8 additions & 8 deletions factory/gimlet/src/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn setup() -> Result<()> {
bail!("giving up after {MAX_TIME} seconds");
}

if let Ok(st) = svcs(&fmri) {
if let Ok(st) = svcs(fmri) {
if st.next.is_none() && st.current == "ON" {
println!(" * {fmri} now online!");
break;
Expand All @@ -125,7 +125,7 @@ pub fn setup() -> Result<()> {
* only be one!
*/
let pools = zpool_unimported_list()?;
if pools.len() == 0 {
if pools.is_empty() {
bail!("no unimported pool found!");
} else if pools.len() > 1 {
bail!("more than one unimported pool found!");
Expand All @@ -137,14 +137,14 @@ pub fn setup() -> Result<()> {
};

println!(" * importing pool {pool:?}...");
zpool_import(&pool)?;
zpool_import(pool)?;

/*
* Update the BSU symlink:
*/
std::fs::create_dir_all("/pool/bsu")?;
std::fs::remove_file("/pool/bsu/0").ok();
std::os::unix::fs::symlink(&format!("../int/{pool_id}"), "/pool/bsu/0")?;
std::os::unix::fs::symlink(format!("../int/{pool_id}"), "/pool/bsu/0")?;

/*
* Create the swap device:
Expand Down Expand Up @@ -252,14 +252,14 @@ fn prepare_m2() -> Result<()> {
let p = &mut vtoc.parts_mut()[i];
p.p_tag = efi::sys::V_USR;
p.p_start = next_start;
p.p_size = size.into();
p.p_size = size;
next_start = next_start.checked_add(size).unwrap();
}

/*
* Create the dump slice:
*/
let size = (1 * 1024 * 1024 * 1024 * 1024) / vtoc.block_size();
let size = (1024 * 1024 * 1024 * 1024) / vtoc.block_size();
let p = &mut vtoc.parts_mut()[4];
p.p_tag = efi::sys::V_USR;
p.p_start = next_start;
Expand Down Expand Up @@ -287,11 +287,11 @@ fn prepare_m2() -> Result<()> {
.env_clear()
.arg("create")
.arg("-O")
.arg(&format!("mountpoint=/pool/int/{id}"))
.arg(format!("mountpoint=/pool/int/{id}"))
.arg("-O")
.arg("compress=on")
.arg(&pool)
.arg(&format!("{}s5", d.name))
.arg(format!("{}s5", d.name))
.output()?;

if !out.status.success() {
Expand Down
8 changes: 4 additions & 4 deletions factory/gimlet/src/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub fn list_disks() -> Result<Disks> {
slice: u32|
-> Result<Option<devinfo::DevLink>> {
let mut paths = links
.links_for_path(&device)?
.links_for_path(device)?
.into_iter()
.filter(|l| {
l.linktype() == devinfo::DevLinkType::Primary
Expand Down Expand Up @@ -193,18 +193,18 @@ pub fn list_disks() -> Result<Disks> {
*/
let device = m.devfs_path()?;

Ok((0..=8)
(0..=8)
.map(|num| {
Ok(slice_from_path(&device, num)?.map(|link| {
(num, m.spec_type(), link.path().to_owned())
}))
})
.collect::<Result<Vec<_>>>()?)
.collect::<Result<Vec<_>>>()
})
.collect::<Result<Vec<_>>>()?
.into_iter()
.flatten()
.filter_map(|v| v)
.flatten()
.collect::<Vec<_>>();

/*
Expand Down
10 changes: 5 additions & 5 deletions factory/gimlet/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ impl HostManager {
Ok(())
}
HostState::Cleaning(cst) => {
let mut new_cst = cst.clone();
let mut new_cst = *cst;

{
let mut l = self.locked.lock().unwrap();
Expand Down Expand Up @@ -700,7 +700,7 @@ impl HostManager {
Ok(())
}
HostState::Starting(sst, hgs) => {
let mut new_sst = sst.clone();
let mut new_sst = *sst;

{
let mut l = self.locked.lock().unwrap();
Expand All @@ -726,7 +726,7 @@ impl HostManager {
}
}

if let Err(e) = self.thread_starting(&mut new_sst, &hgs) {
if let Err(e) = self.thread_starting(&mut new_sst, hgs) {
error!(log, "starting error: {e}");
}

Expand Down Expand Up @@ -794,7 +794,7 @@ impl HostManager {

let pb = sys
.ssh_exec("svcs -Ho sta,nsta svc:/site/postboot:default")?;
let t = pb.out.trim().split_whitespace().collect::<Vec<_>>();
let t = pb.out.split_whitespace().collect::<Vec<_>>();
if t.len() != 2 || t[0] == "ON" || t[1] == "-" {
bail!("postboot not ready: {t:?}");
}
Expand Down Expand Up @@ -847,7 +847,7 @@ impl HostManager {

let pb = sys
.ssh_exec("svcs -Ho sta,nsta svc:/site/postboot:default")?;
let t = pb.out.trim().split_whitespace().collect::<Vec<_>>();
let t = pb.out.split_whitespace().collect::<Vec<_>>();
if t.len() != 2 || t[0] == "ON" || t[1] == "-" {
bail!("postboot not ready: {t:?}");
}
Expand Down
2 changes: 1 addition & 1 deletion factory/gimlet/src/humility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl ValueExt for Value {
bail!("expected a hex number, got {t:?}");
};

out.push(u8::from_str_radix(&hex, 16)?);
out.push(u8::from_str_radix(hex, 16)?);
}
_ => bail!("list should only contain terms"),
}
Expand Down
2 changes: 1 addition & 1 deletion factory/gimlet/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async fn instance_worker_start(
}
instances_with_workers.insert(id.clone());

let c = Arc::clone(&c);
let c = Arc::clone(c);
let log = log.new(o!(
"component" => "instance_worker",
"instance" => id.to_string(),
Expand Down
2 changes: 2 additions & 0 deletions factory/lab/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright 2023 Oxide Computer Company
*/

#![allow(dead_code)]

use std::{
collections::HashMap,
sync::{Arc, Mutex},
Expand Down
4 changes: 2 additions & 2 deletions factory/lab/src/minder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl FormatScript {
.replace("%BASEURL%", &self.host_config.lab_baseurl)
.replace("%HOST%", &self.host_config.nodename)
.replace("%CONSOLE%", &self.host_config.console)
.replace("%BOOTARGS%", &bootargs)
.replace("%BOOTARGS%", bootargs)
.replace("%COREURL%", &self.coreurl);

if let Some(key) = self.key.as_deref() {
Expand Down Expand Up @@ -149,7 +149,7 @@ impl CentralExt for Central {
&self,
name: &str,
) -> HResult<&super::config::ConfigFileHost> {
if let Some(h) = self.hosts.get(&name.to_string()) {
if let Some(h) = self.hosts.get(name) {
Ok(&h.config)
} else {
Err(dropshot::HttpError::for_client_error(
Expand Down
2 changes: 1 addition & 1 deletion factory/propolis/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl ConfigFile {
&self,
slot: u32,
id: &InstanceId,
) -> Result<InstanceInSlot> {
) -> Result<InstanceInSlot<'_>> {
Ok(InstanceInSlot { config: self, slot, id: id.clone() })
}

Expand Down
2 changes: 1 addition & 1 deletion factory/propolis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Central {
* Allow the per-target diagnostic configuration to override the base
* diagnostic configuration.
*/
Ok(self.config.diag.apply_overrides(&t.diag).build()?)
self.config.diag.apply_overrides(&t.diag).build()
}
}

Expand Down
4 changes: 2 additions & 2 deletions factory/propolis/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ async fn instance_worker_one(
include_str!("../smf/serial.xml"),
),
] {
std::fs::write(&vmdir.join(&format!("{name}.sh")), script)?;
std::fs::write(&smfdir.join(format!("{name}.xml")), bundle)?;
std::fs::write(vmdir.join(format!("{name}.sh")), script)?;
std::fs::write(smfdir.join(format!("{name}.xml")), bundle)?;
}

std::fs::write(&siteprofile, include_str!("../smf/site.xml"))?;
Expand Down
Loading