From 503ad20b27ae4e5abaeefe8390f2c122e97b87b5 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Thu, 25 Apr 2024 11:43:59 -0700 Subject: [PATCH] clippy cleanliness/unused methods --- nexus/src/app/instance_network.rs | 71 +++---------------------------- nexus/src/app/oximeter.rs | 53 ----------------------- nexus/src/app/switch_port.rs | 7 --- 3 files changed, 6 insertions(+), 125 deletions(-) diff --git a/nexus/src/app/instance_network.rs b/nexus/src/app/instance_network.rs index ad855a4bdc..de8a205a0d 100644 --- a/nexus/src/app/instance_network.rs +++ b/nexus/src/app/instance_network.rs @@ -211,35 +211,13 @@ impl super::Nexus { opctx: &OpContext, nat_entry: &Ipv4NatEntry, ) -> Result<(), Error> { - let log = &self.log; - - info!(log, "deleting individual NAT entry from dpd configuration"; - "id" => ?nat_entry.id, - "version_added" => %nat_entry.external_address.0); - - match self.db_datastore.ipv4_nat_delete(&opctx, nat_entry).await { - Ok(_) => {} - Err(err) => match err { - Error::ObjectNotFound { .. } => { - warn!(log, "no matching nat entries to soft delete"); - } - _ => { - let message = format!( - "failed to delete nat entry due to error: {err:?}" - ); - error!(log, "{}", message); - return Err(Error::internal_error(&message)); - } - }, - } - - notify_dendrite_nat_state( + delete_dpd_config_by_entry( &self.db_datastore, - log, &self.resolver().await, + &self.log, + opctx, &self.opctx_alloc, - None, - false, + nat_entry, ) .await } @@ -263,45 +241,6 @@ impl super::Nexus { ) .await } - - /// Given old and new instance runtime states, determines the desired - /// networking configuration for a given instance and ensures it has been - /// propagated to all relevant sleds. - /// - /// # Arguments - /// - /// - opctx: An operation context for this operation. - /// - authz_instance: A resolved authorization context for the instance of - /// interest. - /// - prev_instance_state: The most-recently-recorded instance runtime - /// state for this instance. - /// - new_instance_state: The instance state that the caller of this routine - /// has observed and that should be used to set up this instance's - /// networking state. - /// - /// # Return value - /// - /// `Ok(())` if this routine completed all the operations it wanted to - /// complete, or an appropriate `Err` otherwise. - pub(crate) async fn ensure_updated_instance_network_config( - &self, - opctx: &OpContext, - authz_instance: &authz::Instance, - prev_instance_state: &db::model::InstanceRuntimeState, - new_instance_state: &nexus::InstanceRuntimeState, - ) -> Result<(), Error> { - ensure_updated_instance_network_config( - &self.db_datastore, - &self.log, - &self.resolver().await, - opctx, - &self.opctx_alloc, - authz_instance, - prev_instance_state, - new_instance_state, - ) - .await - } } /// Returns the set of switches with uplinks configured and boundary @@ -353,6 +292,7 @@ pub(crate) async fn boundary_switches( /// /// `Ok(())` if this routine completed all the operations it wanted to /// complete, or an appropriate `Err` otherwise. +#[allow(clippy::too_many_arguments)] // Yeah, I know, I know, Clippy... pub(crate) async fn ensure_updated_instance_network_config( datastore: &DataStore, log: &slog::Logger, @@ -529,6 +469,7 @@ pub(crate) async fn ensure_updated_instance_network_config( /// - If this is `None`, this routine configures DPD for all external /// IPs and *will back out* if any IPs are not yet fully attached to /// the instance. +#[allow(clippy::too_many_arguments)] // I don't like it either, clippy... pub(crate) async fn instance_ensure_dpd_config( datastore: &DataStore, log: &slog::Logger, diff --git a/nexus/src/app/oximeter.rs b/nexus/src/app/oximeter.rs index 1c828ddb2e..92ea3c0a0d 100644 --- a/nexus/src/app/oximeter.rs +++ b/nexus/src/app/oximeter.rs @@ -163,59 +163,6 @@ impl super::Nexus { Ok(()) } - /// Idempotently un-assign a producer from an oximeter collector. - pub(crate) async fn unassign_producer( - &self, - opctx: &OpContext, - id: &Uuid, - ) -> Result<(), Error> { - if let Some(collector_id) = - self.db_datastore.producer_endpoint_delete(opctx, id).await? - { - debug!( - self.log, - "deleted metric producer assignment"; - "producer_id" => %id, - "collector_id" => %collector_id, - ); - let oximeter_info = - self.db_datastore.oximeter_lookup(opctx, &collector_id).await?; - let address = - SocketAddr::new(oximeter_info.ip.ip(), *oximeter_info.port); - let client = build_oximeter_client(&self.log, &id, address); - if let Err(e) = client.producer_delete(&id).await { - error!( - self.log, - "failed to delete producer from collector"; - "producer_id" => %id, - "collector_id" => %collector_id, - "address" => %address, - "error" => ?e, - ); - return Err(Error::internal_error( - format!("failed to delete producer from collector: {e:?}") - .as_str(), - )); - } else { - debug!( - self.log, - "successfully deleted producer from collector"; - "producer_id" => %id, - "collector_id" => %collector_id, - "address" => %address, - ); - Ok(()) - } - } else { - trace!( - self.log, - "un-assigned non-existent metric producer"; - "producer_id" => %id, - ); - Ok(()) - } - } - /// Returns a results from the timeseries DB based on the provided query /// parameters. /// diff --git a/nexus/src/app/switch_port.rs b/nexus/src/app/switch_port.rs index c04ebe7d41..e0c303f277 100644 --- a/nexus/src/app/switch_port.rs +++ b/nexus/src/app/switch_port.rs @@ -169,13 +169,6 @@ impl super::Nexus { self.db_datastore.switch_port_list(opctx, pagparams).await } - pub(crate) async fn list_switch_ports_with_uplinks( - &self, - opctx: &OpContext, - ) -> ListResultVec { - list_switch_ports_with_uplinks(&self.db_datastore, opctx).await - } - pub(crate) async fn set_switch_port_settings_id( &self, opctx: &OpContext,