I would like to make use of the sqlite3 module for a iRules LX project on the BIG-IP, but it fails to install due to limitations on the /var partition. The installation of this module depends on running 'node-pre-gyp' from within the iRules LX workspace directory which per default resides on the /var partition. The /var partition is however mounted with the 'noexec' flag, so the installation fails. I can imagine this limitation limits the amount of Node.js modules that can be used within iRules LX.
Is this a design flaw of iRules LX or is there a good reason why this limitation is useful? What could be a reasonable workaround that is also future proof as it comes to BIG-IP software upgrades?
Here more details about the sqlite3 module installation that fails.
[root@nielsvs-bigip:Active:Standalone] extension # pwd
[root@nielsvs-bigip:Active:Standalone] extension # npm install sqlite3 --save
> firstname.lastname@example.org install /var/ilx/workspaces/Common/workspace/extensions/extension/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
sh: /var/ilx/workspaces/Common/workspace/extensions/extension/node_modules/sqlite3/node_modules/.bin/node-pre-gyp: Permission denied
npm ERR! Linux 3.10.0-327.36.3.el7.ve.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/.npm__" "install" "sqlite3" "--save"
npm ERR! node v0.12.15
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! email@example.com install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR! Failed at the firstname.lastname@example.org install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sqlite3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sqlite3
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/ilx/workspaces/Common/workspace/extensions/extension/npm-debug.log
[root@nielsvs-bigip:Active:Standalone] extension # mount | grep vg--db--sda-set.1._var
/dev/mapper/vg--db--sda-set.1._var on /var type ext3 (rw,noexec,noatime)
[root@nielsvs-bigip:Active:Standalone] extension #
Dealing with module installation in general I have a few questions. I have never used the sqlite3 module for node, but is it by chance a compiled module? Is so, BIG-IP does not include a complier so they cant be used if they have binaries that need to be built. Another question is if the sqlite3 module has a version compatible with 0.12.x (which is the version of node for iRules LX right now)?
Now as far as using sqlite in ILX, I would recommend against it for a number of reasons. First, is that using the file system from Node.js (which is where the DB file is kept for SQLite) on the BIG-IP is not a recommended or supported practice and could be detrimental to your platform or even to the app operation. Please see this solution article for more details - K16221101: Overview of iRules LX properties and limitations
The second is that it would only allow your plugin to run in Single concurrency mode (1 Node process for the whole BIG-IP) and you could never run it in Dedicated mode (one node process per TMM) because SQLite does not handle multiple processes using the DB file very well.
I would recommend that you use an external DB server with the appropriate NPM module. Another option you could use if you BIG-IP is version 13.0 is the ILXTable class, but this is only compatible with running your LX plugin in streaming mode (more precisely, it can only be used if you pass it an ILXFlow instance which is only available in the context of the ILXPlugin "connect" event emitter listener).
Hi Eric, Thanks for your thoughts on this matter. As you mentioned it isn't a good practice to perform filesystem actions from ILX, so I dropped the requirement for sqlite3 for my project. Instead I searched for a in-memory database solution and found lokijs. This module can be used without storing the database to disk. I'll check out the ILXTable class.