key-networks / ztncui

ZeroTier network controller UI
GNU General Public License v3.0
1.53k stars 228 forks source link

node16: Builds on node v16.13.1 #79

Closed key-networks closed 2 years ago

key-networks commented 2 years ago

This builds with node v16.13.1, but execution fails at:

pkg/prelude/bootstrap.js:1740
      throw error;
      ^

Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /opt/key-networks/ztncui/node_modules/argon2/build/Release/argon2.node)
    at process.dlopen (pkg/prelude/bootstrap.js:2114:28)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at Module.require (pkg/prelude/bootstrap.js:1719:31)
    at require (node:internal/modules/cjs/helpers:102:18)
    at bindings (/snapshot/src/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/snapshot/src/node_modules/argon2/argon2.js:3:37)
    at Module._compile (pkg/prelude/bootstrap.js:1794:22) {
  code: 'ERR_DLOPEN_FAILED'
}
kmahyyg commented 2 years ago

This builds with node v16.13.1, but execution fails at:

pkg/prelude/bootstrap.js:1740
      throw error;
      ^

Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /opt/key-networks/ztncui/node_modules/argon2/build/Release/argon2.node)
    at process.dlopen (pkg/prelude/bootstrap.js:2114:28)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at Module.require (pkg/prelude/bootstrap.js:1719:31)
    at require (node:internal/modules/cjs/helpers:102:18)
    at bindings (/snapshot/src/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/snapshot/src/node_modules/argon2/argon2.js:3:37)
    at Module._compile (pkg/prelude/bootstrap.js:1794:22) {
  code: 'ERR_DLOPEN_FAILED'
}

This problem is related to a relatively old system (like CentOS6/7) running a binary built on a new OS (like Ubuntu 20.04). Please upgrade your system or build the code from old systems instead.

Also, Please check my PR in docker repo due to a serious SECURITY issue for generating password.

kmahyyg commented 2 years ago

make sure you do mention me to keep the docker environment up to date with you when you merge this PR. Thanks a lot.

key-networks commented 2 years ago

Thanks @kmahyyg for the pointers. I am building on Fedora 35 and was trying to run on Ubuntu 20.04 (IIRC). I'll have a look over the next few days when I get a chance.

key-networks commented 2 years ago

@kmahyyg - as you pointed out, it was a clash between the build environment and the deployment environment. It seems to deploy fine on a Fedora 35 VM.

kmahyyg commented 2 years ago

Yes, so either you built on relatively old machine, then run on new machine. Or use the same environment on both machine.

key-networks commented 2 years ago

@kmahyyg I wonder if you could give me some pointers on how to do this? My build system has been upgraded to Fedora 35 and there are other dependencies in the build process to produce the .rpm and .deb artifacts, so I was thinking it would be neat if the argon2 module alone (built with node-gyp) could be built in a docker container with nodejs 16 where it is statically linked against an older version of libstdc++.a (see https://github.com/key-networks/ztncui/blob/master/build/binding.gyp.patch) so that it can work on older systems. Alternately, I guess all the nodejs modules could be built in a docker container and then the artifact presented to the host machine for packaging and rpm signing.

It's a while since I've worked on this stuff, so it will take me a while to get my brain in gear to do it, so I was wondering if you could give me some pointers to try help speed things up so that I can merge this PR sooner? Many thanks!

kmahyyg commented 2 years ago

This is related to how Linux loads the binary files and executes it. Simplified saying, they are all linked against a must-have library called glibc (If not statically build), glibc is not compatible in some ways between different version. It is the base of the whole program.

Root cause here: The old version glibc doesn't guarantee to have the same dependencies when you build the program with newer glibc.

So you have two choices here:

Packaging and Signing should be done on the same environment, not in Host OS, but in Docker only.

key-networks commented 2 years ago

@kmahyyg - just a heads-up that I'm about to merge this branch into master.

kmahyyg commented 2 years ago

got it.

key-networks commented 2 years ago

@kmahyyg I'm not merging just yet - there may be a bug. I tested on a VM on my local machine. After attempting to authorize a new node and giving it a name, when I pressed Refresh, it went straight back to the login page. I have put the DEB package here: https://s3-us-west-1.amazonaws.com/key-networks/deb/ztncui/1/x86_64/ztncui_0.8.4_amd64.deb and the RPM can be installed with: sudo dnf --enablerepo=ztncui-testing upgrade ztncui

Please can someone help with testing to verify if this is a bug, or some network issue with my VM.

key-networks commented 2 years ago

@kmahyyg the ztncui-aio image builds, so I am merging this now.

If someone has a problem with the deb or rpm package, please open a new ticket.