From f52d4a7957556d033c5208f58358a99b7a248fbd Mon Sep 17 00:00:00 2001 From: James MacMahon Date: Thu, 26 May 2022 16:46:05 -0400 Subject: [PATCH 1/4] YouCanBootAnythingAsLongAsItsAlpine image source For development purposes, allow people to select the alpine.iso blob that ships with the propolis-server zone image as an image source. --- nexus/src/app/image.rs | 52 ++++++++++++++++++++++++++++++++ nexus/src/external_api/params.rs | 4 +++ openapi/nexus.json | 15 +++++++++ 3 files changed, 71 insertions(+) diff --git a/nexus/src/app/image.rs b/nexus/src/app/image.rs index ada0b3bb601..94562bc19f5 100644 --- a/nexus/src/app/image.rs +++ b/nexus/src/app/image.rs @@ -209,6 +209,58 @@ impl super::Nexus { &"creating images from snapshots not supported", )); } + + params::ImageSource::YouCanBootAnythingAsLongAsItsAlpine => { + // Each Propolis zone ships with an alpine.iso (it's part of the + // package-manifest.toml blobs), and for development purposes + // allow users to boot that. This should go away when that blob + // does. + let db_block_size = db::model::BlockSize::Traditional; + let block_size: u64 = db_block_size.to_bytes() as u64; + + let volume_construction_request = sled_agent_client::types::VolumeConstructionRequest::Volume { + block_size, + sub_volumes: vec![ + sled_agent_client::types::VolumeConstructionRequest::File { + block_size, + path: "/opt/oxide/propolis-server/blob/alpine.iso".into(), + } + ], + read_only_parent: None, + }; + + let volume_data = + serde_json::to_string(&volume_construction_request)?; + + // Nexus runs in its own zone so we can't ask the propolis zone + // image tar file for size of alpine.iso. Conservatively set the + // size to 100M (at the time of this comment, it's 41M). Any + // disk created from this image has to be larger than it. + let size: u64 = 100 * 1024 * 1024; + let size: external::ByteCount = + size.try_into().map_err(|e| Error::InvalidValue { + label: String::from("size"), + message: format!("size is invalid: {}", e), + })?; + + let new_image_volume = + db::model::Volume::new(Uuid::new_v4(), volume_data); + let volume = + self.db_datastore.volume_create(new_image_volume).await?; + + db::model::GlobalImage { + identity: db::model::GlobalImageIdentity::new( + Uuid::new_v4(), + params.identity.clone(), + ), + volume_id: volume.id(), + url: None, + version: None, + digest: None, + block_size: db_block_size, + size: size.into(), + } + } }; self.db_datastore.global_image_create_image(opctx, new_image).await diff --git a/nexus/src/external_api/params.rs b/nexus/src/external_api/params.rs index f654b393caf..39b77dde6f0 100644 --- a/nexus/src/external_api/params.rs +++ b/nexus/src/external_api/params.rs @@ -391,6 +391,10 @@ pub struct NetworkInterfaceIdentifier { pub enum ImageSource { Url(String), Snapshot(Uuid), + + /// Boot the Alpine ISO that ships with the Propolis zone. Intended for + /// development purposes only. + YouCanBootAnythingAsLongAsItsAlpine, } /// Create-time parameters for an diff --git a/openapi/nexus.json b/openapi/nexus.json index cbfb4f14d9d..49122399489 100644 --- a/openapi/nexus.json +++ b/openapi/nexus.json @@ -6040,6 +6040,21 @@ "src", "type" ] + }, + { + "description": "Boot the Alpine ISO that ships with the Propolis zone. Intended for development purposes only.", + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "you_can_boot_anything_as_long_as_its_alpine" + ] + } + }, + "required": [ + "type" + ] } ] }, From a876e129c1e1062a7327b1ffd3c455e42f609c44 Mon Sep 17 00:00:00 2001 From: James MacMahon Date: Wed, 1 Jun 2022 20:52:33 -0400 Subject: [PATCH 2/4] update propolis to "no longer can we only boot alpine" rev --- Cargo.lock | 2 +- package-manifest.toml | 4 ++-- sled-agent/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a0d60c5da2..239eebcdc33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3765,7 +3765,7 @@ dependencies = [ [[package]] name = "propolis-client" version = "0.1.0" -source = "git+https://github.com/oxidecomputer/propolis?rev=a11ccd5bf001e0c690c67d117f8beb06b0bc6914#a11ccd5bf001e0c690c67d117f8beb06b0bc6914" +source = "git+https://github.com/oxidecomputer/propolis?rev=1538f78c1656bd3ac8ef816f6177ae9b1bef348a#1538f78c1656bd3ac8ef816f6177ae9b1bef348a" dependencies = [ "crucible", "reqwest", diff --git a/package-manifest.toml b/package-manifest.toml index 434163792c3..8dc69d330a2 100644 --- a/package-manifest.toml +++ b/package-manifest.toml @@ -98,7 +98,7 @@ zone = true [external_package.propolis-server.source] type = "prebuilt" repo = "propolis" -commit = "a11ccd5bf001e0c690c67d117f8beb06b0bc6914" +commit = "1538f78c1656bd3ac8ef816f6177ae9b1bef348a" # The SHA256 digest is automatically posted to: # https://buildomat.eng.oxide.computer/public/file/oxidecomputer/propolis/image//propolis-server.sha256.txt -sha256 = "52dd465bf70f3130e16cfb32eefb87f5d01514f1f60a7dd9a1eca970a0669159" +sha256 = "1e21d95a1254f6796a2a7fee3a49f14988beb5646505fc7c9d669ef49f6a50f3" diff --git a/sled-agent/Cargo.toml b/sled-agent/Cargo.toml index 6f2511ded1d..2aa2a12896f 100644 --- a/sled-agent/Cargo.toml +++ b/sled-agent/Cargo.toml @@ -24,7 +24,7 @@ omicron-common = { path = "../common" } p256 = "0.9.0" percent-encoding = "2.1.0" progenitor = { git = "https://github.com/oxidecomputer/progenitor" } -propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "a11ccd5bf001e0c690c67d117f8beb06b0bc6914" } +propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "1538f78c1656bd3ac8ef816f6177ae9b1bef348a" } rand = { version = "0.8.5", features = ["getrandom"] } reqwest = { version = "0.11.8", default-features = false, features = ["rustls-tls", "stream"] } schemars = { version = "0.8.10", features = [ "chrono", "uuid1" ] } From e5d88a10c4686a85a7ef54982178c8f7b42e16c1 Mon Sep 17 00:00:00 2001 From: James MacMahon Date: Thu, 2 Jun 2022 15:45:41 -0400 Subject: [PATCH 3/4] add "How to provision an instance using the CLI" --- docs/how-to-run.adoc | 80 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/docs/how-to-run.adoc b/docs/how-to-run.adoc index aab25ddc434..5619ccc7392 100644 --- a/docs/how-to-run.adoc +++ b/docs/how-to-run.adoc @@ -133,3 +133,83 @@ unique local addresses in the subnet of the first Sled Agent: `fd00:1122:3344:1: Note that Sled Agent runs in the global zone and is the one responsible for bringing up all the other other services and allocating them with vNICs and IPv6 addresses. + +=== How to provision an instance using the CLI + +Here are the current steps to provision an instance using the [oxide](https://github.com/oxidecomputer/cli) +command line interface. + +1. Create an organization and project that the resources will live under: + + oxide org create myorg + oxide project create -o myorg myproj + +2. Define a global image that will be used as initial disk contents. This can be the alpine.iso image that ships with propolis, or an ISO / raw disk image / etc hosted at a URL: + + oxide api /images --method POST --input - < -p serial` + From 8568995b41001929280f382148b892dc33eb593b Mon Sep 17 00:00:00 2001 From: James MacMahon Date: Thu, 2 Jun 2022 15:47:36 -0400 Subject: [PATCH 4/4] asciidoc, not markdown --- docs/how-to-run.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/how-to-run.adoc b/docs/how-to-run.adoc index 5619ccc7392..827b6f1475a 100644 --- a/docs/how-to-run.adoc +++ b/docs/how-to-run.adoc @@ -136,7 +136,7 @@ other services and allocating them with vNICs and IPv6 addresses. === How to provision an instance using the CLI -Here are the current steps to provision an instance using the [oxide](https://github.com/oxidecomputer/cli) +Here are the current steps to provision an instance using the https://github.com/oxidecomputer/cli[oxide] command line interface. 1. Create an organization and project that the resources will live under: