Skip to content

Commit a1efa63

Browse files
authored
missing checks (#571)
1 parent b247247 commit a1efa63

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,5 @@ Makefile
144144

145145
# local pyright settings
146146
pyrightconfig.json
147+
148+
wt*/

src/charm.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,18 @@ def is_new_unit(self) -> bool:
274274
}
275275
return self.unit_peer_data.keys() == _default_unit_data_keys
276276

277+
@property
278+
def unit_initialized(self) -> bool:
279+
"""Return whether a unit is started.
280+
281+
Oveerride parent class method to include container accessibility check.
282+
"""
283+
container = self.unit.get_container(CONTAINER_NAME)
284+
if container.can_connect():
285+
return super().unit_initialized
286+
else:
287+
return False
288+
277289
def get_unit_hostname(self, unit_name: Optional[str] = None) -> str:
278290
"""Get the hostname.localdomain for a unit.
279291

src/mysql_k8s_helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,13 @@ def fix_data_dir(self, container: Container) -> None:
186186
if paths[0].user != MYSQL_SYSTEM_USER or paths[0].group != MYSQL_SYSTEM_GROUP:
187187
logger.debug(f"Changing ownership to {MYSQL_SYSTEM_USER}:{MYSQL_SYSTEM_GROUP}")
188188
try:
189-
container.exec([
189+
process = container.exec([
190190
"chown",
191191
"-R",
192192
f"{MYSQL_SYSTEM_USER}:{MYSQL_SYSTEM_GROUP}",
193193
MYSQL_DATA_DIR,
194194
])
195+
process.wait()
195196
except ExecError as e:
196197
logger.error(f"Exited with code {e.exit_code}. Stderr:\n{e.stderr}")
197198
raise MySQLInitialiseMySQLDError(e.stderr or "")

0 commit comments

Comments
 (0)