Skip to contentSkip to conversation

cooker: add support for more than one server in BB_HASHSERVE_UPSTREAM

RFC PATCH Jose Quaresma 2 participants 5 messages Sep 24, 2025 – Oct 1, 2025 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi

With that we can have for example:

BB_HASHSERVE_UPSTREAM = "wss://hashserv.yoctoproject.org/ws hashserv.yoctoproject.org:8686"

Jose

Jose Quaresma via lists.openembedded.org <quaresma.jose= [email protected]> escreveu (quarta, 24/09/2025 à(s) 11:32):

Quoted 93 lines

From: Jose Quaresma <[email protected]>

Making the use of python websockets mandatory when connecting to hashserve could
create several difficulties for users, especially when the python-python is not
available in the distribution used.
So it will be better to have a list of servers where for example we can have a second fallback in case it is not possible to use the first one.

If it is not possible to use any server from the specified list, this will cause a fatal error.

---
 lib/bb/cooker.py | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
lib/bb/cooker.py +0 -0
index fb87368f1..976065622 100644
@@ -312,21 +312,25 @@ class BBCooker:
             # Create a new hash server bound to a unix domain socket
             if not self.hashserv:
                 dbfile = (self.data.getVar("PERSISTENT_DIR") or

self.data.getVar("CACHE")) + "/hashserv.db"
- upstream = self.data.getVar("BB_HASHSERVE_UPSTREAM") or
None

lib/bb/cooker.py +0 -6
-                if upstream:
-                    try:
-                        with hashserv.create_client(upstream) as client:
-                            client.ping()
-                    except ImportError as e:
-                        bb.fatal(""""Unable to use hash equivalence

server at '%s' due to missing or incorrect python module:
-%s
-Please install the needed module on the build host, or use an environment containing it (e.g a pip venv or OpenEmbedded's buildtools tarball). -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."""

lib/bb/cooker.py +0 -3
-                                 % (upstream, repr(e)))
-                    except ConnectionError as e:
-                        bb.warn("Unable to connect to hash equivalence

server at '%s', please correct or remove BB_HASHSERVE_UPSTREAM:\n%s"

lib/bb/cooker.py +1 -2
-                                 % (upstream, repr(e)))
-                        upstream = None
+                hashserve_upstream_list =

self.data.getVar("BB_HASHSERVE_UPSTREAM") or None

lib/bb/cooker.py +3 -0
+                upstream = None
+                if hashserve_upstream_list:
+                    for hashserve_upstream in

hashserve_upstream_list.split():

lib/bb/cooker.py +2 -0
+                        try:
+                            with

hashserv.create_client(hashserve_upstream) as client:

lib/bb/cooker.py +5 -0
+                                client.ping()
+                                upstream = hashserve_upstream
+                                break
+                        except ImportError as e:
+                            bb.warn("Unable to connect to hash

equivalence server at '%s' due to missing or incorrect python module:\n%s"

lib/bb/cooker.py +3 -0
+                                    % (hashserve_upstream, repr(e)))
+                        except ConnectionError as e:
+                            bb.warn("Unable to connect to hash

equivalence server at '%s':\n%s"

lib/bb/cooker.py +5 -0
+                                    % (hashserve_upstream, repr(e)))
+
+                if hashserve_upstream_list and not upstream:
+                    bb.fatal("""Unable to use hash equivalence server:
+    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.""")

