Skip to content

Commit 63e683f

Browse files
Add default 30 second timeout to snap subprocess calls (#222)
Companion PR to canonical/mysql-router-k8s-operator#394 Use 30 seconds instead of 15 since we aren't constrainted by Kubernetes pod `terminationGracePeriodSeconds`
1 parent c2e940f commit 63e683f

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/container.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,11 @@ def set_mysql_router_rest_api_password(
228228
self.create_router_rest_api_credentials_file()
229229

230230
if not password:
231-
users_credentials = self._run_command(
232-
[
233-
self._mysql_router_password_command,
234-
"list",
235-
str(self.rest_api_credentials_file),
236-
],
237-
timeout=30,
238-
)
231+
users_credentials = self._run_command([
232+
self._mysql_router_password_command,
233+
"list",
234+
str(self.rest_api_credentials_file),
235+
])
239236
if user not in users_credentials:
240237
return
241238

@@ -248,5 +245,4 @@ def set_mysql_router_rest_api_password(
248245
user,
249246
],
250247
input=password,
251-
timeout=30,
252248
)

src/snap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _run_command(
256256
self,
257257
command: typing.List[str],
258258
*,
259-
timeout: typing.Optional[int],
259+
timeout: typing.Optional[int] = 30,
260260
input: str = None, # noqa: A002 Match subprocess.run()
261261
) -> str:
262262
try:

src/workload.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def _bootstrap_router(self, *, event, tls: bool) -> None:
266266

267267
command = self._get_bootstrap_command(event=event, connection_info=self._connection_info)
268268
try:
269-
self._container.run_mysql_router(command, timeout=30)
269+
self._container.run_mysql_router(command)
270270
except container.CalledProcessError as e:
271271
# Original exception contains password
272272
# Re-raising would log the password to Juju's debug log
@@ -327,7 +327,7 @@ def _restart(self, *, event, tls: bool) -> None:
327327

328328
def _enable_router(self, *, event, tls: bool, unit_name: str) -> None:
329329
"""Enable router after setting up all the necessary prerequisites."""
330-
logger.debug("Enabling MySQL Router service")
330+
logger.info("Enabling MySQL Router service")
331331
self._cleanup_after_upgrade_or_potential_container_restart()
332332
# create an empty credentials file, if the file does not exist
333333
self._container.create_router_rest_api_credentials_file()
@@ -337,7 +337,7 @@ def _enable_router(self, *, event, tls: bool, unit_name: str) -> None:
337337
)
338338
self._container.update_mysql_router_service(enabled=True, tls=tls)
339339
self._logrotate.enable()
340-
logger.debug("Enabled MySQL Router service")
340+
logger.info("Enabled MySQL Router service")
341341
self._charm.wait_until_mysql_router_ready(event=event)
342342

343343
def _enable_exporter(

0 commit comments

Comments
 (0)