Skip to content

Commit

Permalink
[FAB-8539] Add version checking to first-network
Browse files Browse the repository at this point in the history
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 <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Feb 27, 2018
1 parent c93268f commit 2bed1ef
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions first-network/byfn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2bed1ef

Please sign in to comment.