@@ -7,7 +7,7 @@ use std::{
77} ;
88
99use chrono:: Utc ;
10- use log:: { debug, error, info, warn} ;
10+ use log:: { debug, error, info, trace , warn} ;
1111
1212use osutils:: { dependencies:: Dependency , path:: join_relative} ;
1313use trident_api:: {
@@ -81,12 +81,10 @@ pub(crate) trait Subsystem: Send {
8181 // TODO: Implement dependencies
8282 // fn dependencies(&self) -> &'static [&'static str];
8383
84- /// Select the servicing type based on the Host Status and Host Configuration.
85- fn select_servicing_type ( & self , ctx : & EngineContext ) -> Result < ServicingType , TridentError > {
86- if is_default ( & ctx. spec_old ) {
87- return Ok ( ServicingType :: CleanInstall ) ;
88- }
89- Ok ( ServicingType :: AbUpdate )
84+ /// Select the servicing type based on information in the Host Status
85+ /// relevant to a subsystem.
86+ fn select_servicing_type ( & self , _ctx : & EngineContext ) -> Result < ServicingType , TridentError > {
87+ Ok ( ServicingType :: NoActiveServicing )
9088 }
9189
9290 /// Servicing types on which a subsystem may run. By default, all subsystems
@@ -256,6 +254,28 @@ fn persist_background_log_and_metrics(
256254 }
257255}
258256
257+ fn select_servicing_type (
258+ subsystems : & [ Box < dyn Subsystem > ] ,
259+ ctx : & EngineContext ,
260+ ) -> Result < ServicingType , TridentError > {
261+ if is_default ( & ctx. spec_old ) {
262+ return Ok ( ServicingType :: CleanInstall ) ;
263+ } else if ctx
264+ . ab_update_required ( )
265+ . message ( "Failed to determine if A/B update is required" ) ?
266+ {
267+ return Ok ( ServicingType :: AbUpdate ) ;
268+ }
269+
270+ Ok ( subsystems
271+ . iter ( )
272+ . map ( |m| m. select_servicing_type ( ctx) )
273+ . collect :: < Result < Vec < _ > , TridentError > > ( ) ?
274+ . into_iter ( )
275+ . max ( )
276+ . unwrap_or ( ServicingType :: NoActiveServicing ) )
277+ }
278+
259279#[ tracing:: instrument( skip_all) ]
260280fn validate_host_config (
261281 subsystems : & [ Box < dyn Subsystem > ] ,
@@ -273,7 +293,7 @@ fn validate_host_config(
273293 subsystem. name( )
274294 ) ) ?;
275295 } else {
276- debug ! (
296+ trace ! (
277297 "Skipping step 'Validate' for subsystem '{}'" ,
278298 subsystem. name( )
279299 ) ;
@@ -296,7 +316,7 @@ fn prepare(subsystems: &mut [Box<dyn Subsystem>], ctx: &EngineContext) -> Result
296316 subsystem. name( )
297317 ) ) ?;
298318 } else {
299- debug ! (
319+ trace ! (
300320 "Skipping step 'Prepare' for subsystem '{}'" ,
301321 subsystem. name( )
302322 ) ;
@@ -335,7 +355,7 @@ fn provision(
335355 subsystem. name( )
336356 ) ) ?;
337357 } else {
338- debug ! (
358+ trace ! (
339359 "Skipping step 'Provision' for subsystem '{}'" ,
340360 subsystem. name( )
341361 ) ;
@@ -377,7 +397,7 @@ fn configure(
377397 subsystem. name( )
378398 ) ) ?;
379399 } else {
380- debug ! (
400+ trace ! (
381401 "Skipping step 'Configure' for subsystem '{}'" ,
382402 subsystem. name( )
383403 ) ;
@@ -404,7 +424,7 @@ fn update_host_configuration(
404424 subsystem. name( )
405425 ) ) ?;
406426 } else {
407- debug ! (
427+ trace ! (
408428 "Skipping step 'Update Host Configuration' for subsystem '{}'" ,
409429 subsystem. name( )
410430 ) ;
@@ -427,7 +447,7 @@ fn clean_up(subsystems: &[Box<dyn Subsystem>], ctx: &EngineContext) -> Result<()
427447 subsystem. name( )
428448 ) ) ?;
429449 } else {
430- debug ! (
450+ trace ! (
431451 "Skipping step 'Clean Up' for subsystem '{}'" ,
432452 subsystem. name( )
433453 ) ;
0 commit comments