From 2bed1ef499a970190cfc01d2ae3c5138940834f5 Mon Sep 17 00:00:00 2001 From: Jason Yellick Date: Mon, 26 Feb 2018 23:35:25 -0500 Subject: [PATCH] [FAB-8539] Add version checking to first-network The first-network tutorial turns on the v1.1 fabric capabilities, and depends on very recent versions of cryptogen and configtxlator. Users appear to be running the latest version of first-network with older binaries, and are experiencing cryptic failures. This CR adds basic version checking, both for the local binary versions as well as the binary versions contained within the docker images. If these versions are mismatched, it prints a warning. If either of the versions is in a black-list, the byfn.sh will error out. Change-Id: I1a43ec396c8d1f5a438472cb422d5a7e52e2ef63 Signed-off-by: Jason Yellick --- first-network/byfn.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/first-network/byfn.sh b/first-network/byfn.sh index 172f96d587..a6118e874b 100755 --- a/first-network/byfn.sh +++ b/first-network/byfn.sh @@ -105,8 +105,46 @@ function removeUnwantedImages() { fi } +# Versions of fabric known not to work with this release of first-network +BLACKLISTED_VERSIONS="^1\.0\. ^1\.1\.0-preview ^1\.1\.0-alpha" + +# Do some basic sanity checking to make sure that the appropriate versions of fabric +# binaries/images are available. In the future, additional checking for the presence +# of go or other items could be added. +function checkPrereqs() { + # Note, we check configtxlator externally because it does not require a config file, and peer in the + # docker image because of FAB-8551 that makes configtxlator return 'development version' in docker + LOCAL_VERSION=$(configtxlator version | sed -ne 's/ Version: //p') + DOCKER_IMAGE_VERSION=$(docker run --rm hyperledger/fabric-tools:$IMAGETAG peer version | sed -ne 's/ Version: //p'|head -1) + + echo "LOCAL_VERSION=$LOCAL_VERSION" + echo "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION" + + if [ "$LOCAL_VERSION" != "$DOCKER_IMAGE_VERSION" ] ; then + echo "=================== WARNING ===================" + echo " Local fabric binaries and docker images are " + echo " out of sync. This may cause problems. " + echo "===============================================" + fi + + for UNSUPPORTED_VERSION in $BLACKLISTED_VERSIONS ; do + echo "$LOCAL_VERSION" | grep -q $UNSUPPORTED_VERSION + if [ $? -eq 0 ] ; then + echo "ERROR! Local Fabric binary version of $LOCAL_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples." + exit 1 + fi + + echo "$DOCKER_IMAGE_VERSION" | grep -q $UNSUPPORTED_VERSION + if [ $? -eq 0 ] ; then + echo "ERROR! Fabric Docker image version of $DOCKER_IMAGE_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples." + exit 1 + fi + done +} + # Generate the needed certificates, the genesis block and start the network. function networkUp () { + checkPrereqs # generate artifacts if they don't exist if [ ! -d "crypto-config" ]; then generateCerts