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

[sled-agent][package] Make zone uninstallation concurrent #1178

Merged
merged 3 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions package/src/bin/omicron-package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,10 @@ fn do_install(
}

fn uninstall_all_omicron_zones() -> Result<()> {
for zone in zone::Zones::get()? {
zone::Zones::get()?.into_par_iter().try_for_each(|zone| -> Result<()> {
zone::Zones::halt_and_remove(zone.name())?;
}
Ok(())
})?;
Ok(())
}

Expand Down
46 changes: 33 additions & 13 deletions sled-agent/src/sled_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::params::{
};
use crate::services::ServiceManager;
use crate::storage_manager::StorageManager;
use futures::stream::{self, StreamExt, TryStreamExt};
use omicron_common::api::{
internal::nexus::DiskRuntimeState, internal::nexus::InstanceRuntimeState,
internal::nexus::UpdateArtifact,
Expand Down Expand Up @@ -167,10 +168,19 @@ impl SledAgent {
// re-establish contact (i.e., if the Sled Agent crashed, but we wanted
// to leave the running Zones intact).
let zones = Zones::get()?;
for z in zones {
warn!(log, "Deleting existing zone"; "zone_name" => z.name());
Zones::halt_and_remove_logged(&log, z.name())?;
}
let logs = vec![log.clone(); zones.len()];
smklein marked this conversation as resolved.
Show resolved Hide resolved
stream::iter(zones)
.zip(stream::iter(logs))
.map(Ok::<_, crate::zone::AdmError>)
.try_for_each_concurrent(
None,
|(zone, log)| async {
tokio::task::spawn_blocking(move || {
warn!(log, "Deleting existing zone"; "zone_name" => zone.name());
Zones::halt_and_remove_logged(&log, zone.name())
}).await.unwrap()
}
).await?;

// Identify all VNICs which should be managed by the Sled Agent.
//
Expand All @@ -185,15 +195,25 @@ impl SledAgent {
// Note that we don't currently delete the VNICs in any particular
// order. That should be OK, since we're definitely deleting the guest
// VNICs before the xde devices, which is the main constraint.
for vnic in Dladm::get_vnics()? {
warn!(
log,
"Deleting existing VNIC";
"vnic_name" => &vnic,
"vnic_kind" => ?VnicKind::from_name(&vnic).unwrap(),
);
Dladm::delete_vnic(&vnic)?;
}
let vnics = Dladm::get_vnics()?;
let logs = vec![log.clone(); vnics.len()];
stream::iter(vnics)
.zip(stream::iter(logs))
.map(Ok::<_, crate::illumos::dladm::DeleteVnicError>)
.try_for_each_concurrent(None, |(vnic, log)| async {
tokio::task::spawn_blocking(move || {
warn!(
log,
"Deleting existing VNIC";
"vnic_name" => &vnic,
"vnic_kind" => ?VnicKind::from_name(&vnic).unwrap(),
);
Dladm::delete_vnic(&vnic)
})
.await
.unwrap()
})
.await?;

// Also delete any extant xde devices. These should also eventually be
// recovered / tracked, to avoid interruption of any guests that are
Expand Down