From 5a573f2cef87828e964193966664d5df99caf928 Mon Sep 17 00:00:00 2001 From: Dan Bungert Date: Thu, 21 Sep 2023 10:41:57 -0600 Subject: [PATCH] snapd api: wait longer While these changes are not supposed to take nearly this long, per LP: #2034715 we know that they are, and that some systems will correctly perform the finish_install() step if just given more time. --- subiquitycore/snapd.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/subiquitycore/snapd.py b/subiquitycore/snapd.py index afcd89f4..108e8d37 100644 --- a/subiquitycore/snapd.py +++ b/subiquitycore/snapd.py @@ -33,6 +33,11 @@ log = logging.getLogger("subiquitycore.snapd") class SnapdConnection: + # In LP: #2034715, we found that while some requests should be + # non-blocking, they are actually blocking and exceeding one minute. + # Extending the timeout helps. + default_timeout_seconds = 600 + def __init__(self, root, sock): self.root = root self.url_base = "http+unix://{}/".format(quote_plus(sock)) @@ -41,13 +46,19 @@ class SnapdConnection: if args: path += "?" + urlencode(args) with requests_unixsocket.Session() as session: - return session.get(self.url_base + path, timeout=60) + return session.get( + self.url_base + path, timeout=self.default_timeout_seconds + ) def post(self, path, body, **args): if args: path += "?" + urlencode(args) with requests_unixsocket.Session() as session: - return session.post(self.url_base + path, data=json.dumps(body), timeout=60) + return session.post( + self.url_base + path, + data=json.dumps(body), + timeout=self.default_timeout_seconds, + ) def configure_proxy(self, proxy): log.debug("restarting snapd to pick up proxy config")