Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion kubernetes/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,6 @@ def _configure_instance(self, container) -> None:
# bootstrap the data directory and users
logger.info("Initializing mysqld")
try:
self._mysql.fix_data_dir(container)
self._mysql.initialise_mysqld()

# Add the pebble layer
Expand Down
26 changes: 0 additions & 26 deletions kubernetes/src/mysql_k8s_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,32 +180,6 @@ def _build_instance_sock_executor(self):
executor.set_container(self.container)
return executor

def fix_data_dir(self, container: Container) -> None:
"""Ensure the data directory for mysql is writable for the "mysql" user.

Until the ability to set fsGroup and fsGroupChangePolicy via Pod securityContext
is available we fix permissions incorrectly with chown.
"""
if not container.exists(MYSQL_DATA_DIR):
container.make_dir(MYSQL_DATA_DIR, user=MYSQL_SYSTEM_USER, group=MYSQL_SYSTEM_GROUP)
return

paths = container.list_files(MYSQL_DATA_DIR, itself=True)
logger.debug(f"Data directory ownership: {paths[0].user}:{paths[0].group}")
if paths[0].user != MYSQL_SYSTEM_USER or paths[0].group != MYSQL_SYSTEM_GROUP:
logger.debug(f"Changing ownership to {MYSQL_SYSTEM_USER}:{MYSQL_SYSTEM_GROUP}")
try:
process = container.exec([
"chown",
"-R",
f"{MYSQL_SYSTEM_USER}:{MYSQL_SYSTEM_GROUP}",
MYSQL_DATA_DIR,
])
process.wait()
except ExecError as e:
logger.error(f"Exited with code {e.exit_code}. Stderr:\n{e.stderr}")
raise MySQLInitialiseMySQLDError(e.stderr or "") from None

@retry(reraise=True, stop=stop_after_delay(30), wait=wait_fixed(5))
def initialise_mysqld(self) -> None:
"""Execute instance first run.
Expand Down
2 changes: 0 additions & 2 deletions kubernetes/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def test_on_leader_elected_secrets(self):
@patch("mysql_k8s_helpers.MySQL.configure_instance")
@patch("mysql_k8s_helpers.MySQL.create_cluster")
@patch("mysql_k8s_helpers.MySQL.initialise_mysqld")
@patch("mysql_k8s_helpers.MySQL.fix_data_dir")
@patch("mysql_k8s_helpers.MySQL.is_instance_in_cluster")
@patch("mysql_k8s_helpers.MySQL.get_member_state", return_value="ONLINE")
@patch("mysql_k8s_helpers.MySQL.get_member_role", return_value="PRIMARY")
Expand All @@ -184,7 +183,6 @@ def test_mysql_pebble_ready(
_get_member_state,
_is_instance_in_cluster,
_initialise_mysqld,
_fix_data_dir,
_create_cluster,
_configure_instance,
_configure_mysql_router_roles,
Expand Down
Loading