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
11 changes: 8 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,16 @@ impl ByteCount {

impl Display for ByteCount {
fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult {
if self.to_bytes() >= TiB && self.to_bytes() % TiB == 0 {
if self.to_bytes() >= TiB && self.to_bytes().is_multiple_of(TiB) {
write!(f, "{} TiB", self.to_whole_tebibytes())
} else if self.to_bytes() >= GiB && self.to_bytes() % GiB == 0 {
} else if self.to_bytes() >= GiB && self.to_bytes().is_multiple_of(GiB)
{
write!(f, "{} GiB", self.to_whole_gibibytes())
} else if self.to_bytes() >= MiB && self.to_bytes() % MiB == 0 {
} else if self.to_bytes() >= MiB && self.to_bytes().is_multiple_of(MiB)
{
write!(f, "{} MiB", self.to_whole_mebibytes())
} else if self.to_bytes() >= KiB && self.to_bytes() % KiB == 0 {
} else if self.to_bytes() >= KiB && self.to_bytes().is_multiple_of(KiB)
{
write!(f, "{} KiB", self.to_whole_kibibytes())
} else {
write!(f, "{} B", self.to_bytes())
Expand Down
2 changes: 1 addition & 1 deletion common/src/api/internal/shared/external_ip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<T: Ip> SourceNatConfig<T> {
first_port: u16,
last_port: u16,
) -> Result<Self, SourceNatConfigError> {
if first_port % NUM_SOURCE_NAT_PORTS == 0
if first_port.is_multiple_of(NUM_SOURCE_NAT_PORTS)
&& last_port
.checked_sub(first_port)
.and_then(|diff| diff.checked_add(1))
Expand Down
2 changes: 1 addition & 1 deletion common/src/api/internal/shared/external_ip/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl SourceNatConfig {
first_port: u16,
last_port: u16,
) -> Result<Self, SourceNatConfigError> {
if first_port % NUM_SOURCE_NAT_PORTS == 0
if first_port.is_multiple_of(NUM_SOURCE_NAT_PORTS)
&& last_port
.checked_sub(first_port)
.and_then(|diff| diff.checked_add(1))
Expand Down
2 changes: 1 addition & 1 deletion illumos-utils/src/vmm_reservoir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ pub fn align_reservoir_size(size_bytes: u64) -> u64 {
}

pub fn reservoir_size_is_aligned(size_bytes: u64) -> bool {
(size_bytes % RESERVOIR_SZ_ALIGN) == 0
size_bytes.is_multiple_of(RESERVOIR_SZ_ALIGN)
}
2 changes: 1 addition & 1 deletion installinator/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ impl WriteTransport for BlockDeviceTransport {
// When writing to a block device, we must write a multiple of the block
// size. We can assume the image we're given should be
// appropriately-sized: return an error here if it is not.
if total_bytes % block_size != 0 {
if !total_bytes.is_multiple_of(block_size) {
return Err(WriteError::WriteError {
component,
slot,
Expand Down
20 changes: 0 additions & 20 deletions nexus/db-queries/src/db/datastore/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,9 @@ use omicron_uuid_kinds::GenericUuid as _;
use omicron_uuid_kinds::ProbeUuid;
use omicron_uuid_kinds::SledUuid;
use ref_cast::RefCast;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use sled_agent_client::types::ProbeCreate;
use uuid::Uuid;

#[derive(Debug, Clone, JsonSchema, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum IpKind {
Snat,
Floating,
Ephemeral,
}

impl From<nexus_db_model::IpKind> for IpKind {
fn from(value: nexus_db_model::IpKind) -> Self {
match value {
nexus_db_model::IpKind::SNat => Self::Snat,
nexus_db_model::IpKind::Ephemeral => Self::Ephemeral,
nexus_db_model::IpKind::Floating => Self::Floating,
}
}
}

impl super::DataStore {
/// List the probes for the given project.
pub async fn probe_list(
Expand Down
10 changes: 2 additions & 8 deletions nexus/db-queries/src/db/datastore/switch_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::db::model::{
LldpLinkConfig, Name, SwitchInterfaceConfig, SwitchLinkFec,
SwitchLinkSpeed, SwitchPort, SwitchPortAddressConfig,
SwitchPortBgpPeerConfig, SwitchPortConfig, SwitchPortLinkConfig,
SwitchPortRouteConfig, SwitchPortSettings, SwitchPortSettingsGroup,
SwitchPortSettingsGroups, SwitchVlanInterfaceConfig, TxEqConfig,
SwitchPortRouteConfig, SwitchPortSettings, SwitchPortSettingsGroups,
SwitchVlanInterfaceConfig, TxEqConfig,
};
use crate::db::pagination::paginated;
use async_bb8_diesel::{AsyncRunQueryDsl, Connection};
Expand Down Expand Up @@ -149,12 +149,6 @@ impl Into<external::SwitchPortSettings> for SwitchPortSettingsCombinedResult {
}
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SwitchPortSettingsGroupCreateResult {
pub group: SwitchPortSettingsGroup,
pub settings: SwitchPortSettingsCombinedResult,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct LinkConfigCombinedResult {
pub port_settings_id: Uuid,
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/datastore/vpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl DataStore {
}
Err(e) => return Err(e),
Ok(None) => {
crate::probes::vni__search__range__empty!(|| (&id));
crate::probes::vni__search__range__empty!(|| &id);
debug!(
opctx.log,
"No VNIs available within current search range, retrying";
Expand Down
1 change: 0 additions & 1 deletion nexus/mgs-updates/src/common_sp_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use nexus_types::deployment::PendingMgsUpdate;
use nexus_types::deployment::PendingMgsUpdateDetails;
use nexus_types::inventory::SpType;
use omicron_common::disk::M2Slot;
use slog::error;
use std::net::SocketAddrV6;
use std::time::Duration;
use thiserror::Error;
Expand Down
5 changes: 5 additions & 0 deletions nexus/networking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ license = "MPL-2.0"
[lints]
workspace = true

[build-dependencies]
omicron-rpaths.workspace = true

[dependencies]
futures.workspace = true
ipnetwork.workspace = true
Expand All @@ -20,3 +23,5 @@ slog.workspace = true
uuid.workspace = true
omicron-workspace-hack.workspace = true
omicron-uuid-kinds.workspace = true
# See omicron-rpaths for more about the "pq-sys" dependency.
pq-sys = "*"
10 changes: 10 additions & 0 deletions nexus/networking/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// See omicron-rpaths for documentation.
// NOTE: This file MUST be kept in sync with the other build.rs files in this
// repository.
fn main() {
omicron_rpaths::configure_default_omicron_rpaths();
}
5 changes: 5 additions & 0 deletions nexus/reconfigurator/preparation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition.workspace = true
[lints]
workspace = true

[build-dependencies]
omicron-rpaths.workspace = true

[dependencies]
anyhow.workspace = true
futures.workspace = true
Expand All @@ -14,6 +17,8 @@ nexus-db-queries.workspace = true
nexus-types.workspace = true
omicron-common.workspace = true
omicron-uuid-kinds.workspace = true
# See omicron-rpaths for more about the "pq-sys" dependency.
pq-sys = "*"
slog.workspace = true
slog-error-chain.workspace = true

Expand Down
10 changes: 10 additions & 0 deletions nexus/reconfigurator/preparation/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// See omicron-rpaths for documentation.
// NOTE: This file MUST be kept in sync with the other build.rs files in this
// repository.
fn main() {
omicron_rpaths::configure_default_omicron_rpaths();
}
8 changes: 6 additions & 2 deletions nexus/src/app/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl super::Nexus {

// Reject disks where the block size doesn't evenly divide the
// total size
if (params.size.to_bytes() % block_size) != 0 {
if !params.size.to_bytes().is_multiple_of(block_size) {
return Err(Error::invalid_value(
"size and block_size",
format!(
Expand All @@ -199,7 +199,11 @@ impl super::Nexus {

// Reject disks where the MIN_DISK_SIZE_BYTES doesn't evenly
// divide the size
if (params.size.to_bytes() % u64::from(MIN_DISK_SIZE_BYTES)) != 0 {
if !params
.size
.to_bytes()
.is_multiple_of(u64::from(MIN_DISK_SIZE_BYTES))
{
return Err(Error::invalid_value(
"size",
format!(
Expand Down
5 changes: 4 additions & 1 deletion nexus/src/app/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,10 @@ fn check_instance_cpu_memory_sizes(

// Reject instances where the memory is not divisible by
// MIN_MEMORY_BYTES_PER_INSTANCE
if (memory.to_bytes() % u64::from(MIN_MEMORY_BYTES_PER_INSTANCE)) != 0 {
if !memory
.to_bytes()
.is_multiple_of(u64::from(MIN_MEMORY_BYTES_PER_INSTANCE))
{
return Err(Error::invalid_value(
"size",
format!(
Expand Down
5 changes: 2 additions & 3 deletions nexus/src/app/sagas/disk_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,15 +603,14 @@ async fn sdc_regions_ensure(

// Each ID should be unique to this disk
if let Some(read_only_parent) = &mut read_only_parent {
*read_only_parent = Box::new(
**read_only_parent =
randomize_volume_construction_request_ids(&read_only_parent)
.map_err(|e| {
ActionError::action_failed(Error::internal_error(&format!(
"failed to randomize ids: {}",
e,
)))
})?,
);
})?;
}

// Create volume construction request for this disk
Expand Down
18 changes: 1 addition & 17 deletions nexus/src/app/sagas/instance_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ use omicron_common::api::external::NameOrId;
use omicron_common::api::external::{Error, InternalContext};
use omicron_common::api::internal::shared::SwitchLocation;
use omicron_uuid_kinds::{
AffinityGroupUuid, AntiAffinityGroupUuid, GenericUuid, InstanceUuid,
MulticastGroupUuid,
AntiAffinityGroupUuid, GenericUuid, InstanceUuid, MulticastGroupUuid,
};
use ref_cast::RefCast;
use serde::Deserialize;
Expand Down Expand Up @@ -61,28 +60,13 @@ struct NetParams {
new_id: Uuid,
}

#[derive(Debug, Deserialize, Serialize)]
struct AffinityParams {
serialized_authn: authn::saga::Serialized,
instance_id: InstanceUuid,
group: AffinityGroupUuid,
}

#[derive(Debug, Deserialize, Serialize)]
struct AntiAffinityParams {
serialized_authn: authn::saga::Serialized,
instance_id: InstanceUuid,
group: AntiAffinityGroupUuid,
}

#[derive(Debug, Deserialize, Serialize)]
struct NetworkConfigParams {
saga_params: Params,
instance_id: InstanceUuid,
which: usize,
switch_location: SwitchLocation,
}

#[derive(Debug, Deserialize, Serialize)]
struct DiskAttachParams {
serialized_authn: authn::saga::Serialized,
Expand Down
4 changes: 2 additions & 2 deletions nexus/src/app/sagas/region_replacement_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ pub(crate) mod test {
async fn test_find_only_new_region(cptestctx: &ControlPlaneTestContext) {
let log = &cptestctx.logctx.log;

let datasets = vec![
let datasets = [
CrucibleDataset::new(
DatasetUuid::new_v4(),
ZpoolUuid::new_v4(),
Expand All @@ -921,7 +921,7 @@ pub(crate) mod test {
),
];

let regions = vec![
let regions = [
Region::new(
datasets[0].id(),
VolumeUuid::new_v4(),
Expand Down
5 changes: 5 additions & 0 deletions nexus/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ license = "MPL-2.0"
[lints]
workspace = true

[build-dependencies]
omicron-rpaths.workspace = true

[dependencies]
anyhow.workspace = true
bytes.workspace = true
Expand Down Expand Up @@ -47,6 +50,8 @@ oximeter.workspace = true
oximeter-collector.workspace = true
oximeter-producer.workspace = true
oxnet.workspace = true
# See omicron-rpaths for more about the "pq-sys" dependency.
pq-sys = "*"
pretty_assertions.workspace = true
serde.workspace = true
serde_json.workspace = true
Expand Down
10 changes: 10 additions & 0 deletions nexus/test-utils/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// See omicron-rpaths for documentation.
// NOTE: This file MUST be kept in sync with the other build.rs files in this
// repository.
fn main() {
omicron_rpaths::configure_default_omicron_rpaths();
}
2 changes: 1 addition & 1 deletion nexus/test-utils/src/starter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ impl oximeter::Producer for IntegrationProducer {
fn produce(
&mut self,
) -> Result<
Box<(dyn Iterator<Item = oximeter::types::Sample> + 'static)>,
Box<dyn Iterator<Item = oximeter::types::Sample> + 'static>,
oximeter::MetricsError,
> {
use oximeter::Metric;
Expand Down
Loading
Loading