Skip to content

Commit 6b7c059

Browse files
committed
[CE-82] Fix fabric 1.0 support bugs
* 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>
1 parent 0e12527 commit 6b7c059

File tree

13 files changed

+180
-171
lines changed

13 files changed

+180
-171
lines changed

src/agent/docker/_compose_files/fabric-0.6/local/peer-pbft.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ services:
2323
- hyperledger=true
2424
- com.docker.swarm.reschedule-policy=["on-node-failure"]
2525
environment:
26+
- CORE_LOGGING_LEVEL=${CLUSTER_LOG_LEVEL} #critical, error, warning, notice, info, debug
2627
- CORE_PEER_ADDRESSAUTODETECT=true
2728
- CORE_PEER_NETWORKID=${PEER_NETWORKID}
28-
- CORE_LOGGING_LEVEL=${CLUSTER_LOG_LEVEL} #critical, error, warning, notice, info, debug
29+
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=${PEER_VALIDATOR_CONSENSUS_PLUGIN} # noops, pbft
2930
- CORE_VM_ENDPOINT=${VM_ENDPOINT}
3031
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${VM_DOCKER_HOSTCONFIG_NETWORKMODE} # host, bridge, ipvlan, none
31-
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=${PEER_VALIDATOR_CONSENSUS_PLUGIN} # noops, pbft
3232
# The following section enables noops consensus
3333
- CORE_NOOPS_BLOCK_TIMEOUT=2 # only useful when in noops
3434
- CORE_NOOPS_BLOCK_WAIT=2 # only useful when in noops

src/agent/docker/_compose_files/fabric-1.0/local/fabric-solo-4.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
version: '2.0'
99

1010
services:
11-
ca:
11+
ca.example.com:
1212
image: hyperledger/fabric-ca
1313
container_name: ${COMPOSE_PROJECT_NAME}_fabric-ca
1414
hostname: ca
1515
# 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
16-
ports:
17-
- "7054:7054"
16+
expose:
17+
- "7054"
1818
command: fabric-ca-server start -b admin:adminpw
1919

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

8787
networks:
8888
default:

src/agent/docker/_compose_files/fabric-1.0/local/orderer-base.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ version: '2'
99
services:
1010
orderer-base:
1111
image: hyperledger/fabric-orderer
12+
restart: unless-stopped
13+
labels:
14+
- monitor=true
15+
- hyperledger=true
16+
- com.docker.swarm.reschedule-policy=["on-node-failure"]
1217
environment:
1318
- ORDERER_GENERAL_LOGLEVEL=DEBUG
1419
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
@@ -29,4 +34,11 @@ services:
2934
- ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
3035
expose:
3136
- "7050" #
37+
mem_limit: 512000000
38+
memswap_limit: 1000000000
39+
cpu_quota: 50000
40+
logging:
41+
driver: json-file
42+
options:
43+
max-size: 100m
3244
command: orderer start

src/agent/docker/_compose_files/fabric-1.0/local/peer-base.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ version: '2'
99
services:
1010
peer-base:
1111
image: hyperledger/fabric-peer
12+
restart: unless-stopped
13+
labels:
14+
- monitor=true
15+
- hyperledger=true
16+
- com.docker.swarm.reschedule-policy=["on-node-failure"]
1217
environment:
1318
#- CORE_PEER_ID=peer0
14-
- CORE_PEER_ADDRESSAUTODETECT=false
15-
- CORE_LOGGING_LEVEL=DEBUG
16-
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=local_default # uncomment this to use specific network
19+
- CORE_LOGGING_LEVEL=${CLUSTER_LOG_LEVEL} #critical, error, warning, notice, info, debug
20+
- CORE_PEER_ADDRESSAUTODETECT=true
21+
- CORE_PEER_NETWORKID=${PEER_NETWORKID}
1722
#- CORE_PEER_NETWORKID=dev
1823
- CORE_PEER_GOSSIP_USELEADERELECTION=true
1924
- CORE_PEER_GOSSIP_ORGLEADER=false # this node is the group leader, default to false
@@ -22,6 +27,8 @@ services:
2227
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
2328
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
2429
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
30+
- CORE_VM_ENDPOINT=${VM_ENDPOINT}
31+
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${VM_DOCKER_HOSTCONFIG_NETWORKMODE} # host, bridge, ipvlan, none
2532
expose:
2633
- "7050" # Rest
2734
- "7051" # Grpc
@@ -37,4 +44,11 @@ services:
3744
- /var/run/docker.sock:/var/run/docker.sock
3845
#volumes:
3946
# - /var/run/:/host/var/run/
47+
mem_limit: 512000000
48+
memswap_limit: 1000000000
49+
cpu_quota: 50000
50+
logging:
51+
driver: json-file
52+
options:
53+
max-size: 100m
4054
command: peer node start

src/agent/docker/cluster.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ class ClusterOnDocker(ClusterBase):
3131
def __init__(self):
3232
pass
3333

34-
def create(self, cid, mapped_ports, host, user_id="",
35-
network_type=NETWORK_TYPES[0],
36-
config=None):
34+
def create(self, cid, mapped_ports, host, config, user_id=""):
3735
""" Create a cluster based on given data
3836
3937
TODO: maybe need other id generation mechanism
@@ -54,7 +52,7 @@ def create(self, cid, mapped_ports, host, user_id="",
5452
# start compose project, failed then clean and return
5553
logger.debug("Start compose project with name={}".format(cid))
5654
containers = compose_up(name=cid, mapped_ports=mapped_ports, host=host,
57-
network_type=network_type, config=config)
55+
config=config)
5856
if not containers:
5957
logger.warning("failed to create cluster, with container={}"
6058
.format(containers))
@@ -63,23 +61,23 @@ def create(self, cid, mapped_ports, host, user_id="",
6361
logger.debug("Created containers={}".format(containers))
6462
return containers
6563

66-
def delete(self, id, worker_api, network_type, config):
67-
return compose_clean(id, worker_api, network_type, config)
64+
def delete(self, id, worker_api, config):
65+
return compose_clean(id, worker_api, config)
6866

69-
def start(self, name, worker_api, mapped_ports, network_type,
70-
log_type, log_level, log_server, config):
71-
return compose_start(name, worker_api, mapped_ports, network_type,
72-
log_type, log_level, log_server, config)
67+
def start(self, name, worker_api, mapped_ports, log_type, log_level,
68+
log_server, config):
69+
return compose_start(name, worker_api, mapped_ports, log_type,
70+
log_level, log_server, config)
7371

74-
def restart(self, name, worker_api, mapped_ports, network_type,
75-
log_type, log_level, log_server, config):
76-
return compose_restart(name, worker_api, mapped_ports, network_type,
77-
log_type, log_level, log_server, config)
72+
def restart(self, name, worker_api, mapped_ports, log_type, log_level,
73+
log_server, config):
74+
return compose_restart(name, worker_api, mapped_ports, log_type,
75+
log_level, log_server, config)
7876

79-
def stop(self, name, worker_api, mapped_ports, network_type,
80-
log_type, log_level, log_server, config):
81-
return compose_stop(name, worker_api, mapped_ports, network_type,
82-
log_type, log_level, log_server, config)
77+
def stop(self, name, worker_api, mapped_ports, log_type, log_level,
78+
log_server, config):
79+
return compose_stop(name, worker_api, mapped_ports, log_type,
80+
log_level, log_server, config)
8381

8482

8583
cluster_on_docker = ClusterOnDocker()

0 commit comments

Comments
 (0)