2018年3月28日星期三

Building Hyperledger Fabric v1.1.0 on Ubuntu 14.04

TLDR - Don't do that. Build it on Ubuntu 16.04 and it'll work like a breeze.


Rationale -

Here by building Hyperledger Fabric, I mean calling make docker against the code and running through the e2e_cli example that demonstrates a proof-of-concept blockchain network. If you've done this before, you'll know that in order to do this, you'll need the following 2 base docker images that will be used to further build Fabric images like peer, orderer, etc.

root@tony2:/opt/gopath/src/github.com/hyperledger/fabric# docker images | grep base
hyperledger/fabric-baseimage   x86_64-0.4.7        390ac2e95bc7        37 hours ago        1.41GB
hyperledger/fabric-baseos      x86_64-0.4.7        c0e784934c4e        37 hours ago        152MB

I know that it's the 0.4.6 version base images that go with the official 1.1.0 release. I've just started migrating from 1.0.0 since yesterday, when the 0.4.7 version has rolled out. So I figured why not giving it a try? Simply modify BASEIMAGE_RELEASE in the Makefile should do the trick.

These images provide the runtime environment for the Fabric binary executables. When building these executables, there were actually a bunch of warnings that go something like:

Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking.

I obviously didn't give enough attention to these warnings when I first saw them. And later when I tried the e2e_cli example it failed when trying to install a chaincode, complaining about unexpected signal during runtime execution with a bunch of call stack traces. It was the 2nd or 3rd time during the trial and error process that I gave the warnings some serious thoughts, because some of the function names mentioned were similar to that in the call stack.

This is what I believe happened: the binaries were built on Ubuntu 14.04 with glibc 2.19, and the warning message suggested that the runtime environment should also be based on glibc 2.19, which is not the case since the baseimage was an Ubuntu 16.04 with glibc 2.23, hence the error and call stacks.

Figuring this all out I then upgraded my development machine to Ubuntu 16.04 (a command as simple as do-release-upgrade did it nicely), re-built the Fabric images and successfully ran through the e2e_cli example.

A side note: I believe upgrading glibc alone would also work, but there doesn't seem to be an easy way to do that except for building it from source, as Canonical doesn't ship in the 14.04 package repo a newer version.

Side note Number Two: I revisited my Fabric 1.0.0 environment and realized the baseimage v0.3.1, the official one for Fabric 1.0.0, was already an Ubuntu 16.04 with glibc 2.19, and I'd successfully run countless times of e2e_cli example with Fabric images built on Ubuntu 14.04. I'd only assume back in the 1.0.0 days Fabric code didn't call the incompatible functions. But now that we've learned this was a dangerous loophole.

没有评论:

发表评论