open-horizon / anax

Horizon agent control system
https://open-horizon.github.io/docs/anax/docs/
Apache License 2.0
73 stars 98 forks source link

Switch from boltdb to bbolt for RISC-V support #2452

Open gavingao-vto opened 3 years ago

gavingao-vto commented 3 years ago

Hi @dabooz , When I was working on risc-v support, I found that risc-v was not supported by "boltdb", and boltdb had stopped maintenance, but the alternative "bbolt" supported risc-v, so do we need to switch from boltdb to bbolt in anax? If so, I will start the work.

https://github.com/boltdb/bolt#a-message-from-the-author

dabooz commented 3 years ago

@gavingao-vto The requirements for boltdb in the agent are fairly minimal. The agent does not use large amounts of data, but does depend on the in-memory capability for performance. The agbot optionally uses bolt, but that config is really for demo purposes. bbolt claims API compatibility, which is critical. I am not opposed to switching to bbolt as long as the in-memory mode still works well and doesnt require us to switch compiler levels. Feel free to start on it, and please surface any problems you discover along the way. Even a small problem could be pointing to a larger issue, and I wouldn't want you to waste time working around the wrong problem.

The agbot has a "generic" database interface that enables different DBs to be plugged in. Only Boltdb and Postgresql are plugged in today, but there could be more in the future. Please consider doing something similar in the agent as part of this upgrade. While we've never heard a request to plugin a different DB on the agent, establishing an interface is still a solid engineering principle that would enable the creation of tests on that aspect of the system.

losdevnull commented 3 years ago

Hi @gavingao-vto @maiquanghiep, regarding what David suggested above, please see refer to: https://github.com/open-horizon/anax/blob/master/main.go#L73-L96

Essentially anax code has two code paths / runtime flavors: agent and agbot. Current for agent it supports only boltdb. While for agbot it supports both boltdb and postgresql, via the common interface as shown here https://github.com/open-horizon/anax/blob/master/main.go#L89-L90

And for RISC-V we would only need to add bbolt support to agent path. But currently there is no database interface abstraction for agent. What David suggested is that we implement that similar to what has been existing for agbot. So that we could control what type of database we would use for agent through configuration.

Below are sample config files for both agent and agbot for your reference.
https://github.com/open-horizon/anax/blob/master/test/docker/fs/etc/colonus/anax.config.tmpl https://github.com/open-horizon/anax/blob/master/test/docker/fs/etc/agbot/agbot-tmpl.json