-
Notifications
You must be signed in to change notification settings - Fork 43
sled-agent: don't block during instance creation request from nexus #4691
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
Merged
lifning
merged 8 commits into
oxidecomputer:main
from
lifning:sled-agent-instance-creation-refactor
Mar 19, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c0ba701
Add some unit tests for sled-agent Instance creation
a3da136
sled-agent: don't block during instance creation request from nexus
a007503
post-rebase updates
b026a35
fmt
71de433
clean up fake zone files after tests
d55db5b
fixup
aa9da2c
cleanup fmt stable oddity
d5da2d4
use tokio::time::advance
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1193,29 +1193,55 @@ impl ZoneBuilderFactory { | |
/// Created by [ZoneBuilderFactory]. | ||
#[derive(Default)] | ||
pub struct ZoneBuilder<'a> { | ||
/// Logger to which status messages are written during zone installation. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for all the additional info! |
||
log: Option<Logger>, | ||
/// Allocates the NIC used for control plane communication. | ||
underlay_vnic_allocator: Option<&'a VnicAllocator<Etherstub>>, | ||
/// Filesystem path at which the installed zone will reside. | ||
zone_root_path: Option<&'a Utf8Path>, | ||
/// The directories that will be searched for the image tarball for the | ||
/// provided zone type ([`Self::with_zone_type`]). | ||
zone_image_paths: Option<&'a [Utf8PathBuf]>, | ||
/// The name of the type of zone being created (e.g. "propolis-server") | ||
zone_type: Option<&'a str>, | ||
unique_name: Option<Uuid>, // actually optional | ||
/// Unique ID of the instance of the zone being created. (optional) | ||
// *actually* optional (in contrast to other fields that are `Option` for | ||
// builder purposes - that is, skipping this field in the builder will | ||
// still result in an `Ok(InstalledZone)` from `.install()`, rather than | ||
// an `Err(InstallZoneError::IncompleteBuilder)`. | ||
unique_name: Option<Uuid>, | ||
/// ZFS datasets to be accessed from within the zone. | ||
datasets: Option<&'a [zone::Dataset]>, | ||
/// Filesystems to mount within the zone. | ||
filesystems: Option<&'a [zone::Fs]>, | ||
/// Additional network device names to add to the zone. | ||
data_links: Option<&'a [String]>, | ||
/// Device nodes to pass through to the zone. | ||
devices: Option<&'a [zone::Device]>, | ||
/// OPTE devices for the guest network interfaces. | ||
opte_ports: Option<Vec<(Port, PortTicket)>>, | ||
bootstrap_vnic: Option<Link>, // actually optional | ||
/// NIC to use for creating a bootstrap address on the switch zone. | ||
// actually optional (as above) | ||
bootstrap_vnic: Option<Link>, | ||
/// Physical NICs possibly provisioned to the zone. | ||
links: Option<Vec<Link>>, | ||
/// The maximum set of privileges any process in this zone can obtain. | ||
limit_priv: Option<Vec<String>>, | ||
/// For unit tests only: if `Some`, then no actual zones will be installed | ||
/// by this builder, and minimal facsimiles of them will be placed in | ||
/// temporary directories according to the contents of the provided | ||
/// `FakeZoneBuilderConfig`. | ||
fake_cfg: Option<FakeZoneBuilderConfig>, | ||
} | ||
|
||
impl<'a> ZoneBuilder<'a> { | ||
/// Logger to which status messages are written during zone installation. | ||
pub fn with_log(mut self, log: Logger) -> Self { | ||
self.log = Some(log); | ||
self | ||
} | ||
|
||
/// Allocates the NIC used for control plane communication. | ||
pub fn with_underlay_vnic_allocator( | ||
mut self, | ||
vnic_allocator: &'a VnicAllocator<Etherstub>, | ||
|
@@ -1224,11 +1250,14 @@ impl<'a> ZoneBuilder<'a> { | |
self | ||
} | ||
|
||
/// Filesystem path at which the installed zone will reside. | ||
pub fn with_zone_root_path(mut self, root_path: &'a Utf8Path) -> Self { | ||
self.zone_root_path = Some(root_path); | ||
self | ||
} | ||
|
||
/// The directories that will be searched for the image tarball for the | ||
/// provided zone type ([`Self::with_zone_type`]). | ||
pub fn with_zone_image_paths( | ||
mut self, | ||
image_paths: &'a [Utf8PathBuf], | ||
|
@@ -1237,56 +1266,68 @@ impl<'a> ZoneBuilder<'a> { | |
self | ||
} | ||
|
||
/// The name of the type of zone being created (e.g. "propolis-server") | ||
pub fn with_zone_type(mut self, zone_type: &'a str) -> Self { | ||
self.zone_type = Some(zone_type); | ||
self | ||
} | ||
|
||
/// Unique ID of the instance of the zone being created. (optional) | ||
pub fn with_unique_name(mut self, uuid: Uuid) -> Self { | ||
self.unique_name = Some(uuid); | ||
self | ||
} | ||
|
||
/// ZFS datasets to be accessed from within the zone. | ||
pub fn with_datasets(mut self, datasets: &'a [zone::Dataset]) -> Self { | ||
self.datasets = Some(datasets); | ||
self | ||
} | ||
|
||
/// Filesystems to mount within the zone. | ||
pub fn with_filesystems(mut self, filesystems: &'a [zone::Fs]) -> Self { | ||
self.filesystems = Some(filesystems); | ||
self | ||
} | ||
|
||
/// Additional network device names to add to the zone. | ||
pub fn with_data_links(mut self, links: &'a [String]) -> Self { | ||
self.data_links = Some(links); | ||
self | ||
} | ||
|
||
/// Device nodes to pass through to the zone. | ||
pub fn with_devices(mut self, devices: &'a [zone::Device]) -> Self { | ||
self.devices = Some(devices); | ||
self | ||
} | ||
|
||
/// OPTE devices for the guest network interfaces. | ||
pub fn with_opte_ports(mut self, ports: Vec<(Port, PortTicket)>) -> Self { | ||
self.opte_ports = Some(ports); | ||
self | ||
} | ||
|
||
/// NIC to use for creating a bootstrap address on the switch zone. | ||
/// (optional) | ||
pub fn with_bootstrap_vnic(mut self, vnic: Link) -> Self { | ||
self.bootstrap_vnic = Some(vnic); | ||
self | ||
} | ||
|
||
/// Physical NICs possibly provisioned to the zone. | ||
pub fn with_links(mut self, links: Vec<Link>) -> Self { | ||
self.links = Some(links); | ||
self | ||
} | ||
|
||
/// The maximum set of privileges any process in this zone can obtain. | ||
pub fn with_limit_priv(mut self, limit_priv: Vec<String>) -> Self { | ||
self.limit_priv = Some(limit_priv); | ||
self | ||
} | ||
|
||
// (used in unit tests) | ||
fn fake_install(self) -> Result<InstalledZone, InstallZoneError> { | ||
let zone = self | ||
.zone_type | ||
|
@@ -1324,6 +1365,9 @@ impl<'a> ZoneBuilder<'a> { | |
.ok_or(InstallZoneError::IncompleteBuilder) | ||
} | ||
|
||
/// Create the zone with the provided parameters. | ||
/// Returns `Err(InstallZoneError::IncompleteBuilder)` if a necessary | ||
/// parameter was not provided. | ||
pub async fn install(self) -> Result<InstalledZone, InstallZoneError> { | ||
if self.fake_cfg.is_some() { | ||
return self.fake_install(); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.