Skip to content

Commit

Permalink
[CE-82] Fix fabric 1.0 support bugs
Browse files Browse the repository at this point in the history
* Setup the fabric network using the initialize.sh script;
* Fix port mapping conflicts in fabric-ca service;
* Fix docker-compose env variables.

Change-Id: Ib2135f0d23ec5114f4b25bb6e57328ee8485b859
Signed-off-by: Baohua Yang <yangbaohua@gmail.com>
  • Loading branch information
yeasy committed Jul 11, 2017
1 parent 0e12527 commit 6b7c059
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ services:
- hyperledger=true
- com.docker.swarm.reschedule-policy=["on-node-failure"]
environment:
- CORE_LOGGING_LEVEL=${CLUSTER_LOG_LEVEL} #critical, error, warning, notice, info, debug
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_NETWORKID=${PEER_NETWORKID}
- CORE_LOGGING_LEVEL=${CLUSTER_LOG_LEVEL} #critical, error, warning, notice, info, debug
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=${PEER_VALIDATOR_CONSENSUS_PLUGIN} # noops, pbft
- CORE_VM_ENDPOINT=${VM_ENDPOINT}
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${VM_DOCKER_HOSTCONFIG_NETWORKMODE} # host, bridge, ipvlan, none
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=${PEER_VALIDATOR_CONSENSUS_PLUGIN} # noops, pbft
# The following section enables noops consensus
- CORE_NOOPS_BLOCK_TIMEOUT=2 # only useful when in noops
- CORE_NOOPS_BLOCK_WAIT=2 # only useful when in noops
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
version: '2.0'

services:
ca:
ca.example.com:
image: hyperledger/fabric-ca
container_name: ${COMPOSE_PROJECT_NAME}_fabric-ca
hostname: ca
# command: /go/src/github.com/hyperledger/fabric-ca/bin/ca server start -ca testdata/ec.pem -ca-key testdata/ec-key.pem -config testdata/testconfig.json
ports:
- "7054:7054"
expose:
- "7054"
command: fabric-ca-server start -b admin:adminpw

orderer.example.com: # There can be multiple orderers
Expand Down Expand Up @@ -82,7 +82,7 @@ services:
- peer0.org2.example.com
- peer1.org2.example.com
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: bash -c 'while true; do sleep 20170504; done'
command: bash -c 'sleep 2; bash ./scripts/initialize.sh; while true; do sleep 20170504; done'

networks:
default:
Expand Down
12 changes: 12 additions & 0 deletions src/agent/docker/_compose_files/fabric-1.0/local/orderer-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ version: '2'
services:
orderer-base:
image: hyperledger/fabric-orderer
restart: unless-stopped
labels:
- monitor=true
- hyperledger=true
- com.docker.swarm.reschedule-policy=["on-node-failure"]
environment:
- ORDERER_GENERAL_LOGLEVEL=DEBUG
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
Expand All @@ -29,4 +34,11 @@ services:
- ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
expose:
- "7050" #
mem_limit: 512000000
memswap_limit: 1000000000
cpu_quota: 50000
logging:
driver: json-file
options:
max-size: 100m
command: orderer start
20 changes: 17 additions & 3 deletions src/agent/docker/_compose_files/fabric-1.0/local/peer-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ version: '2'
services:
peer-base:
image: hyperledger/fabric-peer
restart: unless-stopped
labels:
- monitor=true
- hyperledger=true
- com.docker.swarm.reschedule-policy=["on-node-failure"]
environment:
#- CORE_PEER_ID=peer0
- CORE_PEER_ADDRESSAUTODETECT=false
- CORE_LOGGING_LEVEL=DEBUG
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=local_default # uncomment this to use specific network
- CORE_LOGGING_LEVEL=${CLUSTER_LOG_LEVEL} #critical, error, warning, notice, info, debug
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_NETWORKID=${PEER_NETWORKID}
#- CORE_PEER_NETWORKID=dev
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false # this node is the group leader, default to false
Expand All @@ -22,6 +27,8 @@ services:
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
- CORE_VM_ENDPOINT=${VM_ENDPOINT}
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${VM_DOCKER_HOSTCONFIG_NETWORKMODE} # host, bridge, ipvlan, none
expose:
- "7050" # Rest
- "7051" # Grpc
Expand All @@ -37,4 +44,11 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
#volumes:
# - /var/run/:/host/var/run/
mem_limit: 512000000
memswap_limit: 1000000000
cpu_quota: 50000
logging:
driver: json-file
options:
max-size: 100m
command: peer node start
34 changes: 16 additions & 18 deletions src/agent/docker/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ class ClusterOnDocker(ClusterBase):
def __init__(self):
pass

def create(self, cid, mapped_ports, host, user_id="",
network_type=NETWORK_TYPES[0],
config=None):
def create(self, cid, mapped_ports, host, config, user_id=""):
""" Create a cluster based on given data
TODO: maybe need other id generation mechanism
Expand All @@ -54,7 +52,7 @@ def create(self, cid, mapped_ports, host, user_id="",
# start compose project, failed then clean and return
logger.debug("Start compose project with name={}".format(cid))
containers = compose_up(name=cid, mapped_ports=mapped_ports, host=host,
network_type=network_type, config=config)
config=config)
if not containers:
logger.warning("failed to create cluster, with container={}"
.format(containers))
Expand All @@ -63,23 +61,23 @@ def create(self, cid, mapped_ports, host, user_id="",
logger.debug("Created containers={}".format(containers))
return containers

def delete(self, id, worker_api, network_type, config):
return compose_clean(id, worker_api, network_type, config)
def delete(self, id, worker_api, config):
return compose_clean(id, worker_api, config)

def start(self, name, worker_api, mapped_ports, network_type,
log_type, log_level, log_server, config):
return compose_start(name, worker_api, mapped_ports, network_type,
log_type, log_level, log_server, config)
def start(self, name, worker_api, mapped_ports, log_type, log_level,
log_server, config):
return compose_start(name, worker_api, mapped_ports, log_type,
log_level, log_server, config)

def restart(self, name, worker_api, mapped_ports, network_type,
log_type, log_level, log_server, config):
return compose_restart(name, worker_api, mapped_ports, network_type,
log_type, log_level, log_server, config)
def restart(self, name, worker_api, mapped_ports, log_type, log_level,
log_server, config):
return compose_restart(name, worker_api, mapped_ports, log_type,
log_level, log_server, config)

def stop(self, name, worker_api, mapped_ports, network_type,
log_type, log_level, log_server, config):
return compose_stop(name, worker_api, mapped_ports, network_type,
log_type, log_level, log_server, config)
def stop(self, name, worker_api, mapped_ports, log_type, log_level,
log_server, config):
return compose_stop(name, worker_api, mapped_ports, log_type,
log_level, log_server, config)


cluster_on_docker = ClusterOnDocker()
Loading

0 comments on commit 6b7c059

Please sign in to comment.