@@ -419,20 +419,27 @@ pub async fn handle_instance_change(
419
419
}
420
420
} ;
421
421
if let Some ( broker_spec) = & configuration. spec . broker_spec {
422
- match broker_spec {
422
+ let instance_change_result = match broker_spec {
423
423
BrokerSpec :: BrokerPodSpec ( p) => {
424
424
handle_instance_change_pod ( instance, p, action, kube_interface) . await
425
425
}
426
426
BrokerSpec :: BrokerJobSpec ( j) => {
427
427
handle_instance_change_job (
428
- instance. clone ( ) ,
428
+ instance,
429
429
* configuration. metadata . generation . as_ref ( ) . unwrap ( ) ,
430
430
j,
431
431
action,
432
432
kube_interface,
433
433
)
434
434
. await
435
435
}
436
+ } ;
437
+ match instance_change_result {
438
+ Ok ( _) => Ok ( ( ) ) ,
439
+ Err ( e) => {
440
+ error ! ( "Unable to handle Broker action: {:?}" , e) ;
441
+ Ok ( ( ) )
442
+ }
436
443
}
437
444
} else {
438
445
Ok ( ( ) )
@@ -444,7 +451,7 @@ pub async fn handle_instance_change(
444
451
/// InstanceAction::Remove => Delete all Jobs labeled with the Instance name
445
452
/// InstanceAction::Update => No nothing
446
453
pub async fn handle_instance_change_job (
447
- instance : Instance ,
454
+ instance : & Instance ,
448
455
config_generation : i64 ,
449
456
job_spec : & JobSpec ,
450
457
action : & InstanceAction ,
@@ -472,7 +479,7 @@ pub async fn handle_instance_change_job(
472
479
trace ! ( "handle_instance_change_job - instance added" ) ;
473
480
let capability_id = format ! ( "{}/{}" , AKRI_PREFIX , instance_name) ;
474
481
let new_job = job:: create_new_job_from_spec (
475
- & instance,
482
+ instance,
476
483
OwnershipInfo :: new (
477
484
OwnershipType :: Instance ,
478
485
instance_name. to_string ( ) ,
@@ -841,13 +848,15 @@ mod handle_instance_tests {
841
848
new_pod_names : Vec < & ' static str > ,
842
849
new_pod_instance_names : Vec < & ' static str > ,
843
850
new_pod_namespaces : Vec < & ' static str > ,
851
+ new_pod_error : Vec < bool > ,
844
852
}
845
853
846
854
fn configure_add_shared_config_a_359973 ( pod_name : & ' static str ) -> HandleAdditionWork {
847
855
HandleAdditionWork {
848
856
new_pod_names : vec ! [ pod_name] ,
849
857
new_pod_instance_names : vec ! [ "config-a-359973" ] ,
850
858
new_pod_namespaces : vec ! [ "config-a-namespace" ] ,
859
+ new_pod_error : vec ! [ false ] ,
851
860
}
852
861
}
853
862
fn get_config_work ( ) -> HandleConfigWork {
@@ -857,11 +866,12 @@ mod handle_instance_tests {
857
866
find_config_result : "../test/json/config-a.json" ,
858
867
}
859
868
}
860
- fn configure_add_local_config_a_b494b6 ( ) -> HandleAdditionWork {
869
+ fn configure_add_local_config_a_b494b6 ( error : bool ) -> HandleAdditionWork {
861
870
HandleAdditionWork {
862
871
new_pod_names : vec ! [ "config-a-b494b6-pod" ] ,
863
872
new_pod_instance_names : vec ! [ "config-a-b494b6" ] ,
864
873
new_pod_namespaces : vec ! [ "config-a-namespace" ] ,
874
+ new_pod_error : vec ! [ error] ,
865
875
}
866
876
}
867
877
@@ -873,6 +883,7 @@ mod handle_instance_tests {
873
883
work. new_pod_namespaces [ i] ,
874
884
AKRI_INSTANCE_LABEL_NAME ,
875
885
work. new_pod_instance_names [ i] ,
886
+ work. new_pod_error [ i] ,
876
887
) ;
877
888
}
878
889
}
@@ -944,7 +955,33 @@ mod handle_instance_tests {
944
955
find_pods_delete_start_time : false ,
945
956
config_work : get_config_work ( ) ,
946
957
deletion_work : None ,
947
- addition_work : Some ( configure_add_local_config_a_b494b6 ( ) ) ,
958
+ addition_work : Some ( configure_add_local_config_a_b494b6 ( false ) ) ,
959
+ } ,
960
+ ) ;
961
+ run_handle_instance_change_test (
962
+ & mut mock,
963
+ "../test/json/local-instance.json" ,
964
+ & InstanceAction :: Add ,
965
+ )
966
+ . await ;
967
+ }
968
+
969
+ #[ tokio:: test]
970
+ async fn test_handle_instance_change_for_add_new_local_instance_error ( ) {
971
+ let _ = env_logger:: builder ( ) . is_test ( true ) . try_init ( ) ;
972
+
973
+ let mut mock = MockKubeInterface :: new ( ) ;
974
+ configure_for_handle_instance_change (
975
+ & mut mock,
976
+ & HandleInstanceWork {
977
+ find_pods_selector : "akri.sh/instance=config-a-b494b6" ,
978
+ find_pods_result : "../test/json/empty-list.json" ,
979
+ find_pods_phase : None ,
980
+ find_pods_start_time : None ,
981
+ find_pods_delete_start_time : false ,
982
+ config_work : get_config_work ( ) ,
983
+ deletion_work : None ,
984
+ addition_work : Some ( configure_add_local_config_a_b494b6 ( true ) ) ,
948
985
} ,
949
986
) ;
950
987
run_handle_instance_change_test (
@@ -1139,7 +1176,7 @@ mod handle_instance_tests {
1139
1176
find_pods_delete_start_time : false ,
1140
1177
config_work : get_config_work ( ) ,
1141
1178
deletion_work : None ,
1142
- addition_work : Some ( configure_add_local_config_a_b494b6 ( ) ) ,
1179
+ addition_work : Some ( configure_add_local_config_a_b494b6 ( false ) ) ,
1143
1180
} ,
1144
1181
) ;
1145
1182
run_handle_instance_change_test (
0 commit comments