Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow-up feedback on #3707 #3709

Closed
wants to merge 1 commit into from
Closed
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: 6 additions & 5 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1923,16 +1923,17 @@ impl ServiceManager {
});
}

// We initialize all the zones we can, but only return the first error.
// We initialize all the zones we can, but only return one error, if
// any.
let local_existing_zones = Arc::new(Mutex::new(existing_zones));
let first_err = Arc::new(Mutex::new(None));
let last_err = Arc::new(Mutex::new(None));
stream::iter(requests)
// WARNING: Do not use "try_for_each_concurrent" here -- if you do,
// it's possible that the future will cancel other ongoing requests
// to "initialize_zone".
.for_each_concurrent(None, |request| {
let local_existing_zones = local_existing_zones.clone();
let first_err = first_err.clone();
let last_err = last_err.clone();
async move {
match self
.initialize_zone(
Expand All @@ -1949,14 +1950,14 @@ impl ServiceManager {
.push(running_zone);
}
Err(err) => {
*first_err.lock().await = Some(err);
*last_err.lock().await = Some(err);
}
}
}
})
.await;

if let Some(err) = Arc::into_inner(first_err)
if let Some(err) = Arc::into_inner(last_err)
.expect("Should have last reference")
.into_inner()
{
Expand Down