@@ -154,9 +154,7 @@ async fn handle_config(
154
154
}
155
155
// If a config is updated, delete all associated instances and device plugins and then recreate them to reflect updated config
156
156
WatchEvent :: Modified ( config) => {
157
- let do_recreate = should_recreate_config ( & config, config_map. clone ( ) )
158
- . await
159
- . unwrap ( ) ;
157
+ let do_recreate = should_recreate_config ( & config, config_map. clone ( ) ) . await ?;
160
158
if !do_recreate {
161
159
trace ! (
162
160
"handle_config - config {:?} has not changed. ignoring config modified event." ,
@@ -294,13 +292,20 @@ async fn handle_config_delete(
294
292
/// Checks to see if the configuration needs to be recreated.
295
293
/// At present, this just checks to see if the `.metadata.generation` has changed.
296
294
/// The `.metadata.generation` value is incremented for all changes, except for changes to `.metadata` or `.status`.
297
- async fn should_recreate_config ( config : & Configuration , config_map : ConfigMap ) -> Result < bool , ( ) > {
295
+ async fn should_recreate_config (
296
+ config : & Configuration ,
297
+ config_map : ConfigMap ,
298
+ ) -> Result < bool , anyhow:: Error > {
298
299
let name = config. metadata . name . clone ( ) . unwrap ( ) ;
299
- let last_generation = config_map. lock ( ) . await . get ( & name) . unwrap ( ) . last_generation ;
300
- trace ! (
301
- "should_recreate_config - checking if config {} needs to be recreated" ,
302
- name,
303
- ) ;
300
+ let last_generation = config_map
301
+ . lock ( )
302
+ . await
303
+ . get ( & name)
304
+ . ok_or ( anyhow:: anyhow!(
305
+ "Configuration {} not found in ConfigMap" ,
306
+ name
307
+ ) ) ?
308
+ . last_generation ;
304
309
305
310
if config. metadata . generation == last_generation {
306
311
return Ok ( false ) ;
0 commit comments