@@ -82,42 +82,40 @@ def __init__(self, *args: typing.Any) -> None:
8282 self ._mjolnir = Mjolnir (self , charm_state = self ._charm_state )
8383 self .framework .observe (self .on .config_changed , self ._on_config_changed )
8484 self .framework .observe (self .on .reset_instance_action , self ._on_reset_instance_action )
85- self .framework .observe (self .on .synapse_pebble_ready , self ._on_pebble_ready )
85+ self .framework .observe (self .on .synapse_pebble_ready , self ._on_synapse_pebble_ready )
86+ self .framework .observe (
87+ self .on .synapse_nginx_pebble_ready , self ._on_synapse_nginx_pebble_ready
88+ )
8689 self .framework .observe (self .on .register_user_action , self ._on_register_user_action )
8790 self .framework .observe (
8891 self .on .promote_user_admin_action , self ._on_promote_user_admin_action
8992 )
9093 self .framework .observe (self .on .anonymize_user_action , self ._on_anonymize_user_action )
9194
92- def replan_nginx (self ) -> None :
93- """Replan NGINX."""
94- container = self .unit .get_container (synapse .SYNAPSE_NGINX_CONTAINER_NAME )
95- if not container .can_connect ():
96- self .unit .status = ops .MaintenanceStatus ("Waiting for pebble" )
97- return
98- self .model .unit .status = ops .MaintenanceStatus ("Configuring Synapse NGINX" )
99- self .pebble_service .replan_nginx (container )
100- self .model .unit .status = ops .ActiveStatus ()
101-
10295 def change_config (self ) -> None :
10396 """Change configuration."""
10497 container = self .unit .get_container (synapse .SYNAPSE_CONTAINER_NAME )
10598 if not container .can_connect ():
106- self .unit .status = ops .MaintenanceStatus ("Waiting for pebble" )
99+ self .unit .status = ops .MaintenanceStatus ("Waiting for Synapse pebble" )
107100 return
108101 self .model .unit .status = ops .MaintenanceStatus ("Configuring Synapse" )
109102 try :
110103 self .pebble_service .change_config (container )
111104 except PebbleServiceError as exc :
112105 self .model .unit .status = ops .BlockedStatus (str (exc ))
113106 return
114- self .replan_nginx ()
107+ container = self .unit .get_container (synapse .SYNAPSE_NGINX_CONTAINER_NAME )
108+ if not container .can_connect ():
109+ self .unit .status = ops .MaintenanceStatus ("Waiting for Synapse NGINX pebble" )
110+ return
111+ self .pebble_service .replan_nginx (container )
112+ self .model .unit .status = ops .ActiveStatus ()
115113
116114 def _set_workload_version (self ) -> None :
117115 """Set workload version with Synapse version."""
118116 container = self .unit .get_container (synapse .SYNAPSE_CONTAINER_NAME )
119117 if not container .can_connect ():
120- self .unit .status = ops .MaintenanceStatus ("Waiting for pebble" )
118+ self .unit .status = ops .MaintenanceStatus ("Waiting for Synapse pebble" )
121119 return
122120 try :
123121 synapse_version = synapse .get_version ()
@@ -130,10 +128,18 @@ def _on_config_changed(self, _: ops.HookEvent) -> None:
130128 self .change_config ()
131129 self ._set_workload_version ()
132130
133- def _on_pebble_ready (self , _ : ops .HookEvent ) -> None :
134- """Handle pebble ready event."""
131+ def _on_synapse_pebble_ready (self , _ : ops .HookEvent ) -> None :
132+ """Handle synapse pebble ready event."""
135133 self .change_config ()
136134
135+ def _on_synapse_nginx_pebble_ready (self , _ : ops .HookEvent ) -> None :
136+ """Handle synapse nginx pebble ready event."""
137+ container = self .unit .get_container (synapse .SYNAPSE_NGINX_CONTAINER_NAME )
138+ if not container .can_connect ():
139+ self .unit .status = ops .MaintenanceStatus ("Waiting for Synapse NGINX pebble" )
140+ return
141+ self .pebble_service .replan_nginx (container )
142+
137143 def _on_reset_instance_action (self , event : ActionEvent ) -> None :
138144 """Reset instance and report action result.
139145
0 commit comments