@@ -10,15 +10,13 @@ use anyhow::anyhow;
1010use futures:: StreamExt ;
1111use futures:: stream;
1212use nexus_db_queries:: context:: OpContext ;
13- use nexus_sled_agent_shared:: inventory:: OmicronSledConfigResult ;
1413use nexus_types:: deployment:: BlueprintSledConfig ;
1514use omicron_uuid_kinds:: GenericUuid ;
1615use omicron_uuid_kinds:: SledUuid ;
17- use slog:: Logger ;
1816use slog:: info;
1917use slog:: warn;
18+ use slog_error_chain:: InlineErrorChain ;
2019use std:: collections:: BTreeMap ;
21- use update_engine:: merge_anyhow_list;
2220
2321/// Idempotently ensure that the specified Omicron sled configs are deployed to
2422/// the corresponding sleds
@@ -63,13 +61,14 @@ pub(crate) async fn deploy_sled_configs(
6361 format ! ( "Failed to put {config:#?} to sled {sled_id}" )
6462 } ) ;
6563 match result {
64+ Ok ( _) => None ,
6665 Err ( error) => {
67- warn ! ( log, "{error:#}" ) ;
66+ warn ! (
67+ log, "failed to put sled config" ;
68+ InlineErrorChain :: new( error. as_ref( ) ) ,
69+ ) ;
6870 Some ( error)
6971 }
70- Ok ( result) => {
71- parse_config_result ( result. into_inner ( ) , & log) . err ( )
72- }
7372 }
7473 } )
7574 . collect ( )
@@ -78,69 +77,6 @@ pub(crate) async fn deploy_sled_configs(
7877 if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors) }
7978}
8079
81- fn parse_config_result (
82- result : OmicronSledConfigResult ,
83- log : & Logger ,
84- ) -> anyhow:: Result < ( ) > {
85- let ( disk_errs, disk_successes) : ( Vec < _ > , Vec < _ > ) =
86- result. disks . into_iter ( ) . partition ( |status| status. err . is_some ( ) ) ;
87-
88- if !disk_errs. is_empty ( ) {
89- warn ! (
90- log,
91- "Failed to deploy disks for sled agent" ;
92- "successfully configured disks" => disk_successes. len( ) ,
93- "failed disk configurations" => disk_errs. len( ) ,
94- ) ;
95- for err in & disk_errs {
96- warn ! ( log, "{err:?}" ) ;
97- }
98- return Err ( merge_anyhow_list ( disk_errs. into_iter ( ) . map ( |status| {
99- anyhow ! (
100- "failed to deploy disk {:?}: {:#}" ,
101- status. identity,
102- // `disk_errs` was partitioned by `status.err.is_some()`, so
103- // this is safe to unwrap.
104- status. err. unwrap( ) ,
105- )
106- } ) ) ) ;
107- }
108-
109- let ( dataset_errs, dataset_successes) : ( Vec < _ > , Vec < _ > ) =
110- result. datasets . into_iter ( ) . partition ( |status| status. err . is_some ( ) ) ;
111-
112- if !dataset_errs. is_empty ( ) {
113- warn ! (
114- log,
115- "Failed to deploy datasets for sled agent" ;
116- "successfully configured datasets" => dataset_successes. len( ) ,
117- "failed dataset configurations" => dataset_errs. len( ) ,
118- ) ;
119- for err in & dataset_errs {
120- warn ! ( log, "{err:?}" ) ;
121- }
122- return Err ( merge_anyhow_list ( dataset_errs. into_iter ( ) . map (
123- |status| {
124- anyhow ! (
125- "failed to deploy dataset {}: {:#}" ,
126- status. dataset_name. full_name( ) ,
127- // `dataset_errs` was partitioned by `status.err.is_some()`,
128- // so this is safe to unwrap.
129- status. err. unwrap( ) ,
130- )
131- } ,
132- ) ) ) ;
133- }
134-
135- info ! (
136- log,
137- "Successfully deployed config to sled agent" ;
138- "successfully configured disks" => disk_successes. len( ) ,
139- "successfully configured datasets" => dataset_successes. len( ) ,
140- ) ;
141- Ok ( ( ) )
142- }
143-
14480#[ cfg( test) ]
14581mod tests {
14682 use super :: * ;
@@ -326,6 +262,9 @@ mod tests {
326262
327263 // Observe the latest configuration stored on the simulated sled agent,
328264 // and verify that this output matches the input.
265+ //
266+ // TODO-cleanup Simulated sled-agent should report a unified
267+ // `OmicronSledConfig`.
329268 let observed_disks =
330269 sim_sled_agent. omicron_physical_disks_list ( ) . unwrap ( ) ;
331270 let observed_datasets = sim_sled_agent. datasets_config_list ( ) . unwrap ( ) ;
0 commit comments