Skip to content

Commit

Permalink
Delete binlogs collector config when not needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zvirovyi committed Jan 9, 2025
1 parent db8f9ad commit 9ac2a34
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/charms/mysql/v0/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ def _on_s3_credentials_changed(self, event: CredentialsChangedEvent) -> None:
logger.error("Failed to restart binlogs collecting after S3 relation update")

def _on_s3_credentials_gone(self, event: CredentialsGoneEvent) -> None:
self.charm._mysql.delete_binlogs_collector_config()
if not self.charm.unit.is_leader():
logger.debug("Early exit on _on_s3_credentials_gone: unit is not a leader")
return
Expand Down
5 changes: 5 additions & 0 deletions lib/charms/mysql/v0/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -3269,6 +3269,11 @@ def reconcile_binlogs_collection(self, force_restart: bool = False) -> bool:
"""
raise NotImplementedError

@abstractmethod
def delete_binlogs_collector_config(self) -> None:
"""Delete binlogs collector config file."""
raise NotImplementedError

@abstractmethod
def get_cluster_members(self) -> list[str]:
"""Get cluster members in MySQL MEMBER_HOST format.
Expand Down
7 changes: 7 additions & 0 deletions src/mysql_vm_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
CHARMED_MYSQLD_EXPORTER_SERVICE,
CHARMED_MYSQLD_SERVICE,
CHARMED_MYSQLSH,
MYSQL_BINLOGS_COLLECTOR_CONFIG_FILE,
MYSQL_DATA_DIR,
MYSQL_SYSTEM_USER,
MYSQLD_CONFIG_DIRECTORY,
Expand Down Expand Up @@ -861,6 +862,12 @@ def reconcile_binlogs_collection(self, force_restart: bool = False) -> bool:

return True

def delete_binlogs_collector_config(self) -> None:
"""Delete binlogs collector config file."""
logger.info("Deleting binlogs collector config")
if os.path.exists(MYSQL_BINLOGS_COLLECTOR_CONFIG_FILE):
os.remove(MYSQL_BINLOGS_COLLECTOR_CONFIG_FILE)

def get_cluster_members(self) -> list[str]:
"""Get cluster members in MySQL MEMBER_HOST format.
Expand Down

0 comments on commit 9ac2a34

Please sign in to comment.