Skip to content

Commit

Permalink
add rack-topology package feature
Browse files Browse the repository at this point in the history
This adds the rack-topology package feature with possible values of
single-sled or multi-sled. single-sled is intended for dev/CI
deployments, while multi-sled is intended for dogfood/prod. The value
of this determines which nexus config-partial.toml is packaged.

Right now the only difference single/multi is the crucible region
allocation strategy.
  • Loading branch information
faithanalog committed Aug 18, 2023
1 parent 4885fb2 commit 960489f
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/buildomat/jobs/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ptime -m ./tools/ci_download_softnpu_machinery

# Build the test target
ptime -m cargo run --locked --release --bin omicron-package -- \
-t test target create -i standard -m non-gimlet -s softnpu
-t test target create -i standard -m non-gimlet -s softnpu -r single-sled
ptime -m cargo run --locked --release --bin omicron-package -- \
-t test package

Expand Down Expand Up @@ -83,7 +83,7 @@ stamp_packages() {

# Build necessary for the global zone
ptime -m cargo run --locked --release --bin omicron-package -- \
-t host target create -i standard -m gimlet -s asic
-t host target create -i standard -m gimlet -s asic -r multi-sled
ptime -m cargo run --locked --release --bin omicron-package -- \
-t host package
stamp_packages omicron-sled-agent maghemite propolis-server overlay
Expand Down
2 changes: 1 addition & 1 deletion .github/buildomat/jobs/tuf-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ done
mkdir /work/package
pushd /work/package
tar xf /input/package/work/package.tar.gz out package-manifest.toml target/release/omicron-package
target/release/omicron-package -t default target create -i standard -m gimlet -s asic
target/release/omicron-package -t default target create -i standard -m gimlet -s asic -r multi-sled
ln -s /input/package/work/zones/* out/
rm out/switch-softnpu.tar.gz # not used when target switch=asic
rm out/omicron-gateway-softnpu.tar.gz # not used when target switch=asic
Expand Down
34 changes: 28 additions & 6 deletions docs/how-to-run.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,42 @@ Error: Creates a new build target, and sets it as "active"
Usage: omicron-package target create [OPTIONS]
Options:
-i, --image <IMAGE> [default: standard] [possible values: standard, trampoline]
-m, --machine <MACHINE> [possible values: gimlet, gimlet-standalone, non-gimlet]
-s, --switch <SWITCH> [possible values: asic, stub, softnpu]
-h, --help Print help (see more with '--help')
-i, --image <IMAGE>
[default: standard]
Possible values:
- standard: A typical host OS image
- trampoline: A recovery host OS image, intended to bootstrap a Standard image
-m, --machine <MACHINE>
Possible values:
- gimlet: Use sled agent configuration for a Gimlet
- gimlet-standalone: Use sled agent configuration for a Gimlet running in isolation
- non-gimlet: Use sled agent configuration for a device emulating a Gimlet
-s, --switch <SWITCH>
Possible values:
- asic: Use the "real" Dendrite, that attempts to interact with the Tofino
- stub: Use a "stub" Dendrite that does not require any real hardware
- softnpu: Use a "softnpu" Dendrite that uses the SoftNPU asic emulator
-r, --rack-topology <RACK_TOPOLOGY>
Possible values:
- multi-sled: Use configurations suitable for a multi-sled deployment, such as dogfood and production racks
- single-sled: Use configurations suitable for a single-sled deployment, such as CI and dev machines
-h, --help
Print help (see a summary with '-h')
----

To setup a build target for a non-Gimlet machine with simulated (but fully functional) external networking, you would run:

[source,console]
----
$ cargo run --release --bin omicron-package -- -t default target create -i standard -m non-gimlet -s softnpu
$ cargo run --release --bin omicron-package -- -t default target create -i standard -m non-gimlet -s softnpu -r single-sled
Finished release [optimized] target(s) in 0.66s
Running `target/release/omicron-package -t default target create -i standard -m non-gimlet -s softnpu`
Running `target/release/omicron-package -t default target create -i standard -m non-gimlet -s softnpu -r single-sled`
Created new build target 'default' and set it as active
----

Expand Down
2 changes: 1 addition & 1 deletion package-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ source.rust.binary_names = ["nexus", "schema-updater"]
source.rust.release = true
source.paths = [
{ from = "/opt/ooce/pgsql-13/lib/amd64", to = "/opt/ooce/pgsql-13/lib/amd64" },
{ from = "smf/nexus", to = "/var/svc/manifest/site/nexus" },
{ from = "smf/nexus/{{rack-topology}}", to = "/var/svc/manifest/site/nexus" },
{ from = "out/console-assets", to = "/var/nexus/static" },
{ from = "schema/crdb", to = "/var/nexus/schema/crdb" },
]
Expand Down
3 changes: 2 additions & 1 deletion package/src/bin/omicron-package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ async fn do_target(
let target_dir = artifact_dir.join("target");
tokio::fs::create_dir_all(&target_dir).await?;
match subcommand {
TargetCommand::Create { image, machine, switch } => {
TargetCommand::Create { image, machine, switch, rack_topology } => {
let target = KnownTarget::new(
image.clone(),
machine.clone(),
switch.clone(),
rack_topology.clone(),
)?;

let path = get_single_target(&target_dir, name).await?;
Expand Down
7 changes: 7 additions & 0 deletions package/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ pub enum TargetCommand {

#[clap(short, long, default_value_if("image", "standard", "stub"))]
switch: Option<crate::target::Switch>,

#[clap(
short,
long,
default_value_if("image", "standard", "single-sled")
)]
rack_topology: Option<crate::target::RackTopology>,
},
/// List all existing targets
List,
Expand Down
28 changes: 26 additions & 2 deletions package/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,35 @@ pub enum Switch {
SoftNpu,
}

/// Topology of the sleds within the rack.
#[derive(Clone, Debug, strum::EnumString, strum::Display, ValueEnum)]
#[strum(serialize_all = "kebab-case")]
#[clap(rename_all = "kebab-case")]
pub enum RackTopology {
/// Use configurations suitable for a multi-sled deployment, such as dogfood
/// and production racks.
MultiSled,

/// Use configurations suitable for a single-sled deployment, such as CI and
/// dev machines.
SingleSled,
}

/// A strongly-typed variant of [Target].
#[derive(Clone, Debug)]
pub struct KnownTarget {
image: Image,
machine: Option<Machine>,
switch: Option<Switch>,
rack_topology: Option<RackTopology>,
}

impl KnownTarget {
pub fn new(
image: Image,
machine: Option<Machine>,
switch: Option<Switch>,
rack_topology: Option<RackTopology>,
) -> Result<Self> {
if matches!(image, Image::Trampoline) {
if machine.is_some() {
Expand All @@ -77,7 +93,7 @@ impl KnownTarget {
bail!("'switch=asic' is only valid with 'machine=gimlet'");
}

Ok(Self { image, machine, switch })
Ok(Self { image, machine, switch, rack_topology })
}
}

Expand All @@ -87,6 +103,7 @@ impl Default for KnownTarget {
image: Image::Standard,
machine: Some(Machine::NonGimlet),
switch: Some(Switch::Stub),
rack_topology: Some(RackTopology::MultiSled),
}
}
}
Expand All @@ -101,6 +118,9 @@ impl From<KnownTarget> for Target {
if let Some(switch) = kt.switch {
map.insert("switch".to_string(), switch.to_string());
}
if let Some(rack_topology) = kt.rack_topology {
map.insert("rack-topology".to_string(), rack_topology.to_string());
}
Target(map)
}
}
Expand All @@ -121,6 +141,7 @@ impl std::str::FromStr for KnownTarget {
let mut image = Self::default().image;
let mut machine = None;
let mut switch = None;
let mut rack_topology = None;

for (k, v) in target.0.into_iter() {
match k.as_str() {
Expand All @@ -133,6 +154,9 @@ impl std::str::FromStr for KnownTarget {
"switch" => {
switch = Some(v.parse()?);
}
"rack-topology" => {
rack_topology = Some(v.parse()?);
}
_ => {
bail!(
"Unknown target key {k}\nValid keys include: [{}]",
Expand All @@ -146,6 +170,6 @@ impl std::str::FromStr for KnownTarget {
}
}
}
KnownTarget::new(image, machine, switch)
KnownTarget::new(image, machine, switch, rack_topology)
}
}
2 changes: 2 additions & 0 deletions sled-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ machine-non-gimlet = []
switch-asic = []
switch-stub = []
switch-softnpu = []
rack-topology-single-sled = []
rack-topology-multi-sled = []
File renamed without changes.
45 changes: 45 additions & 0 deletions smf/nexus/single-sled/config-partial.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Oxide API: partial configuration file
#

[console]
# Directory for static assets. Absolute path or relative to CWD.
static_dir = "/var/nexus/static"
session_idle_timeout_minutes = 60
session_absolute_timeout_minutes = 480

[authn]
schemes_external = ["session_cookie", "access_token"]

[log]
# Show log messages of this level and more severe
level = "debug"
mode = "file"
path = "/dev/stdout"
if_exists = "append"

# TODO: Uncomment the following lines to enable automatic schema
# migration on boot.
#
# [schema]
# schema_dir = "/var/nexus/schema/crdb"

[background_tasks]
dns_internal.period_secs_config = 60
dns_internal.period_secs_servers = 60
dns_internal.period_secs_propagation = 60
dns_internal.max_concurrent_server_updates = 5
dns_external.period_secs_config = 60
dns_external.period_secs_servers = 60
dns_external.period_secs_propagation = 60
dns_external.max_concurrent_server_updates = 5
# How frequently we check the list of stored TLS certificates. This is
# approximately an upper bound on how soon after updating the list of
# certificates it will take _other_ Nexus instances to notice and stop serving
# them (on a sunny day).
external_endpoints.period_secs = 60

[default_region_allocation_strategy]
# by default, allocate without requirement for distinct sleds.
# seed is omitted so a new seed will be chosen with every allocation.
type = "random"

0 comments on commit 960489f

Please sign in to comment.