@@ -985,30 +985,36 @@ async function update_endpoint_group(req) {
985985 . some ( group => group . name === group_name ) ;
986986
987987 if ( exists ) {
988+ const group = cluster . endpoint_groups . find ( grp => grp . name === group_name ) ;
988989 if ( ! _ . isUndefined ( is_remote ) ) {
989- const group = cluster . endpoint_groups . find ( grp => grp . name === group_name ) ;
990990 if ( group . is_remote !== is_remote ) {
991991 // We do not throw in order to not fail the noobaa operator.
992992 dbg . warn ( 'update_endpoint_group: Conflicted is_remote value of ' ,
993993 is_remote , ' for group: ' , group , ' - aborting request' ) ;
994994 return ;
995995 }
996+
996997 }
997998
998- await system_store . make_changes ( {
999- update : {
1000- clusters : [ {
1001- $find : {
1002- _id : cluster . _id ,
1003- 'endpoint_groups.name' : group_name
1004- } ,
1005- $set : {
1006- 'endpoint_groups.$.region' : region ,
1007- 'endpoint_groups.$.endpoint_range' : endpoint_range
1008- }
1009- } ]
1010- }
1011- } ) ;
999+ // call make_changes only if there are actual changes to make.
1000+ // this check fixes a bug where make_changes sends a load_system_store notification
1001+ // to the operator, which in its own reconcile sends back update_endpoint_group, and so forth
1002+ if ( group . region !== region || ! _ . isEqual ( group . endpoint_range , endpoint_range ) ) {
1003+ await system_store . make_changes ( {
1004+ update : {
1005+ clusters : [ {
1006+ $find : {
1007+ _id : cluster . _id ,
1008+ 'endpoint_groups.name' : group_name
1009+ } ,
1010+ $set : {
1011+ 'endpoint_groups.$.region' : region ,
1012+ 'endpoint_groups.$.endpoint_range' : endpoint_range
1013+ }
1014+ } ]
1015+ }
1016+ } ) ;
1017+ }
10121018
10131019 } else {
10141020 await system_store . make_changes ( {
0 commit comments