Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
23 changes: 0 additions & 23 deletions openapi/wicketd.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,29 +319,6 @@
"$ref": "#/components/responses/Error"
}
}
},
"post": {
"summary": "Run rack setup.",
"description": "Will return an error if not all of the rack setup configuration has been populated.",
"operationId": "post_run_rack_setup",
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RackInitUuid"
}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
}
}
},
"/rack-setup/config": {
Expand Down
14 changes: 8 additions & 6 deletions wicket/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ use slog::Drain;
use crate::{
Runner,
cli::{CommandOutput, ShellApp},
wicketd::WicketdAddrs,
};

pub fn exec() -> Result<ExitCode> {
let wicketd_addr =
SocketAddrV6::new(Ipv6Addr::LOCALHOST, WICKETD_PORT, 0, 0);
let commission_addr =
SocketAddrV6::new(Ipv6Addr::LOCALHOST, WICKETD_COMMISSION_PORT, 0, 0);
let localhost = Ipv6Addr::LOCALHOST;
let addrs = WicketdAddrs {
wicketd: SocketAddrV6::new(localhost, WICKETD_PORT, 0, 0),
commission: SocketAddrV6::new(localhost, WICKETD_COMMISSION_PORT, 0, 0),
};

// SSH_ORIGINAL_COMMAND contains additional arguments, if any.
match std::env::var("SSH_ORIGINAL_COMMAND") {
Expand All @@ -37,7 +39,7 @@ pub fn exec() -> Result<ExitCode> {
let runtime = tokio::runtime::Runtime::new()
.context("creating tokio runtime")?;
runtime.block_on(exec_with_args(
wicketd_addr,
addrs.wicketd,
args,
OutputKind::Terminal,
))
Expand All @@ -46,7 +48,7 @@ pub fn exec() -> Result<ExitCode> {
// Do not expose log messages via standard error since they'll show up
// on top of the TUI.
let log = setup_log(&log_path()?, WithStderr::No)?;
Runner::new(log, wicketd_addr, commission_addr).run()?;
Runner::new(log, addrs).run()?;
Ok(ExitCode::SUCCESS)
}
}
Expand Down
1 change: 1 addition & 0 deletions wicket/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ pub use events::{Action, Event, Recorder, Snapshot};
pub use keymap::{Cmd, KeyHandler};
pub use state::State;
pub use ui::{Control, Screen};
pub use wicketd::WicketdAddrs;
17 changes: 4 additions & 13 deletions wicket/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use slog::Logger;
use slog::{debug, error, info};
use slog_error_chain::InlineErrorChain;
use std::io::{Stdout, stdout};
use std::net::SocketAddrV6;
use std::time::Instant;
use tokio::sync::mpsc::{
UnboundedReceiver, UnboundedSender, unbounded_channel,
Expand All @@ -30,7 +29,7 @@ use crate::helpers::get_update_test_error;
use crate::state::CreateClearUpdateStateOptions;
use crate::state::CreateStartUpdateOptions;
use crate::ui::Screen;
use crate::wicketd::{self, WicketdHandle, WicketdManager};
use crate::wicketd::{self, WicketdAddrs, WicketdHandle, WicketdManager};
use crate::{Action, Cmd, Event, KeyHandler, Recorder, State, TICK_INTERVAL};

// We can avoid a bunch of unnecessary type parameters by picking them ahead of time.
Expand Down Expand Up @@ -283,22 +282,14 @@ pub struct Runner {

#[allow(clippy::new_without_default)]
impl Runner {
pub fn new(
log: slog::Logger,
wicketd_addr: SocketAddrV6,
commission_addr: SocketAddrV6,
) -> Runner {
pub fn new(log: slog::Logger, addrs: WicketdAddrs) -> Runner {
let (events_tx, events_rx) = unbounded_channel();
let tokio_rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap();
let (wicketd, wicketd_manager) = WicketdManager::new(
&log,
events_tx.clone(),
wicketd_addr,
commission_addr,
);
let (wicketd, wicketd_manager) =
WicketdManager::new(&log, events_tx.clone(), addrs);
let core = RunnerCore::new(log);
Runner {
core,
Expand Down
45 changes: 23 additions & 22 deletions wicket/src/wicketd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ use crate::keymap::ShowPopupCmd;
use crate::state::ComponentId;
use crate::{Cmd, Event};

/// The addresses of the wicketd server.
#[derive(Clone, Copy, Debug)]
pub struct WicketdAddrs {
/// The address of the lockstep wicketd API.
pub wicketd: SocketAddrV6,
/// The address of the stable commission API.
pub commission: SocketAddrV6,
}

impl From<ComponentId> for SpIdentifier {
fn from(id: ComponentId) -> Self {
match id {
Expand Down Expand Up @@ -78,27 +87,19 @@ pub struct WicketdManager {
log: Logger,
rx: mpsc::Receiver<Request>,
events_tx: UnboundedSender<Event>,
wicketd_addr: SocketAddrV6,
commission_addr: SocketAddrV6,
addrs: WicketdAddrs,
}

impl WicketdManager {
pub fn new(
log: &Logger,
events_tx: UnboundedSender<Event>,
wicketd_addr: SocketAddrV6,
commission_addr: SocketAddrV6,
addrs: WicketdAddrs,
) -> (WicketdHandle, WicketdManager) {
let log = log.new(o!("component" => "WicketdManager"));
let (tx, rx) = tokio::sync::mpsc::channel(CHANNEL_CAPACITY);
let handle = WicketdHandle { tx };
let manager = WicketdManager {
log,
rx,
events_tx,
wicketd_addr,
commission_addr,
};
let manager = WicketdManager { log, rx, events_tx, addrs };

(handle, manager)
}
Expand Down Expand Up @@ -164,7 +165,7 @@ impl WicketdManager {
options: StartUpdateOptions,
) {
let log = self.log.clone();
let addr = self.wicketd_addr;
let addr = self.addrs.wicketd;
let events_tx = self.events_tx.clone();
tokio::spawn(async move {
let update_client =
Expand Down Expand Up @@ -197,7 +198,7 @@ impl WicketdManager {
options: AbortUpdateOptions,
) {
let log = self.log.clone();
let addr = self.wicketd_addr;
let addr = self.addrs.wicketd;
let events_tx = self.events_tx.clone();
tokio::spawn(async move {
let update_client =
Expand Down Expand Up @@ -229,7 +230,7 @@ impl WicketdManager {
options: ClearUpdateStateOptions,
) {
let log = self.log.clone();
let addr = self.wicketd_addr;
let addr = self.addrs.wicketd;
let events_tx = self.events_tx.clone();
tokio::spawn(async move {
let update_client =
Expand Down Expand Up @@ -266,7 +267,7 @@ impl WicketdManager {
poll_inventory_now: mpsc::Sender<SpIdentifier>,
) {
let log = self.log.clone();
let addr = self.wicketd_addr;
let addr = self.addrs.wicketd;
tokio::spawn(async move {
let client = create_wicketd_client(&log, addr, WICKETD_TIMEOUT);
let sp: SpIdentifier = component_id.into();
Expand All @@ -290,10 +291,10 @@ impl WicketdManager {

fn start_rack_initialization(&self) {
let log = self.log.clone();
let addr = self.wicketd_addr;
let addr = self.addrs.commission;
let events_tx = self.events_tx.clone();
tokio::spawn(async move {
let client = create_wicketd_client(&log, addr, WICKETD_TIMEOUT);
let client = create_commission_client(&log, addr, WICKETD_TIMEOUT);
let response = match client.post_run_rack_setup().await {
Ok(_) => Ok(()),
Err(error) => Err(error.to_string()),
Expand All @@ -309,7 +310,7 @@ impl WicketdManager {
fn poll_rack_setup_status(&self) {
let log = self.log.clone();
let tx = self.events_tx.clone();
let addr = self.wicketd_addr;
let addr = self.addrs.wicketd;
tokio::spawn(async move {
let client = create_wicketd_client(&log, addr, WICKETD_TIMEOUT);
let mut ticker = interval(WICKETD_POLL_INTERVAL * 2);
Expand All @@ -335,7 +336,7 @@ impl WicketdManager {
fn poll_location(&self) {
let log = self.log.clone();
let tx = self.events_tx.clone();
let addr = self.commission_addr;
let addr = self.addrs.commission;
tokio::spawn(async move {
let client = create_commission_client(&log, addr, WICKETD_TIMEOUT);
let mut ticker = interval(WICKETD_POLL_INTERVAL * 2);
Expand Down Expand Up @@ -393,7 +394,7 @@ impl WicketdManager {
fn poll_rack_setup_config(&self) {
let log = self.log.clone();
let tx = self.events_tx.clone();
let addr = self.wicketd_addr;
let addr = self.addrs.wicketd;
tokio::spawn(async move {
let client = create_wicketd_client(&log, addr, WICKETD_TIMEOUT);
let mut ticker = interval(WICKETD_POLL_INTERVAL * 2);
Expand Down Expand Up @@ -426,7 +427,7 @@ impl WicketdManager {
fn poll_artifacts_and_event_reports(&self) {
let log = self.log.clone();
let tx = self.events_tx.clone();
let addr = self.wicketd_addr;
let addr = self.addrs.wicketd;
tokio::spawn(async move {
let client = create_wicketd_client(&log, addr, WICKETD_TIMEOUT);
let mut ticker = interval(WICKETD_POLL_INTERVAL * 2);
Expand Down Expand Up @@ -455,7 +456,7 @@ impl WicketdManager {
fn poll_inventory(&self, mut poll_now: mpsc::Receiver<SpIdentifier>) {
let log = self.log.clone();
let tx = self.events_tx.clone();
let addr = self.wicketd_addr;
let addr = self.addrs.wicketd;

tokio::spawn(async move {
let client = create_wicketd_client(&log, addr, WICKETD_TIMEOUT);
Expand Down
13 changes: 0 additions & 13 deletions wicketd-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use dropshot::RequestContext;
use dropshot::StreamingBody;
use dropshot::TypedBody;
use gateway_client::types::IgnitionCommand;
use omicron_uuid_kinds::RackInitUuid;
use schemars::JsonSchema;
use semver::Version;
use serde::Deserialize;
Expand Down Expand Up @@ -186,18 +185,6 @@ pub trait WicketdApi {
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<RackOperationStatus>, HttpError>;

/// Run rack setup.
///
/// Will return an error if not all of the rack setup configuration has
/// been populated.
#[endpoint {
method = POST,
path = "/rack-setup"
}]
async fn post_run_rack_setup(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<RackInitUuid>, HttpError>;

/// A status endpoint used to report high level information known to
/// wicketd.
///
Expand Down
2 changes: 1 addition & 1 deletion wicketd/src/commission/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! The stable wicketd commissioning API.
//!
//! This API is used by automated tooling such as rkdeploy to commission new
//! racks. It is a reduced subset of the full, unstable wicketd API.
//! racks.
//!
//! **Automation must always use the stable API!**
//!
Expand Down
36 changes: 0 additions & 36 deletions wicketd/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::mgs::GetInventoryResponse as GetMgsInventoryResponse;
use crate::mgs::records_to_mgs_inventory;
use crate::multirack_config::CurrentMultirackJoinConfig;
use crate::transceivers::GetTransceiversResponse;
use bootstrap_agent_lockstep_client::ClientInfo as _;
use bootstrap_agent_lockstep_types::RackOperationStatus;
use dropshot::ApiDescription;
use dropshot::HttpError;
Expand All @@ -26,7 +25,6 @@ use dropshot::RequestContext;
use dropshot::StreamingBody;
use dropshot::TypedBody;
use internal_dns_resolver::Resolver;
use omicron_uuid_kinds::RackInitUuid;
use sled_agent_types::early_networking::SwitchSlot;
use slog::o;
use std::sync::Arc;
Expand Down Expand Up @@ -310,40 +308,6 @@ impl WicketdApi for WicketdApiImpl {
Ok(HttpResponseOk(op_status))
}

async fn post_run_rack_setup(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<RackInitUuid>, HttpError> {
let ctx = rqctx.context();
let log = &rqctx.log;

let client = ba_lockstep_client(ctx);
let request = {
let mut config = ctx.rss_or_multirack_join_config.lock().unwrap();

let rss_config = config.rss_config_mut_or_conflict(
"cannot run rack setup when not preparing for RSS",
)?;

rss_config.start_rss_request(&ctx.bootstrap_peers, log).map_err(
|err| HttpError::for_bad_request(None, format!("{err:#}")),
)?
};

slog::info!(
ctx.log,
"Sending RSS initialize request to {}",
client.baseurl()
);

let init_id = client
.rack_initialize(&request)
.await
.map_err(|err| ba_lockstep_error_to_http(err, "rack setup"))?
.into_inner();

Ok(HttpResponseOk(init_id))
}

async fn get_inventory(
rqctx: RequestContext<Self::Context>,
body_params: TypedBody<GetInventoryParams>,
Expand Down
Loading