Skip to content

Commit 583f991

Browse files
Fix TLS configuration immediately deleted after enabling (#249)
Ported from canonical/mysql-router-operator#150
1 parent 37dc1e8 commit 583f991

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/workload.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,15 @@ def reconcile(
373373
"`key`, `certificate`, and `certificate_authority` arguments required when tls=True"
374374
)
375375

376+
# If the host or port changes, MySQL Router will receive topology change
377+
# notifications from MySQL.
378+
# Therefore, if the host or port changes, we do not need to restart MySQL Router.
379+
is_charm_exposed = self._charm.is_externally_accessible(event=event)
380+
socket_file_exists = self._container.path("/run/mysqlrouter/mysql.sock").exists()
381+
require_rebootstrap = is_charm_exposed == socket_file_exists
382+
if require_rebootstrap:
383+
self._disable_router()
384+
376385
# `self._custom_certificate` will change after we enable/disable TLS
377386
custom_certificate = self._custom_certificate
378387
if tls:
@@ -386,15 +395,6 @@ def reconcile(
386395
if custom_certificate and self._container.mysql_router_service_enabled:
387396
self._restart(event=event, tls=tls)
388397

389-
# If the host or port changes, MySQL Router will receive topology change
390-
# notifications from MySQL.
391-
# Therefore, if the host or port changes, we do not need to restart MySQL Router.
392-
is_charm_exposed = self._charm.is_externally_accessible(event=event)
393-
socket_file_exists = self._container.path("/run/mysqlrouter/mysql.sock").exists()
394-
require_rebootstrap = is_charm_exposed == socket_file_exists
395-
if require_rebootstrap:
396-
self._disable_router()
397-
398398
if not self._container.mysql_router_service_enabled:
399399
self._enable_router(event=event, tls=tls, unit_name=unit_name)
400400

0 commit comments

Comments
 (0)