Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DPE-6521 Add missing check and wait for pebble calls #571

Merged
merged 1 commit into from
Feb 6, 2025
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,5 @@ Makefile

# local pyright settings
pyrightconfig.json

wt*/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

included to ignore worktree dirs

12 changes: 12 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,18 @@ def is_new_unit(self) -> bool:
}
return self.unit_peer_data.keys() == _default_unit_data_keys

@property
def unit_initialized(self) -> bool:
"""Return whether a unit is started.

Oveerride parent class method to include container accessibility check.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Oveerride parent class method to include container accessibility check.
Override parent class method to include container accessibility check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""
container = self.unit.get_container(CONTAINER_NAME)
if container.can_connect():
return super().unit_initialized
else:
return False

def get_unit_hostname(self, unit_name: Optional[str] = None) -> str:
"""Get the hostname.localdomain for a unit.

Expand Down
3 changes: 2 additions & 1 deletion src/mysql_k8s_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ def fix_data_dir(self, container: Container) -> None:
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:
container.exec([
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 "")
Expand Down
Loading