mirror of
https://github.com/neondatabase/neon.git
synced 2026-10-30 15:27:26 +00:00
apply clippy fixes for 1.88.0 beta (#12331)
The 1.88.0 stable release is near (this Thursday). We'd like to fix most warnings beforehand so that the compiler upgrade doesn't require approval from too many teams. This is therefore a preparation PR (like similar PRs before it). There is a lot of changes for this release, mostly because the `uninlined_format_args` lint has been added to the `style` lint group. One can read more about the lint [here](https://rust-lang.github.io/rust-clippy/master/#/uninlined_format_args). The PR is the result of `cargo +beta clippy --fix` and `cargo fmt`. One remaining warning is left for the proxy team. --------- Co-authored-by: Conrad Ludgate <conrad@neon.tech>
This commit is contained in:
co-authored by
Conrad Ludgate
parent
a29772bf6e
commit
552249607d
@@ -370,7 +370,7 @@ impl ComputeHook {
|
||||
let authorization_header = config
|
||||
.control_plane_jwt_token
|
||||
.clone()
|
||||
.map(|jwt| format!("Bearer {}", jwt));
|
||||
.map(|jwt| format!("Bearer {jwt}"));
|
||||
|
||||
let mut client = reqwest::ClientBuilder::new().timeout(NOTIFY_REQUEST_TIMEOUT);
|
||||
for cert in &config.ssl_ca_certs {
|
||||
|
||||
@@ -62,7 +62,7 @@ pub(crate) fn validate_node_state(
|
||||
nodes: Arc<HashMap<NodeId, Node>>,
|
||||
) -> Result<(), OperationError> {
|
||||
let node = nodes.get(node_id).ok_or(OperationError::NodeStateChanged(
|
||||
format!("node {} was removed", node_id).into(),
|
||||
format!("node {node_id} was removed").into(),
|
||||
))?;
|
||||
|
||||
let current_policy = node.get_scheduling();
|
||||
@@ -70,7 +70,7 @@ pub(crate) fn validate_node_state(
|
||||
// TODO(vlad): maybe cancel pending reconciles before erroring out. need to think
|
||||
// about it
|
||||
return Err(OperationError::NodeStateChanged(
|
||||
format!("node {} changed state to {:?}", node_id, current_policy).into(),
|
||||
format!("node {node_id} changed state to {current_policy:?}").into(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ impl TenantShardDrain {
|
||||
|
||||
if !nodes.contains_key(&destination) {
|
||||
return Err(OperationError::NodeStateChanged(
|
||||
format!("node {} was removed", destination).into(),
|
||||
format!("node {destination} was removed").into(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -721,9 +721,9 @@ async fn handle_tenant_timeline_passthrough(
|
||||
|
||||
// Callers will always pass an unsharded tenant ID. Before proxying, we must
|
||||
// rewrite this to a shard-aware shard zero ID.
|
||||
let path = format!("{}", path);
|
||||
let path = format!("{path}");
|
||||
let tenant_str = tenant_or_shard_id.tenant_id.to_string();
|
||||
let tenant_shard_str = format!("{}", tenant_shard_id);
|
||||
let tenant_shard_str = format!("{tenant_shard_id}");
|
||||
let path = path.replace(&tenant_str, &tenant_shard_str);
|
||||
|
||||
let latency = &METRICS_REGISTRY
|
||||
@@ -1539,7 +1539,7 @@ async fn handle_ready(req: Request<Body>) -> Result<Response<Body>, ApiError> {
|
||||
|
||||
impl From<ReconcileError> for ApiError {
|
||||
fn from(value: ReconcileError) -> Self {
|
||||
ApiError::Conflict(format!("Reconciliation error: {}", value))
|
||||
ApiError::Conflict(format!("Reconciliation error: {value}"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -500,15 +500,13 @@ impl Persistence {
|
||||
if let Some(np) = node_to_delete {
|
||||
let lc = NodeLifecycle::from_str(&np.lifecycle).map_err(|e| {
|
||||
DatabaseError::Logical(format!(
|
||||
"Node {} has invalid lifecycle: {}",
|
||||
del_node_id, e
|
||||
"Node {del_node_id} has invalid lifecycle: {e}"
|
||||
))
|
||||
})?;
|
||||
|
||||
if lc != NodeLifecycle::Deleted {
|
||||
return Err(DatabaseError::Logical(format!(
|
||||
"Node {} was not soft deleted before, cannot hard delete it",
|
||||
del_node_id
|
||||
"Node {del_node_id} was not soft deleted before, cannot hard delete it"
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -642,8 +640,7 @@ impl Persistence {
|
||||
.await?;
|
||||
if deleted_node > 0 {
|
||||
return Err(DatabaseError::Logical(format!(
|
||||
"Node {} is marked as deleted, re-attach is not allowed",
|
||||
input_node_id
|
||||
"Node {input_node_id} is marked as deleted, re-attach is not allowed"
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -1003,7 +1000,7 @@ impl Persistence {
|
||||
.execute(conn).await?;
|
||||
if u8::try_from(updated)
|
||||
.map_err(|_| DatabaseError::Logical(
|
||||
format!("Overflow existing shard count {} while splitting", updated))
|
||||
format!("Overflow existing shard count {updated} while splitting"))
|
||||
)? != old_shard_count.count() {
|
||||
// Perhaps a deletion or another split raced with this attempt to split, mutating
|
||||
// the parent shards that we intend to split. In this case the split request should fail.
|
||||
@@ -1343,8 +1340,7 @@ impl Persistence {
|
||||
|
||||
if inserted_updated != 1 {
|
||||
return Err(DatabaseError::Logical(format!(
|
||||
"unexpected number of rows ({})",
|
||||
inserted_updated
|
||||
"unexpected number of rows ({inserted_updated})"
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -1406,8 +1402,7 @@ impl Persistence {
|
||||
0 => Ok(false),
|
||||
1 => Ok(true),
|
||||
_ => Err(DatabaseError::Logical(format!(
|
||||
"unexpected number of rows ({})",
|
||||
inserted_updated
|
||||
"unexpected number of rows ({inserted_updated})"
|
||||
))),
|
||||
}
|
||||
})
|
||||
@@ -1476,8 +1471,7 @@ impl Persistence {
|
||||
0 => Ok(()),
|
||||
1 => Ok(()),
|
||||
_ => Err(DatabaseError::Logical(format!(
|
||||
"unexpected number of rows ({})",
|
||||
updated
|
||||
"unexpected number of rows ({updated})"
|
||||
))),
|
||||
}
|
||||
})
|
||||
@@ -1570,8 +1564,7 @@ impl Persistence {
|
||||
0 => Ok(false),
|
||||
1 => Ok(true),
|
||||
_ => Err(DatabaseError::Logical(format!(
|
||||
"unexpected number of rows ({})",
|
||||
inserted_updated
|
||||
"unexpected number of rows ({inserted_updated})"
|
||||
))),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -23,7 +23,7 @@ pub enum ScheduleError {
|
||||
|
||||
impl From<ScheduleError> for ApiError {
|
||||
fn from(value: ScheduleError) -> Self {
|
||||
ApiError::Conflict(format!("Scheduling error: {}", value))
|
||||
ApiError::Conflict(format!("Scheduling error: {value}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ impl Scheduler {
|
||||
/// rigorously updating them on every change.
|
||||
pub(crate) fn update_metrics(&self) {
|
||||
for (node_id, node) in &self.nodes {
|
||||
let node_id_str = format!("{}", node_id);
|
||||
let node_id_str = format!("{node_id}");
|
||||
let label_group = NodeLabelGroup {
|
||||
az: &node.az.0,
|
||||
node_id: &node_id_str,
|
||||
@@ -1326,7 +1326,7 @@ mod tests {
|
||||
.map(|(node_id, node)| (node_id, node.home_shard_count))
|
||||
.collect::<Vec<_>>();
|
||||
node_home_counts.sort_by_key(|i| i.0);
|
||||
eprintln!("Selected {}, vs nodes {:?}", preferred_az, node_home_counts);
|
||||
eprintln!("Selected {preferred_az}, vs nodes {node_home_counts:?}");
|
||||
|
||||
let tenant_shard_id = TenantShardId {
|
||||
tenant_id: TenantId::generate(),
|
||||
|
||||
@@ -260,7 +260,7 @@ fn passthrough_api_error(node: &Node, e: mgmt_api::Error) -> ApiError {
|
||||
// Presume errors receiving body are connectivity/availability issues except for decoding errors
|
||||
let src_str = err.source().map(|e| e.to_string()).unwrap_or_default();
|
||||
ApiError::ResourceUnavailable(
|
||||
format!("{node} error receiving error body: {err} {}", src_str).into(),
|
||||
format!("{node} error receiving error body: {err} {src_str}").into(),
|
||||
)
|
||||
}
|
||||
mgmt_api::Error::ApiError(StatusCode::NOT_FOUND, msg) => {
|
||||
@@ -671,7 +671,7 @@ impl std::fmt::Display for StopReconciliationsReason {
|
||||
Self::ShuttingDown => "Shutting down",
|
||||
Self::SteppingDown => "Stepping down",
|
||||
};
|
||||
write!(writer, "{}", s)
|
||||
write!(writer, "{s}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5278,7 +5278,7 @@ impl Service {
|
||||
shard_params,
|
||||
result
|
||||
.iter()
|
||||
.map(|s| format!("{:?}", s))
|
||||
.map(|s| format!("{s:?}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",")
|
||||
);
|
||||
@@ -6201,7 +6201,7 @@ impl Service {
|
||||
},
|
||||
)
|
||||
.await
|
||||
.map_err(|e| ApiError::Conflict(format!("Failed to split {}: {}", parent_id, e)))?;
|
||||
.map_err(|e| ApiError::Conflict(format!("Failed to split {parent_id}: {e}")))?;
|
||||
|
||||
fail::fail_point!("shard-split-post-remote", |_| Err(ApiError::Conflict(
|
||||
"failpoint".to_string()
|
||||
@@ -6218,7 +6218,7 @@ impl Service {
|
||||
response
|
||||
.new_shards
|
||||
.iter()
|
||||
.map(|s| format!("{:?}", s))
|
||||
.map(|s| format!("{s:?}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",")
|
||||
);
|
||||
@@ -7117,8 +7117,7 @@ impl Service {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(ApiError::Conflict(format!(
|
||||
"Node {} is in use, consider using tombstone API first",
|
||||
node_id
|
||||
"Node {node_id} is in use, consider using tombstone API first"
|
||||
)))
|
||||
}
|
||||
}
|
||||
@@ -7668,7 +7667,7 @@ impl Service {
|
||||
|
||||
if let Some(ongoing) = ongoing_op {
|
||||
return Err(ApiError::PreconditionFailed(
|
||||
format!("Background operation already ongoing for node: {}", ongoing).into(),
|
||||
format!("Background operation already ongoing for node: {ongoing}").into(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -7799,7 +7798,7 @@ impl Service {
|
||||
|
||||
if let Some(ongoing) = ongoing_op {
|
||||
return Err(ApiError::PreconditionFailed(
|
||||
format!("Background operation already ongoing for node: {}", ongoing).into(),
|
||||
format!("Background operation already ongoing for node: {ongoing}").into(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -8870,7 +8869,7 @@ impl Service {
|
||||
let nodes = self.inner.read().unwrap().nodes.clone();
|
||||
let node = nodes.get(secondary).ok_or(mgmt_api::Error::ApiError(
|
||||
StatusCode::NOT_FOUND,
|
||||
format!("Node with id {} not found", secondary),
|
||||
format!("Node with id {secondary} not found"),
|
||||
))?;
|
||||
|
||||
match node
|
||||
@@ -8949,8 +8948,7 @@ impl Service {
|
||||
Err(err) => {
|
||||
return Err(OperationError::FinalizeError(
|
||||
format!(
|
||||
"Failed to finalise drain cancel of {} by setting scheduling policy to Active: {}",
|
||||
node_id, err
|
||||
"Failed to finalise drain cancel of {node_id} by setting scheduling policy to Active: {err}"
|
||||
)
|
||||
.into(),
|
||||
));
|
||||
@@ -9054,8 +9052,7 @@ impl Service {
|
||||
Err(err) => {
|
||||
return Err(OperationError::FinalizeError(
|
||||
format!(
|
||||
"Failed to finalise drain cancel of {} by setting scheduling policy to Active: {}",
|
||||
node_id, err
|
||||
"Failed to finalise drain cancel of {node_id} by setting scheduling policy to Active: {err}"
|
||||
)
|
||||
.into(),
|
||||
));
|
||||
@@ -9265,8 +9262,7 @@ impl Service {
|
||||
Err(err) => {
|
||||
return Err(OperationError::FinalizeError(
|
||||
format!(
|
||||
"Failed to finalise drain cancel of {} by setting scheduling policy to Active: {}",
|
||||
node_id, err
|
||||
"Failed to finalise drain cancel of {node_id} by setting scheduling policy to Active: {err}"
|
||||
)
|
||||
.into(),
|
||||
));
|
||||
@@ -9348,8 +9344,7 @@ impl Service {
|
||||
Err(err) => {
|
||||
return Err(OperationError::FinalizeError(
|
||||
format!(
|
||||
"Failed to finalise drain cancel of {} by setting scheduling policy to Active: {}",
|
||||
node_id, err
|
||||
"Failed to finalise drain cancel of {node_id} by setting scheduling policy to Active: {err}"
|
||||
)
|
||||
.into(),
|
||||
));
|
||||
|
||||
@@ -3008,21 +3008,18 @@ pub(crate) mod tests {
|
||||
|
||||
if attachments_in_wrong_az > 0 {
|
||||
violations.push(format!(
|
||||
"{} attachments scheduled to the incorrect AZ",
|
||||
attachments_in_wrong_az
|
||||
"{attachments_in_wrong_az} attachments scheduled to the incorrect AZ"
|
||||
));
|
||||
}
|
||||
|
||||
if secondaries_in_wrong_az > 0 {
|
||||
violations.push(format!(
|
||||
"{} secondaries scheduled to the incorrect AZ",
|
||||
secondaries_in_wrong_az
|
||||
"{secondaries_in_wrong_az} secondaries scheduled to the incorrect AZ"
|
||||
));
|
||||
}
|
||||
|
||||
eprintln!(
|
||||
"attachments_in_wrong_az={} secondaries_in_wrong_az={}",
|
||||
attachments_in_wrong_az, secondaries_in_wrong_az
|
||||
"attachments_in_wrong_az={attachments_in_wrong_az} secondaries_in_wrong_az={secondaries_in_wrong_az}"
|
||||
);
|
||||
|
||||
for (node_id, stats) in &node_stats {
|
||||
|
||||
@@ -195,7 +195,7 @@ impl UpcallClient {
|
||||
let authorization_header = config
|
||||
.control_plane_jwt_token
|
||||
.clone()
|
||||
.map(|jwt| format!("Bearer {}", jwt));
|
||||
.map(|jwt| format!("Bearer {jwt}"));
|
||||
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
.timeout(IMPORT_COMPLETE_REQUEST_TIMEOUT)
|
||||
|
||||
Reference in New Issue
Block a user