diff --git a/openapi/wicketd.json b/openapi/wicketd.json index 23271794b23..93bc3e28392 100644 --- a/openapi/wicketd.json +++ b/openapi/wicketd.json @@ -633,35 +633,6 @@ } } }, - "/repository": { - "put": { - "summary": "Upload a TUF repository to the server.", - "description": "At any given time, wicketd will keep at most one TUF repository in memory. Any previously-uploaded repositories will be discarded.", - "operationId": "put_repository", - "requestBody": { - "content": { - "application/octet-stream": { - "schema": { - "type": "string", - "format": "binary" - } - } - }, - "required": true - }, - "responses": { - "204": { - "description": "resource updated" - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, "/update": { "post": { "summary": "An endpoint to start updating one or more sleds, switches and PSCs.", diff --git a/wicket/src/cli/command.rs b/wicket/src/cli/command.rs index 7fba229e99a..f4803ea894e 100644 --- a/wicket/src/cli/command.rs +++ b/wicket/src/cli/command.rs @@ -4,7 +4,6 @@ //! Code that manages command dispatch from a shell for wicket. -use std::net::SocketAddrV6; use std::process::ExitCode; use anyhow::Result; @@ -14,6 +13,7 @@ use super::{ inventory::InventoryArgs, preflight::PreflightArgs, rack_setup::SetupArgs, rack_update::RackUpdateArgs, upload::UploadArgs, }; +use crate::wicketd::WicketdAddrs; pub(crate) struct CommandOutput<'a> { pub(crate) stdout: &'a mut dyn std::io::Write, @@ -36,27 +36,27 @@ impl ShellApp { pub(crate) async fn exec( self, log: slog::Logger, - wicketd_addr: SocketAddrV6, + addrs: WicketdAddrs, output: CommandOutput<'_>, ) -> Result { match self.command { ShellCommand::UploadRepo(args) => { - args.exec(log, wicketd_addr).await?; + args.exec(log, addrs.commission).await?; Ok(ExitCode::SUCCESS) } ShellCommand::RackUpdate(args) => { - args.exec(log, wicketd_addr, self.global_opts, output).await + args.exec(log, addrs.wicketd, self.global_opts, output).await } ShellCommand::Setup(args) => { - args.exec(log, wicketd_addr, self.global_opts).await?; + args.exec(log, addrs.wicketd, self.global_opts).await?; Ok(ExitCode::SUCCESS) } ShellCommand::Preflight(args) => { - args.exec(log, wicketd_addr).await?; + args.exec(log, addrs.wicketd).await?; Ok(ExitCode::SUCCESS) } ShellCommand::Inventory(args) => { - args.exec(log, wicketd_addr, output).await?; + args.exec(log, addrs.wicketd, output).await?; Ok(ExitCode::SUCCESS) } } diff --git a/wicket/src/cli/upload.rs b/wicket/src/cli/upload.rs index c9ec4ea2bb1..9ce2a57e8cc 100644 --- a/wicket/src/cli/upload.rs +++ b/wicket/src/cli/upload.rs @@ -17,7 +17,7 @@ use futures::StreamExt; use reqwest::Body; use tokio_util::io::ReaderStream; -use crate::wicketd::create_wicketd_client; +use crate::wicketd::create_commission_client; // We have observed wicketd running in a switch zone under load take ~60 seconds // to accept a repository; set the timeout to double that to give some headroom. @@ -34,15 +34,7 @@ impl UploadArgs { pub(crate) async fn exec( self, log: slog::Logger, - wicketd_addr: SocketAddrV6, - ) -> Result<()> { - self.do_upload(log, wicketd_addr).await - } - - async fn do_upload( - &self, - log: slog::Logger, - wicketd_addr: SocketAddrV6, + commission_addr: SocketAddrV6, ) -> Result<()> { let repo_bytes = Self::read_repository_from_stdin(&log).await?; let repository_bytes_len = repo_bytes.num_bytes(); @@ -56,16 +48,16 @@ impl UploadArgs { ); } else { slog::info!(log, "uploading repository to wicketd"); - let wicketd_client = create_wicketd_client( + let commission_client = create_commission_client( &log, - wicketd_addr, + commission_addr, WICKETD_UPLOAD_TIMEOUT, ); let body = Body::wrap_stream(futures::stream::iter( repo_bytes.into_iter().map(Ok::<_, Infallible>), )); - wicketd_client + commission_client .put_repository(body) .await .context("error uploading repository to wicketd")?; diff --git a/wicket/src/dispatch.rs b/wicket/src/dispatch.rs index 1f1f9655d81..c8a26564c03 100644 --- a/wicket/src/dispatch.rs +++ b/wicket/src/dispatch.rs @@ -38,11 +38,7 @@ pub fn exec() -> Result { let runtime = tokio::runtime::Runtime::new() .context("creating tokio runtime")?; - runtime.block_on(exec_with_args( - addrs.wicketd, - args, - OutputKind::Terminal, - )) + runtime.block_on(exec_with_args(addrs, args, OutputKind::Terminal)) } Err(_) => { // Do not expose log messages via standard error since they'll show up @@ -68,7 +64,7 @@ pub enum OutputKind<'a> { } pub async fn exec_with_args( - wicketd_addr: SocketAddrV6, + addrs: WicketdAddrs, args: Vec, output: OutputKind<'_>, ) -> Result @@ -84,7 +80,7 @@ where match output { OutputKind::Captured { log, stdout, stderr } => { let output = CommandOutput { stdout, stderr }; - app.exec(log, wicketd_addr, output).await + app.exec(log, addrs, output).await } OutputKind::Terminal => { let log = setup_log( @@ -95,7 +91,7 @@ where let mut stderr = std::io::stderr(); let output = CommandOutput { stdout: &mut stdout, stderr: &mut stderr }; - app.exec(log, wicketd_addr, output).await + app.exec(log, addrs, output).await } } } diff --git a/wicketd-api/src/lib.rs b/wicketd-api/src/lib.rs index b7e7956fd24..f68d328200b 100644 --- a/wicketd-api/src/lib.rs +++ b/wicketd-api/src/lib.rs @@ -8,7 +8,6 @@ use dropshot::HttpResponseOk; use dropshot::HttpResponseUpdatedNoContent; use dropshot::Path; use dropshot::RequestContext; -use dropshot::StreamingBody; use dropshot::TypedBody; use gateway_client::types::IgnitionCommand; use schemars::JsonSchema; @@ -40,10 +39,6 @@ use wicketd_commission_types::rack_setup::SetBgpAuthKeyStatus; use wicketd_commission_types::update::ClearUpdateStateResponse; use wicketd_commission_types::update::UpdateTargets; -/// Full release repositories are currently (Dec 2024) 1.8 GiB and are likely to -/// continue growing. -const PUT_REPOSITORY_MAX_BYTES: usize = 4 * 1024 * 1024 * 1024; - #[dropshot::api_description] pub trait WicketdApi { type Context; @@ -202,20 +197,6 @@ pub trait WicketdApi { body_params: TypedBody, ) -> Result, HttpError>; - /// Upload a TUF repository to the server. - /// - /// At any given time, wicketd will keep at most one TUF repository in - /// memory. Any previously-uploaded repositories will be discarded. - #[endpoint { - method = PUT, - path = "/repository", - request_body_max_bytes = PUT_REPOSITORY_MAX_BYTES, - }] - async fn put_repository( - rqctx: RequestContext, - body: StreamingBody, - ) -> Result; - /// An endpoint used to report all available artifacts and event reports. /// /// The order of the returned artifacts is unspecified, and may change between diff --git a/wicketd/src/http_entrypoints.rs b/wicketd/src/http_entrypoints.rs index f730747ec1f..c663cb4fb93 100644 --- a/wicketd/src/http_entrypoints.rs +++ b/wicketd/src/http_entrypoints.rs @@ -22,7 +22,6 @@ use dropshot::HttpResponseOk; use dropshot::HttpResponseUpdatedNoContent; use dropshot::Path; use dropshot::RequestContext; -use dropshot::StreamingBody; use dropshot::TypedBody; use internal_dns_resolver::Resolver; use sled_agent_types::early_networking::SwitchSlot; @@ -390,17 +389,6 @@ impl WicketdApi for WicketdApiImpl { Ok(HttpResponseOk(GetInventoryResponse::Response { inventory })) } - async fn put_repository( - rqctx: RequestContext, - body: StreamingBody, - ) -> Result { - let rqctx = rqctx.context(); - - rqctx.update_tracker.put_repository(body.into_stream()).await?; - - Ok(HttpResponseUpdatedNoContent()) - } - async fn get_artifacts_and_event_reports( rqctx: RequestContext, ) -> Result, HttpError> diff --git a/wicketd/tests/integration_tests/inventory.rs b/wicketd/tests/integration_tests/inventory.rs index 6c34e42e902..d00c214a47a 100644 --- a/wicketd/tests/integration_tests/inventory.rs +++ b/wicketd/tests/integration_tests/inventory.rs @@ -98,7 +98,7 @@ async fn test_inventory() { stderr: &mut stderr, }; - wicket::exec_with_args(wicketd_testctx.wicketd_addr, args, output) + wicket::exec_with_args(wicketd_testctx.wicketd_addrs, args, output) .await .expect("wicket inventory configured-bootstrap-sleds failed"); diff --git a/wicketd/tests/integration_tests/setup.rs b/wicketd/tests/integration_tests/setup.rs index 6377f2974ef..c1a0ca6da55 100644 --- a/wicketd/tests/integration_tests/setup.rs +++ b/wicketd/tests/integration_tests/setup.rs @@ -10,6 +10,7 @@ use gateway_test_utils::setup::GatewayTestContext; use http::StatusCode; use omicron_test_utils::dev::poll::{CondCheckError, wait_for_condition}; use sled_hardware_types::BaseboardId; +use wicket::WicketdAddrs; use wicketd_commission_client::Error; use wicketd_commission_types_versions::latest::inventory::{ SpIdentifier, SpType, @@ -17,7 +18,7 @@ use wicketd_commission_types_versions::latest::inventory::{ use wicketd_commission_types_versions::latest::update::SpUpdateProgress; pub struct WicketdTestContext { - pub wicketd_addr: SocketAddrV6, + pub wicketd_addrs: WicketdAddrs, pub wicketd_client: wicketd_client::Client, // This is not currently used but is kept here because it's easier to debug // this way. @@ -114,7 +115,10 @@ impl WicketdTestContext { }; Self { - wicketd_addr, + wicketd_addrs: WicketdAddrs { + wicketd: wicketd_addr, + commission: commission_addr, + }, wicketd_client, wicketd_raw_client, artifact_addr, diff --git a/wicketd/tests/integration_tests/updates.rs b/wicketd/tests/integration_tests/updates.rs index 8aad9a2cfc1..7ae66ed24fc 100644 --- a/wicketd/tests/integration_tests/updates.rs +++ b/wicketd/tests/integration_tests/updates.rs @@ -87,7 +87,7 @@ async fn test_updates() { .await .unwrap(); wicketd_testctx - .wicketd_client + .commission_client .put_repository(zip_bytes) .await .expect("bytes read and archived"); @@ -301,7 +301,7 @@ async fn test_updates() { stderr: &mut stderr, }; - wicket::exec_with_args(wicketd_testctx.wicketd_addr, args, output) + wicket::exec_with_args(wicketd_testctx.wicketd_addrs, args, output) .await .expect("wicket rack-update clear failed"); @@ -371,7 +371,7 @@ async fn get_rack_update_status( stdout: &mut stdout, stderr: &mut stderr, }; - wicket::exec_with_args(wicketd_testctx.wicketd_addr, args, output) + wicket::exec_with_args(wicketd_testctx.wicketd_addrs, args, output) .await .expect("wicket rack-update status failed to run"); serde_json::from_slice(&stdout) @@ -400,7 +400,7 @@ async fn test_installinator_fetch() { .await .unwrap(); wicketd_testctx - .wicketd_client + .commission_client .put_repository(zip_bytes) .await .expect("bytes read and archived"); @@ -697,7 +697,7 @@ async fn test_update_races() { .await .unwrap(); wicketd_testctx - .wicketd_client + .commission_client .put_repository(zip_bytes.clone()) .await .expect("bytes read and archived"); @@ -739,7 +739,7 @@ async fn test_update_races() { // An update is now running. Try uploading the repository again -- this time // it should fail. wicketd_testctx - .wicketd_client + .commission_client .put_repository(zip_bytes.clone()) .await .expect_err("failed because update is currently running"); @@ -942,7 +942,7 @@ async fn test_update_races() { // Try uploading the repository again -- since no updates are running, this // should succeed. wicketd_testctx - .wicketd_client + .commission_client .put_repository(zip_bytes) .await .expect("no updates currently running");