Skip to content

Commit

Permalink
update comments and some names
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco committed Feb 23, 2024
1 parent 0bde27c commit d77676e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
34 changes: 25 additions & 9 deletions dev-tools/reconfigurator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use anyhow::{anyhow, Context};
use nexus_deployment::blueprint_builder::BlueprintBuilder;
use nexus_deployment::planner::Planner;
use nexus_deployment::synthetic::{SledBuilder, SyntheticSystemBuilder};
use nexus_deployment::system::{SledBuilder, SystemDescription};
use nexus_types::deployment::Blueprint;
use nexus_types::inventory::Collection;
use omicron_common::api::external::Generation;
Expand All @@ -21,13 +21,13 @@ use uuid::Uuid;
// - I think it's finally time to switch to using the derive version of clap +
// reedline directly. This is in my way right now because I'm getting back
// errors that I cannot see. See item below.
// - in a bit of a dead end in the demo flow because SyntheticSystemBuilder does
// - in a bit of a dead end in the demo flow because SystemDescription does
// not put any zones onto anything, and build-blueprint-from-inventory
// requires that there are zones. options here include:
// - create a function to create an initial Blueprint from a *blank* inventory
// (or maybe a SystemBuilder? since RSS won't have an inventory) that does
// what RSS would do (maybe even have RSS use this?)
// - add support to SyntheticSystemBuilder for putting zones onto things
// - add support to SystemDescription for putting zones onto things
// (not sure this is worth doing)
// - build support for loading *saved* stuff from existing systems and only
// support that (nope)
Expand All @@ -52,14 +52,21 @@ use uuid::Uuid;
// - call the real deployment code against simulated stuff
// (sled agents + database)
// This is appealing but in the limit may require quite a lot of Nexus to
// work. Can you even create a fake datastore outside the nexus-db-queries
// crate? If so, how much does this stuff assume stuff has been set up by a
// real Nexus?
// work. But can you even create a fake datastore outside the
// nexus-db-queries crate? If so, how much does this stuff assume stuff has
// been set up by a real Nexus? I'm fairly sure that DNS does assume this.
// Plus, the sled info is stored in the database, so that means the sled
// addresses would need to all be "localhost" instead of the more
// realistic-looking addresses.
// - implement dry-run deployment code
// - we have a basic idea how this might work
// - dns: can directly report what it would do
// - zones: can report what requests it would make
// - external IP/NIC stuff: ??
// - but then we also need a way to fake up an inventory from the result
// - seems like this would require the alternate approach of implementing
// methods on SystemBuilder to specify zones
// methods on SystemBuilder to specify zones? or would we use an
// InventoryBuilder directly?
//
// With this in place, though, the demo could proceed:
//
Expand All @@ -74,6 +81,15 @@ use uuid::Uuid;
// blueprint but by starting with an inventory that has zones in it. (We might
// _get_ that through the above simulation.)
//
// At some point we can add:
//
// - save to file (sleds, collections, blueprints)
// - load from file (ditto)
// - omdb: read from database, save to same format of file
//
// Then we can see what would happen when we make changes to a production system
// by saving its state and loading it here.
//
// XXX-dap reedline-repl-rs nits
// - cannot turn off the date banner
// - cannot use structopt version of command definitions
Expand All @@ -84,7 +100,7 @@ use uuid::Uuid;

#[derive(Debug)]
struct ReconfiguratorSim {
system: SyntheticSystemBuilder,
system: SystemDescription,
collections: Vec<Collection>,
blueprints: Vec<Blueprint>,
log: slog::Logger,
Expand All @@ -97,7 +113,7 @@ fn main() -> anyhow::Result<()> {
.to_logger("reconfigurator-sim")
.context("creating logger")?;
let sim = ReconfiguratorSim {
system: SyntheticSystemBuilder::new(),
system: SystemDescription::new(),
collections: vec![],
blueprints: vec![],
log,
Expand Down
8 changes: 4 additions & 4 deletions nexus/deployment/src/blueprint_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,8 @@ impl<'a> BlueprintZones<'a> {
#[cfg(test)]
pub mod test {
use super::*;
use crate::synthetic::SledBuilder;
use crate::synthetic::SyntheticSystemBuilder;
use crate::system::SledBuilder;
use crate::system::SystemDescription;
use nexus_types::external_api::views::SledProvisionState;
use omicron_common::address::IpRange;
use omicron_common::address::Ipv6Subnet;
Expand All @@ -735,9 +735,9 @@ pub mod test {

/// Returns a collection and policy describing a small but non-trivial
/// system
pub fn example_system() -> SyntheticSystemBuilder {
pub fn example_system() -> SystemDescription {
// First, build a system that just has some sleds in it.
let mut system_builder = SyntheticSystemBuilder::new();
let mut system_builder = SystemDescription::new();
for _ in 0..3 {
let _ = system_builder.sled(SledBuilder::new()).unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion nexus/deployment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@
pub mod blueprint_builder;
mod ip_allocator;
pub mod planner;
pub mod synthetic;
pub mod system;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Builders for constructing inventory collections and blueprints for synthetic
//! systems
//! Builders for constructing descriptions of systems (real or synthetic) and
//! associated inventory collections and blueprints
use crate::blueprint_builder::BlueprintBuilder;
use anyhow::{anyhow, bail, Context};
Expand Down Expand Up @@ -41,7 +41,7 @@ impl<T> SubnetIterator for T where
}

#[derive(Debug)]
pub struct SyntheticSystemBuilder {
pub struct SystemDescription {
collector: Option<String>,
sleds: Vec<Sled>,
sled_subnets: Box<dyn SubnetIterator>,
Expand All @@ -51,7 +51,7 @@ pub struct SyntheticSystemBuilder {
service_ip_pool_ranges: Vec<IpRange>,
}

impl SyntheticSystemBuilder {
impl SystemDescription {
pub fn new() -> Self {
// Prepare sets of available slots (cubby numbers) for (1) all
// non-Scrimlet sleds, and (2) Scrimlets in particular. These do not
Expand Down Expand Up @@ -101,7 +101,7 @@ impl SyntheticSystemBuilder {
))
.unwrap()];

SyntheticSystemBuilder {
SystemDescription {
sleds: Vec::new(),
collector: None,
sled_subnets,
Expand All @@ -114,15 +114,15 @@ impl SyntheticSystemBuilder {

/// Returns a complete system deployed on a single Sled
pub fn single_sled() -> anyhow::Result<Self> {
let mut builder = SyntheticSystemBuilder::new();
let mut builder = SystemDescription::new();
let sled = SledBuilder::new();
builder.sled(sled)?;
Ok(builder)
}

/// Returns a complete system resembling a full rack
pub fn full_rack() -> anyhow::Result<Self> {
let mut builder = SyntheticSystemBuilder::new();
let mut builder = SystemDescription::new();
for slot_number in 1..32 {
let mut sled = SledBuilder::new();
if slot_number == 14 || slot_number == 16 {
Expand Down

0 comments on commit d77676e

Please sign in to comment.