Skip to content

Commit 4a3815b

Browse files
authored
Replace bootstrap-agent dropshot server with sprockets session (#1173)
Removes sprockets proxies, fixing #1161.
1 parent 5c76e0e commit 4a3815b

File tree

16 files changed

+459
-609
lines changed

16 files changed

+459
-609
lines changed

Cargo.lock

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/bootstrap-agent.json

Lines changed: 0 additions & 199 deletions
This file was deleted.

sled-agent/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ smf = "0.2"
3737
spdm = { git = "https://github.com/oxidecomputer/spdm", rev = "9742f6e" }
3838
sp-sim = { path = "../sp-sim" }
3939
sprockets-host = { git = "http://github.com/oxidecomputer/sprockets", rev = "0361fd13ff19cda6696242fe40f1325fca30d3d1" }
40-
sprockets-proxy = { git = "http://github.com/oxidecomputer/sprockets", rev = "0361fd13ff19cda6696242fe40f1325fca30d3d1" }
4140
socket2 = { version = "0.4", features = [ "all" ] }
4241
structopt = "0.3"
4342
tar = "0.4"

sled-agent/src/bin/sled-agent.rs

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
//! Executable program to run the sled agent
66
7-
use dropshot::ConfigDropshot;
8-
use omicron_common::api::external::Error;
97
use omicron_common::cmd::fatal;
108
use omicron_common::cmd::CmdError;
119
use omicron_sled_agent::bootstrap::{
@@ -15,42 +13,17 @@ use omicron_sled_agent::bootstrap::{
1513
use omicron_sled_agent::rack_setup::config::SetupServiceConfig as RssConfig;
1614
use omicron_sled_agent::{config::Config as SledConfig, server as sled_server};
1715
use sp_sim::config::GimletConfig;
18-
use std::net::SocketAddr;
1916
use std::path::PathBuf;
2017
use structopt::StructOpt;
2118

22-
#[derive(Debug)]
23-
enum ApiRequest {
24-
Bootstrap,
25-
Sled,
26-
}
27-
28-
impl std::str::FromStr for ApiRequest {
29-
type Err = Error;
30-
fn from_str(s: &str) -> Result<Self, Self::Err> {
31-
match s {
32-
"bootstrap" => Ok(ApiRequest::Bootstrap),
33-
"sled" => Ok(ApiRequest::Sled),
34-
_ => Err(Error::InvalidValue {
35-
label: s.to_string(),
36-
message: "Invalid value: try one of {bootstrap, sled}"
37-
.to_string(),
38-
}),
39-
}
40-
}
41-
}
42-
4319
#[derive(Debug, StructOpt)]
4420
#[structopt(
4521
name = "sled_agent",
4622
about = "See README.adoc for more information"
4723
)]
4824
enum Args {
4925
/// Generates the OpenAPI specification.
50-
Openapi {
51-
#[structopt(name = "api_type", parse(try_from_str))]
52-
api_requested: ApiRequest,
53-
},
26+
Openapi,
5427
/// Runs the Sled Agent server.
5528
Run {
5629
#[structopt(name = "CONFIG_FILE_PATH", parse(from_os_str))]
@@ -71,14 +44,7 @@ async fn do_run() -> Result<(), CmdError> {
7144
})?;
7245

7346
match args {
74-
Args::Openapi { api_requested } => match api_requested {
75-
ApiRequest::Bootstrap => {
76-
bootstrap_server::run_openapi().map_err(CmdError::Failure)
77-
}
78-
ApiRequest::Sled => {
79-
sled_server::run_openapi().map_err(CmdError::Failure)
80-
}
81-
},
47+
Args::Openapi => sled_server::run_openapi().map_err(CmdError::Failure),
8248
Args::Run { config_path } => {
8349
let config = SledConfig::from_file(&config_path)
8450
.map_err(|e| CmdError::Failure(e.to_string()))?;
@@ -131,46 +97,12 @@ async fn do_run() -> Result<(), CmdError> {
13197
let bootstrap_address = bootstrap_address(link)
13298
.map_err(|e| CmdError::Failure(e.to_string()))?;
13399

134-
// Are we going to simulate a local SP? If so:
135-
//
136-
// 1. The bootstrap dropshot server listens on localhost
137-
// 2. A sprockets proxy listens on `bootstrap_address` (and relays
138-
// incoming connections to the localhost dropshot server)
139-
//
140-
// If we're not simulating a local SP, we can't establish sprockets
141-
// sessions, so we'll have the bootstrap dropshot server listen on
142-
// `bootstrap_address` (and no sprockets proxy).
143-
//
144-
// TODO-security: With this configuration, dropshot itself is
145-
// running plain HTTP and blindly trusting all connections from
146-
// localhost. We have a similar sprockets proxy on the client side,
147-
// where the proxy blindly trusts all connections from localhost
148-
// (although the client-side proxy only runs while is being made,
149-
// while our dropshot server is always listening). Can we secure
150-
// these connections sufficiently? Other options include expanding
151-
// dropshot/progenitor to allow a custom connection layer (supported
152-
// by hyper, but not reqwest), keeping the sprockets proxy but using
153-
// something other than TCP that we can lock down, or abandoning
154-
// dropshot and using a bespoke protocol over a raw
155-
// sprockets-encrypted TCP connection.
156-
let (bootstrap_dropshot_addr, sprockets_proxy_bind_addr) =
157-
if sp_config.is_some() {
158-
("[::1]:0".parse().unwrap(), Some(bootstrap_address))
159-
} else {
160-
(SocketAddr::V6(bootstrap_address), None)
161-
};
162-
163100
// Configure and run the Bootstrap server.
164101
let bootstrap_config = BootstrapConfig {
165102
id: config.id,
166-
dropshot: ConfigDropshot {
167-
bind_address: bootstrap_dropshot_addr,
168-
request_body_max_bytes: 1024 * 1024,
169-
..Default::default()
170-
},
103+
bind_address: bootstrap_address,
171104
log: config.log.clone(),
172105
rss_config,
173-
sprockets_proxy_bind_addr,
174106
sp_config,
175107
};
176108

sled-agent/src/bootstrap/agent.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,14 @@ impl Agent {
210210
)?,
211211
)
212212
.map_err(|err| BootstrapError::Toml { path: request_path, err })?;
213-
agent.request_agent(sled_request).await?;
213+
agent.request_agent(&sled_request).await?;
214214
}
215215

216216
Ok(agent)
217217
}
218218

219219
/// Implements the "request share" API.
220+
#[allow(dead_code)] // Currently uncalled; will be used soon!
220221
pub async fn request_share(
221222
&self,
222223
identity: Vec<u8>,
@@ -234,7 +235,7 @@ impl Agent {
234235
/// been initialized.
235236
pub async fn request_agent(
236237
&self,
237-
request: SledAgentRequest,
238+
request: &SledAgentRequest,
238239
) -> Result<SledAgentResponse, BootstrapError> {
239240
info!(&self.log, "Loading Sled Agent: {:?}", request);
240241

0 commit comments

Comments
 (0)