Skip to content

Commit ebbc31c

Browse files
[DPE-5711] Add warnings to destructive actions (#555)
1 parent e04a142 commit ebbc31c

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/charms/mysql/v0/mysql.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1547,8 +1547,12 @@ def promote_cluster_to_primary(self, cluster_name: str, force: bool = False) ->
15471547
),
15481548
)
15491549

1550-
try:
1550+
if force:
1551+
logger.warning(f"Promoting {cluster_name=} to primary with {force=}")
1552+
else:
15511553
logger.debug(f"Promoting {cluster_name=} to primary with {force=}")
1554+
1555+
try:
15521556
self._run_mysqlsh_script("\n".join(commands))
15531557
except MySQLClientError:
15541558
logger.exception("Failed to promote cluster to primary")

src/mysql_vm_helpers.py

+2
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ def fetch_error_log() -> Optional[str]:
831831
@staticmethod
832832
def reset_data_dir() -> None:
833833
"""Reset the data directory."""
834+
logger.warning(f"Resetting data directory: {MYSQL_DATA_DIR}")
835+
834836
# Remove the data directory
835837
shutil.rmtree(MYSQL_DATA_DIR, ignore_errors=False)
836838

src/upgrade.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def _on_upgrade_granted(self, event: UpgradeGrantedEvent) -> None: # noqa: C901
218218
self.set_unit_failed()
219219
return
220220

221-
logger.info("Downgrade is incompatible. Resetting workload")
221+
logger.warning("Downgrade is incompatible. Resetting workload")
222222
self._reset_on_unsupported_downgrade()
223223
except MySQLStopMySQLDError:
224224
logger.exception("Failed to stop MySQL server")

0 commit comments

Comments
 (0)