Skip to contentSkip to conversation

cooker: limit the execution of the hashequiv client/server ping

PATCH Superseded [email protected] 2 participants 2 messages May 5 – May 6

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cooker: limit the execution of the hashequiv client/server ping

From: Corentin Guillevic <[email protected]>

The ping method is used to test the connection to the hash equivalence server. However, if the server is unavailable, the bitbake server has to wait several minutes for the system to terminate.

While waiting for a response from the hash server, the bitbake server does not provide any feedback to the bitbake client. The latter then closes the link and fails with the error:

Timeout while waiting for a reply from the bitbake server (60s at 09:50:15.377337)

Adding a timeout to the ping step allows quicker action when a remote server is unavailable, and prevents disconnection of the client due to timeout. The default timeout is 10 seconds, but this can be set using the BB_HASHSERVE_UPSTREAM_TIMEOUT variable.

---

Notes:
Changes in v2:
- Rename variable BB_HASHSERVER_TIMEOUT as BB_HASHSERVE_UPSTREAM_TIMEOUT
- Document BB_HASHSERVE_UPSTREAM_TIMEOUT
- Set a default value to the "timeout" argument (keeping all calls to ping() unchanged, except for the one that connects to the hash server)

 .../bitbake-user-manual-ref-variables.rst             | 11 +++++++++++
 lib/bb/asyncrpc/client.py                             |  4 ++--
 lib/bb/cooker.py                                      |  4 ++--
 3 files changed, 15 insertions(+), 4 deletions(-)
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +11 -0
index 9824b58ef..cce03bc0c 100644
@@ -511,6 +511,17 @@ overview of their function and contents.
 
          BB_HASHSERVE_UPSTREAM = "hashserv.yoctoproject.org:8686"
 
+   :term:`BB_HASHSERVE_UPSTREAM_TIMEOUT`
+      Specifies the duration (in seconds) for which BitBake waits for the first
+      response from the upstream Hash Equivalence server (specified by
+      :term:`BB_HASHSERVE_UPSTREAM`).
+
+      This variable prevents BitBake from waiting too long for an unavailable server.
+      If the time expires, the upstream Hash Equivalence server will be skipped for
+      the build.
+
+      The default value is "10" (seconds).
+
    :term:`BB_INVALIDCONF`
       Used in combination with the ``ConfigParsed`` event to trigger
       re-parsing the base metadata (i.e. all the recipes). The
lib/bb/asyncrpc/client.py +2 -2
index 17b72033b..5e2505494 100644
@@ -199,8 +199,8 @@ class AsyncClient(object):
         self.check_invoke_error(result)
         return result
 
-    async def ping(self):
-        return await self.invoke({"ping": {}})
+    async def ping(self, timeout=None):
+        return await asyncio.wait_for(self.invoke({"ping": {}}), timeout)
 
     async def __aenter__(self):
         return self
lib/bb/cooker.py +2 -2
index 4b6ba3196..c7ced1e37 100644
@@ -342,7 +342,7 @@ according to https://docs.yoctoproject.org/dev-manual/hashequivserver.html""".fo
                 if upstream:
                     try:
                         with hashserv.create_client(upstream) as client:
-                            client.ping()
+                            client.ping(int(self.data.getVar("BB_HASHSERVE_UPSTREAM_TIMEOUT")) or 10)
                     except ImportError as e:
                         bb.fatal(""""Unable to use hash equivalence server at '%s' due to missing or incorrect python module:
 %s
@@ -352,7 +352,7 @@ Please install the needed module on the build host, or use an environment contai
  - or set up pip venv
 You can also remove the BB_HASHSERVE_UPSTREAM setting, but this may result in significantly longer build times as bitbake will be unable to reuse prebuilt sstate artefacts."""
                                  % (upstream, repr(e)))
-                    except ConnectionError as e:
+                    except (ConnectionError, TimeoutError) as e:
                         bb.warn("Unable to connect to hash equivalence server at '%s', please correct or remove BB_HASHSERVE_UPSTREAM:\n%s"
                                  % (upstream, repr(e)))
                         upstream = None
Signature · 1 line
2.51.0
#1 lore raw
Quoted 12 lines · Corentin Guillevic via lists.openembedded.org

From: Corentin Guillevic <[email protected]>

The ping method is used to test the connection to the hash equivalence server. However, if the server is unavailable, the bitbake server has to wait several minutes for the system to terminate.

While waiting for a response from the hash server, the bitbake server does not provide any feedback to the bitbake client. The latter then closes the link and fails with the error:

Timeout while waiting for a reply from the bitbake server (60s at 09:50:15.377337)

Quoted 7 lines

Adding a timeout to the ping step allows quicker action when a remote server is unavailable, and prevents disconnection of the client due to timeout. The default timeout is 10 seconds, but this can be set using the BB_HASHSERVE_UPSTREAM_TIMEOUT variable.

---

Hi Corentin,

Thanks for the new version.

lib/bb/cooker.py according to https://docs.yoctoproject.org/dev-manual/hashequivserver.html""".fo · line 345

Quoted 8 lines
lib/bb/cooker.py +1 -1
@@ -342,7 +342,7 @@ according to https://docs.yoctoproject.org/dev-manual/hashequivserver.html""".fo
                 if upstream:
                     try:
                         with hashserv.create_client(upstream) as client:
-                            client.ping()
+                            client.ping(int(self.data.getVar("BB_HASHSERVE_UPSTREAM_TIMEOUT")) or 10)

I believe this is not sufficient when BB_HASHSERVE_UPSTREAM_TIMEOUT is not defined:

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

https://autobuilder.yoctoproject.org/valkyrie/#/builders/80/builds/3542

Maybe this is just a parenthesis issue? client.ping(int(self.data.getVar("BB_HASHSERVE_UPSTREAM_TIMEOUT") or 10))

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com