From 6806e0b34fefef72f3be56e77c4b60b9e5a88101 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Wed, 13 Nov 2024 10:32:29 -0800 Subject: [PATCH 1/5] avoid tight coupling with propolis Dropshot version --- Cargo.lock | 15 ++++++++++++--- Cargo.toml | 2 +- sled-agent/src/instance.rs | 22 ++++++---------------- sled-agent/src/sim/sled_agent.rs | 30 +++++++++++------------------- 4 files changed, 30 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 637465ebd8..d0496a49cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8808,7 +8808,7 @@ dependencies = [ [[package]] name = "propolis-mock-server" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656#86101eaf80b55e7f405b5cafe9b0de0e9f331656" +source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#364413d21aa83a8427c317bbb3ad9733a1e2b97b" dependencies = [ "anyhow", "atty", @@ -8818,7 +8818,7 @@ dependencies = [ "futures", "hyper", "progenitor", - "propolis_types", + "propolis_types 0.0.0 (git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix)", "rand", "reqwest", "schemars", @@ -8853,13 +8853,22 @@ version = "0.0.0" source = "git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656#86101eaf80b55e7f405b5cafe9b0de0e9f331656" dependencies = [ "crucible-client-types", - "propolis_types", + "propolis_types 0.0.0 (git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656)", "schemars", "serde", "thiserror", "uuid", ] +[[package]] +name = "propolis_types" +version = "0.0.0" +source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#364413d21aa83a8427c317bbb3ad9733a1e2b97b" +dependencies = [ + "schemars", + "serde", +] + [[package]] name = "propolis_types" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index 522acee6ac..fa7c9bff6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -523,7 +523,7 @@ progenitor-client = "0.8.0" bhyve_api = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } propolis_api_types = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } -propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } +propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", branch = "dap/mock-server-fix" } proptest = "1.5.0" qorb = "0.2.0" quote = "1.0" diff --git a/sled-agent/src/instance.rs b/sled-agent/src/instance.rs index 4883918c36..f195e00ced 100644 --- a/sled-agent/src/instance.rs +++ b/sled-agent/src/instance.rs @@ -2102,29 +2102,19 @@ mod tests { // TODO: factor out, this is also in sled-agent-sim. fn propolis_mock_server( log: &Logger, - ) -> (HttpServer>, PropolisClient) { + ) -> (propolis_mock_server::Server, PropolisClient) { let propolis_bind_address = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 0); // allocate port - let dropshot_config = dropshot::ConfigDropshot { + let dropshot_config = propolis_mock_server::Config { bind_address: propolis_bind_address, ..Default::default() }; - let propolis_log = log.new(o!("component" => "propolis-server-mock")); - let private = - Arc::new(propolis_mock_server::Context::new(propolis_log)); info!(log, "Starting mock propolis-server..."); - let dropshot_log = log.new(o!("component" => "dropshot")); - let mock_api = propolis_mock_server::api(); - - let srv = dropshot::HttpServerStarter::new( - &dropshot_config, - mock_api, - private, - &dropshot_log, - ) - .expect("couldn't create mock propolis-server") - .start(); + let srv = propolis_mock_server::start(dropshot_config, log.clone()) + .await + .expect("couldn't create mock propolis-server") + .start(); let client = propolis_client::Client::new(&format!( "http://{}", srv.local_addr() diff --git a/sled-agent/src/sim/sled_agent.rs b/sled-agent/src/sim/sled_agent.rs index aef4128c52..cf3d75a785 100644 --- a/sled-agent/src/sim/sled_agent.rs +++ b/sled-agent/src/sim/sled_agent.rs @@ -17,7 +17,7 @@ use crate::sim::simulatable::Simulatable; use crate::updates::UpdateManager; use anyhow::bail; use anyhow::Context; -use dropshot::{HttpError, HttpServer}; +use dropshot::HttpError; use futures::lock::Mutex; use nexus_sled_agent_shared::inventory::{ Inventory, InventoryDataset, InventoryDisk, InventoryZpool, @@ -43,7 +43,6 @@ use oxnet::Ipv6Net; use propolis_client::{ types::VolumeConstructionRequest, Client as PropolisClient, }; -use propolis_mock_server::Context as PropolisContext; use sled_agent_types::disk::DiskStateRequested; use sled_agent_types::early_networking::{ EarlyNetworkConfig, EarlyNetworkConfigBody, @@ -81,7 +80,7 @@ pub struct SledAgent { disk_id_to_region_ids: Mutex>>, pub v2p_mappings: Mutex>, mock_propolis: - Mutex>, PropolisClient)>>, + Mutex>, /// lists of external IPs assigned to instances pub external_ips: Mutex>>, @@ -797,26 +796,19 @@ impl SledAgent { } let propolis_bind_address = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 0); - let dropshot_config = dropshot::ConfigDropshot { + let dropshot_config = propolis_mock_server::Config { bind_address: propolis_bind_address, ..Default::default() }; - let propolis_log = log.new(o!("component" => "propolis-server-mock")); - let private = Arc::new(PropolisContext::new(propolis_log)); info!(log, "Starting mock propolis-server..."); - let dropshot_log = log.new(o!("component" => "dropshot")); - let mock_api = propolis_mock_server::api(); - - let srv = dropshot::HttpServerStarter::new( - &dropshot_config, - mock_api, - private, - &dropshot_log, - ) - .map_err(|error| { - Error::unavail(&format!("initializing propolis-server: {}", error)) - })? - .start(); + let srv = propolis_mock_server::start(dropshot_config, log.clone()) + .await + .map_err(|error| { + Error::unavail(&format!( + "initializing propolis-server: {}", + error + )) + })?; let addr = srv.local_addr(); let client = propolis_client::Client::new(&format!("http://{}", addr)); *mock_lock = Some((srv, client)); From 97d7d4d2c0eed648a1d9aedab961a58dbf77c9b9 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Wed, 13 Nov 2024 10:39:20 -0800 Subject: [PATCH 2/5] does not need to be async --- Cargo.lock | 4 ++-- sled-agent/src/instance.rs | 4 +--- sled-agent/src/sim/sled_agent.rs | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0496a49cb..e87015b860 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8808,7 +8808,7 @@ dependencies = [ [[package]] name = "propolis-mock-server" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#364413d21aa83a8427c317bbb3ad9733a1e2b97b" +source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#fea74a6e5a083dfb2d62245e9b01af3e192a091c" dependencies = [ "anyhow", "atty", @@ -8863,7 +8863,7 @@ dependencies = [ [[package]] name = "propolis_types" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#364413d21aa83a8427c317bbb3ad9733a1e2b97b" +source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#fea74a6e5a083dfb2d62245e9b01af3e192a091c" dependencies = [ "schemars", "serde", diff --git a/sled-agent/src/instance.rs b/sled-agent/src/instance.rs index f195e00ced..63c363985a 100644 --- a/sled-agent/src/instance.rs +++ b/sled-agent/src/instance.rs @@ -2112,9 +2112,7 @@ mod tests { info!(log, "Starting mock propolis-server..."); let srv = propolis_mock_server::start(dropshot_config, log.clone()) - .await - .expect("couldn't create mock propolis-server") - .start(); + .expect("couldn't create mock propolis-server"); let client = propolis_client::Client::new(&format!( "http://{}", srv.local_addr() diff --git a/sled-agent/src/sim/sled_agent.rs b/sled-agent/src/sim/sled_agent.rs index cf3d75a785..5a482f3196 100644 --- a/sled-agent/src/sim/sled_agent.rs +++ b/sled-agent/src/sim/sled_agent.rs @@ -802,7 +802,6 @@ impl SledAgent { }; info!(log, "Starting mock propolis-server..."); let srv = propolis_mock_server::start(dropshot_config, log.clone()) - .await .map_err(|error| { Error::unavail(&format!( "initializing propolis-server: {}", From 3da800b39529e7ce7988cdec3faca49509c4caab Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Wed, 13 Nov 2024 10:43:49 -0800 Subject: [PATCH 3/5] update dep --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e87015b860..7fcd490a71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8808,7 +8808,7 @@ dependencies = [ [[package]] name = "propolis-mock-server" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#fea74a6e5a083dfb2d62245e9b01af3e192a091c" +source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#c753e479ddb9111af5223638e64ee9873c179bc9" dependencies = [ "anyhow", "atty", @@ -8863,7 +8863,7 @@ dependencies = [ [[package]] name = "propolis_types" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#fea74a6e5a083dfb2d62245e9b01af3e192a091c" +source = "git+https://github.com/oxidecomputer/propolis?branch=dap/mock-server-fix#c753e479ddb9111af5223638e64ee9873c179bc9" dependencies = [ "schemars", "serde", From 25d67e7e78431626fb01ed08ef22c2719f1bb9a0 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Wed, 13 Nov 2024 13:02:04 -0800 Subject: [PATCH 4/5] update Propolis for mock server updates --- Cargo.toml | 8 ++++---- package-manifest.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 522acee6ac..5093ccec29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -520,10 +520,10 @@ prettyplease = { version = "0.2.25", features = ["verbatim"] } proc-macro2 = "1.0" progenitor = "0.8.0" progenitor-client = "0.8.0" -bhyve_api = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } -propolis_api_types = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } -propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } -propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } +bhyve_api = { git = "https://github.com/oxidecomputer/propolis", rev = "aadc0998c0f07f08ab15a95c006074291734800f" } +propolis_api_types = { git = "https://github.com/oxidecomputer/propolis", rev = "aadc0998c0f07f08ab15a95c006074291734800f" } +propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "aadc0998c0f07f08ab15a95c006074291734800f" } +propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "aadc0998c0f07f08ab15a95c006074291734800f" } proptest = "1.5.0" qorb = "0.2.0" quote = "1.0" diff --git a/package-manifest.toml b/package-manifest.toml index 535f1e2150..ae7a58394a 100644 --- a/package-manifest.toml +++ b/package-manifest.toml @@ -621,10 +621,10 @@ service_name = "propolis-server" only_for_targets.image = "standard" source.type = "prebuilt" source.repo = "propolis" -source.commit = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" +source.commit = "aadc0998c0f07f08ab15a95c006074291734800f" # The SHA256 digest is automatically posted to: # https://buildomat.eng.oxide.computer/public/file/oxidecomputer/propolis/image//propolis-server.sha256.txt -source.sha256 = "8dd411d6f2db23f93c2340cce11aa194da8dcb8cfd20081a614a5722ffbfe255" +source.sha256 = "3cd889201aaa8cc5b916fc8f8176ab5529e2fc1d5d57165ad9a660eb48affef9" output.type = "zone" [package.mg-ddm-gz] From d94c9537f1b0a4006537f9f000522180def3121f Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Wed, 13 Nov 2024 13:07:00 -0800 Subject: [PATCH 5/5] update Cargo.lock too --- Cargo.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 637465ebd8..1abfb1400f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -693,7 +693,7 @@ dependencies = [ [[package]] name = "bhyve_api" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656#86101eaf80b55e7f405b5cafe9b0de0e9f331656" +source = "git+https://github.com/oxidecomputer/propolis?rev=aadc0998c0f07f08ab15a95c006074291734800f#aadc0998c0f07f08ab15a95c006074291734800f" dependencies = [ "bhyve_api_sys", "libc", @@ -703,7 +703,7 @@ dependencies = [ [[package]] name = "bhyve_api_sys" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656#86101eaf80b55e7f405b5cafe9b0de0e9f331656" +source = "git+https://github.com/oxidecomputer/propolis?rev=aadc0998c0f07f08ab15a95c006074291734800f#aadc0998c0f07f08ab15a95c006074291734800f" dependencies = [ "libc", "strum", @@ -6811,7 +6811,7 @@ dependencies = [ "pq-sys", "pretty_assertions", "progenitor-client", - "propolis-client 0.1.0 (git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656)", + "propolis-client 0.1.0 (git+https://github.com/oxidecomputer/propolis?rev=aadc0998c0f07f08ab15a95c006074291734800f)", "qorb", "rand", "rcgen", @@ -7074,7 +7074,7 @@ dependencies = [ "oximeter-producer", "oxnet", "pretty_assertions", - "propolis-client 0.1.0 (git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656)", + "propolis-client 0.1.0 (git+https://github.com/oxidecomputer/propolis?rev=aadc0998c0f07f08ab15a95c006074291734800f)", "propolis-mock-server", "propolis_api_types", "rand", @@ -8766,7 +8766,7 @@ dependencies = [ [[package]] name = "propolis-client" version = "0.1.0" -source = "git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656#86101eaf80b55e7f405b5cafe9b0de0e9f331656" +source = "git+https://github.com/oxidecomputer/propolis?rev=aadc0998c0f07f08ab15a95c006074291734800f#aadc0998c0f07f08ab15a95c006074291734800f" dependencies = [ "async-trait", "base64 0.21.7", @@ -8808,7 +8808,7 @@ dependencies = [ [[package]] name = "propolis-mock-server" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656#86101eaf80b55e7f405b5cafe9b0de0e9f331656" +source = "git+https://github.com/oxidecomputer/propolis?rev=aadc0998c0f07f08ab15a95c006074291734800f#aadc0998c0f07f08ab15a95c006074291734800f" dependencies = [ "anyhow", "atty", @@ -8850,7 +8850,7 @@ dependencies = [ [[package]] name = "propolis_api_types" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656#86101eaf80b55e7f405b5cafe9b0de0e9f331656" +source = "git+https://github.com/oxidecomputer/propolis?rev=aadc0998c0f07f08ab15a95c006074291734800f#aadc0998c0f07f08ab15a95c006074291734800f" dependencies = [ "crucible-client-types", "propolis_types", @@ -8863,7 +8863,7 @@ dependencies = [ [[package]] name = "propolis_types" version = "0.0.0" -source = "git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656#86101eaf80b55e7f405b5cafe9b0de0e9f331656" +source = "git+https://github.com/oxidecomputer/propolis?rev=aadc0998c0f07f08ab15a95c006074291734800f#aadc0998c0f07f08ab15a95c006074291734800f" dependencies = [ "schemars", "serde", @@ -10506,7 +10506,7 @@ dependencies = [ "omicron-uuid-kinds", "omicron-workspace-hack", "oxnet", - "propolis-client 0.1.0 (git+https://github.com/oxidecomputer/propolis?rev=86101eaf80b55e7f405b5cafe9b0de0e9f331656)", + "propolis-client 0.1.0 (git+https://github.com/oxidecomputer/propolis?rev=aadc0998c0f07f08ab15a95c006074291734800f)", "rcgen", "schemars", "serde",