Skip to content

Commit

Permalink
Increase default SnapClient timeout to 30 seconds
Browse files Browse the repository at this point in the history
SnapClient has a default timeout of 5 seconds for all RPCs to
the snapd socket. If any operation takes more, an exception is
raised to the caller.

We have seen this causing issues in slow CI environments, where
a simple config-changed hook will attempt to check if a snap is
installed, timeout and move the unit to a blocked status (causing
the CI run to fail). This is augmented by the fact that typically
SnapCache is used instead of SnapClient, which only uses the default
value and does not provide a way to configure the timeout.

Simply increasing the timeout is enough to tackle the flakes.
  • Loading branch information
neoaggelos committed Sep 14, 2023
1 parent 20b8afd commit e91fa82
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/charms/operator_libs_linux/v2/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ def __init__(
socket_path: str = "/run/snapd.socket",
opener: Optional[urllib.request.OpenerDirector] = None,
base_url: str = "http://localhost/v2/",
timeout: float = 5.0,
timeout: float = 30.0,
):
"""Initialize a client instance.
Expand All @@ -701,7 +701,7 @@ def __init__(
opener: specifies an opener for unix socket, if unspecified a default is used
base_url: base url for making requests to the snap client. Defaults to
http://localhost/v2/
timeout: timeout in seconds to use when making requests to the API. Default is 5.0s.
timeout: timeout in seconds to use when making requests to the API. Default is 30.0s.
"""
if opener is None:
opener = self._get_default_opener(socket_path)
Expand Down

0 comments on commit e91fa82

Please sign in to comment.