4
4
5
5
//! Executable program to run the sled agent
6
6
7
- use dropshot:: ConfigDropshot ;
8
- use omicron_common:: api:: external:: Error ;
9
7
use omicron_common:: cmd:: fatal;
10
8
use omicron_common:: cmd:: CmdError ;
11
9
use omicron_sled_agent:: bootstrap:: {
@@ -15,42 +13,17 @@ use omicron_sled_agent::bootstrap::{
15
13
use omicron_sled_agent:: rack_setup:: config:: SetupServiceConfig as RssConfig ;
16
14
use omicron_sled_agent:: { config:: Config as SledConfig , server as sled_server} ;
17
15
use sp_sim:: config:: GimletConfig ;
18
- use std:: net:: SocketAddr ;
19
16
use std:: path:: PathBuf ;
20
17
use structopt:: StructOpt ;
21
18
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
-
43
19
#[ derive( Debug , StructOpt ) ]
44
20
#[ structopt(
45
21
name = "sled_agent" ,
46
22
about = "See README.adoc for more information"
47
23
) ]
48
24
enum Args {
49
25
/// Generates the OpenAPI specification.
50
- Openapi {
51
- #[ structopt( name = "api_type" , parse( try_from_str) ) ]
52
- api_requested : ApiRequest ,
53
- } ,
26
+ Openapi ,
54
27
/// Runs the Sled Agent server.
55
28
Run {
56
29
#[ structopt( name = "CONFIG_FILE_PATH" , parse( from_os_str) ) ]
@@ -71,14 +44,7 @@ async fn do_run() -> Result<(), CmdError> {
71
44
} ) ?;
72
45
73
46
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 ) ,
82
48
Args :: Run { config_path } => {
83
49
let config = SledConfig :: from_file ( & config_path)
84
50
. map_err ( |e| CmdError :: Failure ( e. to_string ( ) ) ) ?;
@@ -131,46 +97,12 @@ async fn do_run() -> Result<(), CmdError> {
131
97
let bootstrap_address = bootstrap_address ( link)
132
98
. map_err ( |e| CmdError :: Failure ( e. to_string ( ) ) ) ?;
133
99
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
-
163
100
// Configure and run the Bootstrap server.
164
101
let bootstrap_config = BootstrapConfig {
165
102
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,
171
104
log : config. log . clone ( ) ,
172
105
rss_config,
173
- sprockets_proxy_bind_addr,
174
106
sp_config,
175
107
} ;
176
108
0 commit comments