Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions openapi/wicketd.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
14 changes: 7 additions & 7 deletions wicket/src/cli/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -36,27 +36,27 @@ impl ShellApp {
pub(crate) async fn exec(
self,
log: slog::Logger,
wicketd_addr: SocketAddrV6,
addrs: WicketdAddrs,
output: CommandOutput<'_>,
) -> Result<ExitCode> {
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)
}
}
Expand Down
18 changes: 5 additions & 13 deletions wicket/src/cli/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
Expand All @@ -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")?;
Expand Down
12 changes: 4 additions & 8 deletions wicket/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ pub fn exec() -> Result<ExitCode> {

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
Expand All @@ -68,7 +64,7 @@ pub enum OutputKind<'a> {
}

pub async fn exec_with_args<S>(
wicketd_addr: SocketAddrV6,
addrs: WicketdAddrs,
args: Vec<S>,
output: OutputKind<'_>,
) -> Result<ExitCode>
Expand All @@ -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(
Expand All @@ -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
}
}
}
Expand Down
19 changes: 0 additions & 19 deletions wicketd-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -202,20 +197,6 @@ pub trait WicketdApi {
body_params: TypedBody<GetInventoryParams>,
) -> Result<HttpResponseOk<GetInventoryResponse>, 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<Self::Context>,
body: StreamingBody,
) -> Result<HttpResponseUpdatedNoContent, HttpError>;

/// An endpoint used to report all available artifacts and event reports.
///
/// The order of the returned artifacts is unspecified, and may change between
Expand Down
12 changes: 0 additions & 12 deletions wicketd/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -390,17 +389,6 @@ impl WicketdApi for WicketdApiImpl {
Ok(HttpResponseOk(GetInventoryResponse::Response { inventory }))
}

async fn put_repository(
rqctx: RequestContext<Self::Context>,
body: StreamingBody,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let rqctx = rqctx.context();

rqctx.update_tracker.put_repository(body.into_stream()).await?;

Ok(HttpResponseUpdatedNoContent())
}

async fn get_artifacts_and_event_reports(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<GetArtifactsAndEventReportsResponse>, HttpError>
Expand Down
2 changes: 1 addition & 1 deletion wicketd/tests/integration_tests/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
8 changes: 6 additions & 2 deletions wicketd/tests/integration_tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ 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,
};
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.
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions wicketd/tests/integration_tests/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
Loading