Merge "[FAB-8567] Alt: Always use volumes for ledger (m)"

This commit is contained in:
David Enyeart 2018-03-01 01:36:04 +00:00 committed by Gerrit Code Review
commit d58a13682b
6 changed files with 38 additions and 65 deletions

View file

@ -28,6 +28,7 @@ services:
- ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
- orderer.example.com:/var/hyperledger/production/orderer
ports:
- 7050:7050
@ -46,6 +47,7 @@ services:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
- peer0.org1.example.com:/var/hyperledger/production
ports:
- 7051:7051
- 7053:7053
@ -65,6 +67,7 @@ services:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
- peer1.org1.example.com:/var/hyperledger/production
ports:
- 8051:7051
@ -85,6 +88,7 @@ services:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
- peer0.org2.example.com:/var/hyperledger/production
ports:
- 9051:7051
- 9053:7053
@ -104,6 +108,7 @@ services:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
- peer1.org2.example.com:/var/hyperledger/production
ports:
- 10051:7051
- 10053:7053

View file

@ -49,7 +49,6 @@ function printHelp () {
echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
echo " -l <language> - the chaincode language: golang (default) or node"
echo " -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")"
echo " -p - persist the ledgers of the containers to the ./ledgers/<container> directory"
echo
echo "Typically, one would first generate the required certificates and "
echo "genesis block, then bring up the network. e.g.:"
@ -154,20 +153,10 @@ function networkUp () {
replacePrivateKey
generateChannelArtifacts
fi
if $PERSIST ; then
echo "Persisting ledgers to ./ledgers/"
mkdir -p ./ledgers/
if [ "${IF_COUCHDB}" == "couchdb" ]; then
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST -f $COMPOSE_FILE_COUCH up -d 2>&1
else
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST up -d 2>&1
fi
else
if [ "${IF_COUCHDB}" == "couchdb" ]; then
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
else
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1
fi
if [ "${IF_COUCHDB}" == "couchdb" ]; then
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
else
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1
fi
if [ $? -ne 0 ]; then
echo "ERROR !!!! Unable to start network"
@ -185,8 +174,9 @@ function networkUp () {
# Stop the orderer and peers, backup the ledger from orderer and peers, cleanup chaincode containers and images
# and relaunch the orderer and peers with latest tag
function upgradeNetwork () {
if [ ! -d ledgers ]; then
echo "ERROR !!!! There is no persisted ledgers directory, did you start your network with -p?"
docker inspect -f '{{.Config.Volumes}}' orderer.example.com |grep -q '/var/hyperledger/production/orderer'
if [ $? -ne 0 ]; then
echo "ERROR !!!! This network does not appear to be using volumes for its ledgers, did you start from fabric-samples >= v1.0.6?"
exit 1
fi
@ -197,9 +187,9 @@ function upgradeNetwork () {
export IMAGE_TAG=$IMAGETAG
if [ "${IF_COUCHDB}" == "couchdb" ]; then
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST -f $COMPOSE_FILE_COUCH"
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH"
else
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST"
COMPOSE_FILES="-f $COMPOSE_FILE"
fi
# removing the cli container
@ -242,12 +232,12 @@ function upgradeNetwork () {
# Tear down running network
function networkDown () {
docker-compose -f $COMPOSE_FILE down
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down
# Don't remove containers, images, etc if restarting
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down --volumes
docker-compose -f $COMPOSE_FILE down --volumes
# Don't remove the generated artifacts -- note, the ledgers are always removed
if [ "$MODE" != "restart" ]; then
#Delete any persisted ledgers
docker run -v $PWD:/tmp/first-network --rm hyperledger/fabric-tools:$IMAGETAG rm -Rf /tmp/first-network/ledgers
# Bring down the network, deleting the volumes
#Delete any ledger backups
docker run -v $PWD:/tmp/first-network --rm hyperledger/fabric-tools:$IMAGETAG rm -Rf /tmp/first-network/ledgers-backup
#Cleanup the chaincode containers
clearContainers
@ -439,9 +429,6 @@ COMPOSE_FILE_COUCH=docker-compose-couch.yaml
LANGUAGE=golang
# default image tag
IMAGETAG="latest"
# By default, to not use volume mounts for the ledgers
PERSIST="false"
COMPOSE_FILE_PERSIST=docker-compose-persist.yaml
# Parse commandline args
if [ "$1" = "-m" ];then # supports old usage, muscle memory is powerful!
shift
@ -463,7 +450,7 @@ else
exit 1
fi
while getopts "h?m:c:t:d:f:s:l:i:p" opt; do
while getopts "h?m:c:t:d:f:s:l:i:" opt; do
case "$opt" in
h|\?)
printHelp
@ -483,8 +470,6 @@ while getopts "h?m:c:t:d:f:s:l:i:p" opt; do
;;
i) IMAGETAG=`uname -m`"-"$OPTARG
;;
p) PERSIST=true
;;
esac
done

View file

@ -5,6 +5,13 @@
version: '2'
volumes:
orderer.example.com:
peer0.org1.example.com:
peer1.org1.example.com:
peer0.org2.example.com:
peer1.org2.example.com:
networks:
byfn:

View file

@ -5,6 +5,9 @@
version: '2'
volumes:
peer0.org3.example.com:
peer1.org3.example.com:
networks:
byfn:
@ -25,6 +28,7 @@ services:
- /var/run/:/host/var/run/
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp:/etc/hyperledger/fabric/msp
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls:/etc/hyperledger/fabric/tls
- peer0.org3.example.com:/var/hyperledger/production
ports:
- 11051:7051
- 11053:7053
@ -46,6 +50,7 @@ services:
- /var/run/:/host/var/run/
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/msp:/etc/hyperledger/fabric/msp
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls:/etc/hyperledger/fabric/tls
- peer1.org3.example.com:/var/hyperledger/production
ports:
- 12051:7051
- 12053:7053

View file

@ -1,31 +0,0 @@
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
version: '2'
networks:
byfn:
services:
orderer.example.com:
volumes:
- ./ledgers/orderer.example.com:/var/hyperledger/production/orderer
peer0.org1.example.com:
volumes:
- ./ledgers/peer0.org1.example.com:/var/hyperledger/production
peer1.org1.example.com:
volumes:
- ./ledgers/peer1.org1.example.com:/var/hyperledger/production
peer0.org2.example.com:
volumes:
- ./ledgers/peer0.org2.example.com:/var/hyperledger/production
peer1.org2.example.com:
volumes:
- ./ledgers/peer1.org2.example.com:/var/hyperledger/production

View file

@ -134,10 +134,8 @@ function networkUp () {
# Tear down running network
function networkDown () {
docker-compose -f $COMPOSE_FILE_ORG3 down
docker-compose -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 down
docker-compose -f $COMPOSE_FILE down
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_ORG3 down --volumes
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH down --volumes
# Don't remove containers, images, etc if restarting
if [ "$MODE" != "restart" ]; then
#Cleanup the chaincode containers
@ -149,6 +147,10 @@ function networkDown () {
# remove the docker-compose yaml file that was customized to the example
rm -f docker-compose-e2e.yaml
fi
# For some black-magic reason the first docker-compose down does not actually cleanup the volumes
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_ORG3 down --volumes
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH down --volumes
}
# Use the CLI container to create the configuration transaction needed to add