self.hashservaddr = "unix://%s/hashserve.sock" %
self.data.getVar("TOPDIR")

                 self.hashserv = hashserv.create_server(

--
2.51.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#18083):
https://lists.openembedded.org/g/bitbake-devel/message/18083
Mute This Topic: https://lists.openembedded.org/mt/115409539/5052612
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
Best regards,

José Quaresma
#2 lore raw
Quoted 3 lines · Jose Quaresma via lists.openembedded.org

With that we can have for example:

BB_HASHSERVE_UPSTREAM = "wss://hashserv.yoctoproject.org/ws hashserv.yoctoproject.org:8686"

I'd like Joshua and Michael to comment on this ^^^ Specifically, are there performance implications in using one or the other? Are both officially supported and maintained?

Quoted 9 lines
Quoted 9 lines
(quoted diff) +9 -0
+                if hashserve_upstream_list:
+                    for hashserve_upstream in hashserve_upstream_list.split():
+                        try:
+                            with hashserv.create_client(hashserve_upstream) as client:
+                                client.ping()
+                                upstream = hashserve_upstream
+                                break
+                        except ImportError as e:
+                            bb.warn("Unable to connect to hash equivalence server at '%s' due to missing or incorrect python module:\n%s"
Quoted 8 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+                                    % (hashserve_upstream, repr(e)))
+                        except ConnectionError as e:
+                            bb.warn("Unable to connect to hash equivalence server at '%s':\n%s"
+                                    % (hashserve_upstream, repr(e)))
+
+                if hashserve_upstream_list and not upstream:
+                    bb.fatal("""Unable to use hash equivalence server:
+    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.""")

This needs to be rebased on master-next, as it changes the error message. Also you can use for...else to put the newly added bb.fatal into the else block. The bb.fatal message should also be improved, and say that none of the configured servers could be used due to warnings above.

Alex

#3 lore raw

Alexander Kanavin <[email protected]> escreveu (quarta, 24/09/2025 à(s) 11:47):

Quoted 12 lines
Quoted 3 lines · Jose Quaresma via lists.openembedded.org

With that we can have for example:

BB_HASHSERVE_UPSTREAM = "wss://hashserv.yoctoproject.org/ws

hashserv.yoctoproject.org:8686"

I'd like Joshua and Michael to comment on this ^^^ Specifically, are there performance implications in using one or the other? Are both officially supported and maintained?

AFAIK the two are still supported because kirkstone only supports the raw sockets.
We will still prefer the first one and fallback only on hosts that don't have the python-websockets
I think with time they will become available widely and we can also add it as a mandatory dependency of bitbake.

About the performance I will defer it Joshua and Michael

Quoted 21 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+                if hashserve_upstream_list:
+                    for hashserve_upstream in

hashserve_upstream_list.split():

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+                        try:
+                            with

hashserv.create_client(hashserve_upstream) as client:

Quoted 5 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+                                client.ping()
+                                upstream = hashserve_upstream
+                                break
+                        except ImportError as e:
+                            bb.warn("Unable to connect to hash

equivalence server at '%s' due to missing or incorrect python module:\n%s"

Quoted 3 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+                                    % (hashserve_upstream, repr(e)))
+                        except ConnectionError as e:
+                            bb.warn("Unable to connect to hash

equivalence server at '%s':\n%s"

Quoted 5 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+                                    % (hashserve_upstream, repr(e)))
+
+                if hashserve_upstream_list and not upstream:
+                    bb.fatal("""Unable to use hash equivalence server:
+    You can also remove the BB_HASHSERVE_UPSTREAM setting, but this
Quoted 9 lines

may result in significantly longer build times as bitbake will be unable to reuse prebuilt sstate artefacts.""")

This needs to be rebased on master-next, as it changes the error message. Also you can use for...else to put the newly added bb.fatal into the else block. The bb.fatal message should also be improved, and say that none of the configured servers could be used due to warnings above.

I will do it.

Jose

Quoted 3 lines

Alex

Signature · 3 lines
Best regards,

José Quaresma
#4 lore raw
Quoted 10 lines · Jose Quaresma
Quoted 5 lines
Quoted 1 line

BB_HASHSERVE_UPSTREAM = "wss://hashserv.yoctoproject.org/ws hashserv.yoctoproject.org:8686"

I'd like Joshua and Michael to comment on this ^^^ Specifically, are there performance implications in using one or the other? Are both officially supported and maintained?

AFAIK the two are still supported because kirkstone only supports the raw sockets.
We will still prefer the first one and fallback only on hosts that don't have the python-websockets I think with time they will become available widely and we can also add it as a mandatory dependency of bitbake.

The problem is that once you have the fallback, no one will bother to install websockets, and they will not become available widely. I'd rather adjust bitbake/yocto dependency lists in yocto manuals, together with all other bitbake-setup tweaks.

Alex

#5 lore raw

Added Josua and Michael on cc

Alexander Kanavin <[email protected]> escreveu (quarta, 24/09/2025 à(s) 12:11):

Quoted 9 lines
Quoted 1 line · Jose Quaresma
Quoted 1 line
Quoted 1 line

BB_HASHSERVE_UPSTREAM = "wss://hashserv.yoctoproject.org/ws

hashserv.yoctoproject.org:8686"

Quoted 4 lines
Quoted 4 lines

I'd like Joshua and Michael to comment on this ^^^ Specifically, are there performance implications in using one or the other? Are both officially supported and maintained?

Added Josua and Michael on cc.

Could you please give your opinion, if possible, on the above questions?

Jose

Quoted 16 lines
Quoted 3 lines

AFAIK the two are still supported because kirkstone only supports the

raw sockets.

Quoted 1 line

We will still prefer the first one and fallback only on hosts that don't

have the python-websockets

Quoted 1 line

I think with time they will become available widely and we can also add

it as a mandatory dependency of bitbake.

The problem is that once you have the fallback, no one will bother to install websockets, and they will not become available widely. I'd rather adjust bitbake/yocto dependency lists in yocto manuals, together with all other bitbake-setup tweaks.

Alex

Signature · 3 lines
Best regards,

José Quaresma