Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
arpad-m committed Jan 21, 2025
1 parent 0ec5046 commit 9ddb0dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions storage_controller/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ impl Persistence {
},
)
.await?;
if timelines.len() == 0 {
if timelines.is_empty() {
return Ok(None);
} else if timelines.len() > 1 {
return Err(DatabaseError::Logical(format!(
Expand All @@ -1285,7 +1285,7 @@ impl Persistence {
)));
}

let tl = timelines.pop().unwrap().to_persistence();
let tl = timelines.pop().unwrap().into_persistence();

tracing::info!("get_timeline: loaded timeline");

Expand Down Expand Up @@ -1340,7 +1340,7 @@ impl Persistence {
.await?;
let timelines = timelines
.into_iter()
.map(|tl| tl.to_persistence())
.map(|tl| tl.into_persistence())
.collect::<Vec<_>>();

tracing::info!("list_timelines: loaded {} timelines", timelines.len());
Expand Down Expand Up @@ -1605,13 +1605,13 @@ pub(crate) struct TimelineFromDb {
}

impl TimelineFromDb {
fn to_persistence(self) -> TimelinePersistence {
fn into_persistence(self) -> TimelinePersistence {
TimelinePersistence {
tenant_id: self.tenant_id,
timeline_id: self.timeline_id,
generation: self.generation,
sk_set: self.sk_set.into_iter().filter_map(|v| v).collect(),
new_sk_set: self.new_sk_set.into_iter().filter_map(|v| v).collect(),
sk_set: self.sk_set.into_iter().flatten().collect(),
new_sk_set: self.new_sk_set.into_iter().flatten().collect(),
cplane_notified_generation: self.cplane_notified_generation,
status_kind: self.status_kind,
status: self.status,
Expand Down
18 changes: 9 additions & 9 deletions storage_controller/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3285,7 +3285,7 @@ impl Service {
tenant_id: TenantId,
mut create_req: TimelineCreateRequest,
) -> Result<TimelineInfo, ApiError> {
Ok(self.tenant_remote_mutation(tenant_id, move |mut targets| async move {
self.tenant_remote_mutation(tenant_id, move |mut targets| async move {
if targets.0.is_empty() {
return Err(ApiError::NotFound(
anyhow::anyhow!("Tenant not found").into(),
Expand Down Expand Up @@ -3401,7 +3401,7 @@ impl Service {
}

Ok(timeline_info)
}).await??)
}).await?
}

/// reconcile: create timeline on safekeepers
Expand All @@ -3421,7 +3421,7 @@ impl Service {

let mut members = Vec::new();
for sk in timeline_persistence.sk_set.iter() {
let Some(sk_p) = sk_persistences.get(&sk) else {
let Some(sk_p) = sk_persistences.get(sk) else {
return Err(ApiError::InternalServerError(anyhow!(
"couldn't find persisted entry for safekeeper with id {sk}"
)))?;
Expand All @@ -3447,7 +3447,7 @@ impl Service {
};
for sk in timeline_persistence.sk_set.iter() {
// Unwrap is fine as we already would have returned error above
let sk_p = sk_persistences.get(&sk).unwrap();
let sk_p = sk_persistences.get(sk).unwrap();
let sk_clone = NodeId(*sk as u64);
let base_url = sk_p.base_url();
let jwt = jwt.clone();
Expand Down Expand Up @@ -4135,7 +4135,7 @@ impl Service {

let mut members = Vec::new();
for sk in tl_p.sk_set.iter() {
let Some(sk_p) = sk_persistences.get(&sk) else {
let Some(sk_p) = sk_persistences.get(sk) else {
return Err(ApiError::InternalServerError(anyhow!(
"couldn't find persisted entry for safekeeper with id {sk}"
)))?;
Expand All @@ -4150,7 +4150,7 @@ impl Service {
let sks_to_reconcile = &tl_p.sk_set;
for sk in sks_to_reconcile.iter() {
// Unwrap is fine as we already would have returned error above
let sk_p = sk_persistences.get(&sk).unwrap();
let sk_p = sk_persistences.get(sk).unwrap();
let sk_clone = NodeId(*sk as u64);
let base_url = sk_p.base_url();
let jwt = jwt.clone();
Expand Down Expand Up @@ -4223,10 +4223,10 @@ impl Service {
}
}
});
if let Err(_) = timeout_or_last.await {
if let Err(e) = timeout_or_last.await {
// No error if cancelled or timed out: we already have feedback from a quorum of safekeepers
tracing::info!(
"timeout for last {} reconciliations",
"timeout for last {} reconciliations: {e}",
sks_to_reconcile.len() - 1
);
}
Expand All @@ -4239,7 +4239,7 @@ impl Service {
"Got {} successful results from reconciliation",
successful.len()
);
let new_status_kind = if successful.len() < 1 {
let new_status_kind = if successful.is_empty() {
// Failure
return Err(ApiError::InternalServerError(anyhow!(
"not enough successful reconciliations to reach quorum, please retry: {}",
Expand Down

0 comments on commit 9ddb0dc

Please sign in to comment.