Skip to content

Commit 5fce722

Browse files
authored
DPE-3896 report_host as static config (#435)
* report_host is static config * refactor flow to avoid event deferral
1 parent 180cefc commit 5fce722

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/charm.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def _on_peer_relation_joined(self, _) -> None:
452452
self.unit_peer_data.setdefault("member-role", "unknown")
453453
self.unit_peer_data.setdefault("member-state", "waiting")
454454

455-
def _on_config_changed(self, event: EventBase) -> None:
455+
def _on_config_changed(self, _: EventBase) -> None:
456456
"""Handle the config changed event."""
457457
if not self._is_peer_data_set:
458458
# skip when not initialized
@@ -463,12 +463,6 @@ def _on_config_changed(self, event: EventBase) -> None:
463463
# the upgrade already restart the daemon
464464
return
465465

466-
if not self._mysql.is_mysqld_running():
467-
# defer config-changed event until MySQL is running
468-
logger.debug("Deferring config-changed event until MySQL is running")
469-
event.defer()
470-
return
471-
472466
config_content = self._mysql.read_file_content(MYSQLD_CONFIG_FILE)
473467
if not config_content:
474468
# empty config means not initialized, skipping
@@ -492,8 +486,11 @@ def _on_config_changed(self, event: EventBase) -> None:
492486

493487
# persist config to file
494488
self._mysql.write_content_to_file(path=MYSQLD_CONFIG_FILE, content=new_config_content)
495-
self.on[f"{self.restart.name}"].acquire_lock.emit()
496-
return
489+
490+
if self._mysql.is_mysqld_running():
491+
# restart the service
492+
self.on[f"{self.restart.name}"].acquire_lock.emit()
493+
return
497494

498495
if dynamic_config := self.mysql_config.filter_static_keys(changed_config):
499496
# if only dynamic config changed, apply it

src/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class MySQLConfig:
2424
"innodb_buffer_pool_chunk_size",
2525
"group_replication_message_cache_size",
2626
"log_error",
27+
"report_host",
2728
}
2829

2930
def keys_requires_restart(self, keys: set) -> bool:

0 commit comments

Comments
 (0)