Skip to content

Commit

Permalink
remove assert
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Aug 12, 2024
1 parent 701fd1d commit 74abc21
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class MissingConfigServerError(Exception):
"""Raised when mongos expects to be connected to a config-server but is not."""


class ExtraDataDirError:
"""Raised when there is unexpected data in the data directory."""


class MongosCharm(ops.CharmBase):
"""Charm the service."""

Expand Down Expand Up @@ -335,9 +339,10 @@ def _set_data_dir_permissions(container: Container) -> None:
"""
for path in [Config.DATA_DIR, Config.LOG_DIR, Config.LogRotate.LOG_STATUS_DIR]:
paths = container.list_files(path, itself=True)
assert (
len(paths) == 1
), "list_files doesn't return only the directory itself"
if not len(paths) == 1:
raise ExtraDataDirError(
"list_files doesn't return only the directory itself"
)
logger.debug(f"Data directory ownership: {paths[0].user}:{paths[0].group}")
if paths[0].user != Config.UNIX_USER or paths[0].group != Config.UNIX_GROUP:
container.exec(
Expand Down

0 comments on commit 74abc21

Please sign in to comment.