@@ -219,6 +219,28 @@ def _get_synapse_config(container: ops.model.Container) -> dict:
219
219
raise PebbleServiceError (str (exc )) from exc
220
220
221
221
222
+ def _get_mas_config (container : ops .model .Container ) -> dict :
223
+ """Get the current MAS configuration.
224
+
225
+ Args:
226
+ container: Synapse container.
227
+
228
+ Returns:
229
+ dict: MAS configuration.
230
+
231
+ Raises:
232
+ PebbleServiceError: if something goes wrong while interacting with Pebble.
233
+ """
234
+ try :
235
+ config = container .pull (MAS_CONFIGURATION_PATH ).read ()
236
+ return yaml .safe_load (config )
237
+ except ops .pebble .PathError as exc :
238
+ # If the MAS config has not been created, we return an empty dict to trigger a replan
239
+ if exc .kind == "not-found" :
240
+ return {}
241
+ raise PebbleServiceError (str (exc )) from exc
242
+
243
+
222
244
def _push_synapse_config (
223
245
container : ops .model .Container ,
224
246
current_synapse_config : dict ,
@@ -317,7 +339,16 @@ def reconcile( # noqa: C901
317
339
PebbleServiceError: if something goes wrong while interacting with Pebble.
318
340
"""
319
341
try :
320
- restart_mas (container , rendered_mas_configuration , charm_state )
342
+
343
+ existing_mas_config = _get_mas_config (container = container )
344
+ mas_config_has_changed = DeepDiff (
345
+ existing_mas_config ,
346
+ yaml .safe_load (rendered_mas_configuration ),
347
+ ignore_order = True ,
348
+ ignore_string_case = True ,
349
+ )
350
+ if mas_config_has_changed :
351
+ restart_mas (container , rendered_mas_configuration , charm_state )
321
352
322
353
if _environment_has_changed (container = container , charm_state = charm_state , is_main = is_main ):
323
354
# Configurations set via environment variables:
@@ -402,7 +433,7 @@ def reconcile( # noqa: C901
402
433
ignore_string_case = True ,
403
434
)
404
435
405
- if config_has_changed :
436
+ if config_has_changed or mas_config_has_changed :
406
437
logging .info ("Configuration has changed, Synapse will be restarted." )
407
438
logging .debug ("The change is: %s" , config_has_changed )
408
439
# Push worker configuration
0 commit comments