Skip to content

Commit

Permalink
[CE-462] Remove explorer from docker agent
Browse files Browse the repository at this point in the history
Remove explorer service from docker agent.
Can't delete cluster when chain is applied.

Change-Id: I747eaedc86588a0eadea4a230d0b7a7af224818e
Signed-off-by: Haitao Yue <[email protected]>
  • Loading branch information
hightall committed Sep 6, 2018
1 parent 042637f commit d4c1909
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 100 deletions.
78 changes: 39 additions & 39 deletions src/agent/docker/_compose_files/fabric-1.0/fabric-solo-4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,42 +242,42 @@ services:
# - ${COMPOSE_PROJECT_PATH}/examples:/opt/gopath/src/examples
# command: bash -c 'sleep 15; cd /tmp; source scripts/func.sh; bash scripts/test_channel_create.sh; bash scripts/test_channel_join.sh; bash scripts/test_cc_install.sh; while true; do sleep 20180101; done'

explorer:
image: yeasy/blockchain-explorer:0.1.0-preview
container_name: ${COMPOSE_PROJECT_NAME}_explorer
hostname: explorer
restart: always
volumes:
- ${COMPOSE_PROJECT_PATH}/explorer-artifacts/config.json:/blockchain-explorer/config.json
- ${COMPOSE_PROJECT_PATH}/crypto-config:/blockchain-explorer/first-network/crypto-config
ports:
- "${EXPLORER_PORT}:8080"
depends_on:
- mysql
- orderer.example.com
- peer0.org1.example.com
- peer1.org1.example.com
- peer0.org2.example.com
- peer1.org2.example.com
links:
- orderer.example.com
- peer0.org1.example.com
- peer1.org1.example.com
- peer0.org2.example.com
- peer1.org2.example.com
command: bash -c 'sleep 30; node main.js'

mysql: # mysql service
image: mysql:5.7
container_name: ${COMPOSE_PROJECT_NAME}_mysql
hostname: mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=fabricexplorer
- STARTUP_SQL=/fabricexplorer.sql
volumes:
- ${COMPOSE_PROJECT_PATH}/explorer-artifacts/fabricexplorer.sql:/docker-entrypoint-initdb.d/fabricexplorer.sql
expose:
- "3306"
command: mysqld
# explorer:
# image: yeasy/blockchain-explorer:0.1.0-preview
# container_name: ${COMPOSE_PROJECT_NAME}_explorer
# hostname: explorer
# restart: always
# volumes:
# - ${COMPOSE_PROJECT_PATH}/explorer-artifacts/config.json:/blockchain-explorer/config.json
# - ${COMPOSE_PROJECT_PATH}/crypto-config:/blockchain-explorer/first-network/crypto-config
# ports:
# - "${EXPLORER_PORT}:8080"
# depends_on:
# - mysql
# - orderer.example.com
# - peer0.org1.example.com
# - peer1.org1.example.com
# - peer0.org2.example.com
# - peer1.org2.example.com
# links:
# - orderer.example.com
# - peer0.org1.example.com
# - peer1.org1.example.com
# - peer0.org2.example.com
# - peer1.org2.example.com
# command: bash -c 'sleep 30; node main.js'
#
# mysql: # mysql service
# image: mysql:5.7
# container_name: ${COMPOSE_PROJECT_NAME}_mysql
# hostname: mysql
# restart: always
# environment:
# - MYSQL_ROOT_PASSWORD=root
# - MYSQL_DATABASE=fabricexplorer
# - STARTUP_SQL=/fabricexplorer.sql
# volumes:
# - ${COMPOSE_PROJECT_PATH}/explorer-artifacts/fabricexplorer.sql:/docker-entrypoint-initdb.d/fabricexplorer.sql
# expose:
# - "3306"
# command: mysqld
78 changes: 39 additions & 39 deletions src/agent/docker/_compose_files/fabric-1.2/fabric-solo-4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,42 +242,42 @@ services:
# - ${COMPOSE_PROJECT_PATH}/examples:/opt/gopath/src/examples
# command: bash -c 'sleep 15; cd /tmp; source scripts/func.sh; bash scripts/test_channel_create.sh; bash scripts/test_channel_join.sh; bash scripts/test_cc_install.sh; while true; do sleep 20180101; done'

explorer:
image: yeasy/blockchain-explorer:0.1.0-preview
container_name: ${COMPOSE_PROJECT_NAME}_explorer
hostname: explorer
restart: always
volumes:
- ${COMPOSE_PROJECT_PATH}/explorer-artifacts/config.json:/blockchain-explorer/config.json
- ${COMPOSE_PROJECT_PATH}/crypto-config:/blockchain-explorer/first-network/crypto-config
ports:
- "${EXPLORER_PORT}:8080"
depends_on:
- mysql
- orderer.example.com
- peer0.org1.example.com
- peer1.org1.example.com
- peer0.org2.example.com
- peer1.org2.example.com
links:
- orderer.example.com
- peer0.org1.example.com
- peer1.org1.example.com
- peer0.org2.example.com
- peer1.org2.example.com
command: bash -c 'sleep 30; node main.js'

mysql: # mysql service
image: mysql:5.7
container_name: ${COMPOSE_PROJECT_NAME}_mysql
hostname: mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=fabricexplorer
- STARTUP_SQL=/fabricexplorer.sql
volumes:
- ${COMPOSE_PROJECT_PATH}/explorer-artifacts/fabricexplorer.sql:/docker-entrypoint-initdb.d/fabricexplorer.sql
expose:
- "3306"
command: mysqld
# explorer:
# image: yeasy/blockchain-explorer:0.1.0-preview
# container_name: ${COMPOSE_PROJECT_NAME}_explorer
# hostname: explorer
# restart: always
# volumes:
# - ${COMPOSE_PROJECT_PATH}/explorer-artifacts/config.json:/blockchain-explorer/config.json
# - ${COMPOSE_PROJECT_PATH}/crypto-config:/blockchain-explorer/first-network/crypto-config
# ports:
# - "${EXPLORER_PORT}:8080"
# depends_on:
# - mysql
# - orderer.example.com
# - peer0.org1.example.com
# - peer1.org1.example.com
# - peer0.org2.example.com
# - peer1.org2.example.com
# links:
# - orderer.example.com
# - peer0.org1.example.com
# - peer1.org1.example.com
# - peer0.org2.example.com
# - peer1.org2.example.com
# command: bash -c 'sleep 30; node main.js'
#
# mysql: # mysql service
# image: mysql:5.7
# container_name: ${COMPOSE_PROJECT_NAME}_mysql
# hostname: mysql
# restart: always
# environment:
# - MYSQL_ROOT_PASSWORD=root
# - MYSQL_DATABASE=fabricexplorer
# - STARTUP_SQL=/fabricexplorer.sql
# volumes:
# - ${COMPOSE_PROJECT_PATH}/explorer-artifacts/fabricexplorer.sql:/docker-entrypoint-initdb.d/fabricexplorer.sql
# expose:
# - "3306"
# command: mysqld
31 changes: 10 additions & 21 deletions src/modules/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
WORKER_TYPES, WORKER_TYPE_DOCKER, WORKER_TYPE_SWARM, WORKER_TYPE_K8S, \
WORKER_TYPE_VSPHERE, VMIP, \
NETWORK_SIZE_FABRIC_PRE_V1, \
PEER_SERVICE_PORTS, EXPLORER_PORTS, \
PEER_SERVICE_PORTS, \
ORDERER_SERVICE_PORTS, \
NETWORK_STATUS_CREATING, NETWORK_STATUS_RUNNING, NETWORK_STATUS_DELETING

Expand Down Expand Up @@ -109,15 +109,13 @@ def get_by_id(self, id, col_name="active"):
return {}
return self._schema(cluster)

def gen_service_urls(self, cid, peer_ports, ca_ports, orderer_ports,
explorer_ports):
def gen_service_urls(self, cid, peer_ports, ca_ports, orderer_ports):
"""
Generate the service urls based on the mapping ports
:param cid: cluster id to operate with
:param peer_ports: peer ports mapping
:param ca_ports: ca ports mapping
:param orderer_ports: orderer ports mapping
:param explorer_ports: explorer ports mapping
:return: service url mapping. {} means failure
"""
access_peer = 'peer0.org1.example.com'
Expand All @@ -139,8 +137,6 @@ def gen_service_urls(self, cid, peer_ports, ca_ports, orderer_ports,
service_urls[k] = "{}:{}".format(ca_host_ip, v)
for k, v in orderer_ports.items():
service_urls[k] = "{}:{}".format(ca_host_ip, v)
for k, v in explorer_ports.items():
service_urls[k] = "{}:{}".format(peer_host_ip, v)
return service_urls

def gen_ports_mapping(self, peer_num, ca_num, start_port, host_id):
Expand All @@ -155,8 +151,7 @@ def gen_ports_mapping(self, peer_num, ca_num, start_port, host_id):
request_port_num = \
peer_num * (len(peer_service_ports.items())) + \
ca_num * len(ca_service_ports.items()) + \
len(ORDERER_SERVICE_PORTS.items()) + \
len(EXPLORER_PORTS.items())
len(ORDERER_SERVICE_PORTS.items())
logger.debug("request port number {}".format(request_port_num))

if start_port <= 0: # need to dynamic find available ports
Expand All @@ -170,7 +165,7 @@ def gen_ports_mapping(self, peer_num, ca_num, start_port, host_id):
logger.debug("ports {}".format(ports))

peer_ports, ca_ports, orderer_ports = {}, {}, {}
explorer_ports, all_ports = {}, {}
all_ports = {}

if peer_num > 1:
org_num_list = [1, 2]
Expand Down Expand Up @@ -198,20 +193,15 @@ def gen_ports_mapping(self, peer_num, ca_num, start_port, host_id):
orderer_ports[k] = ports[pos]
logger.debug("pos={}".format(pos))
pos += 1
for k, v in EXPLORER_PORTS.items(): # explorer ports
explorer_ports[k] = ports[pos]
pos += 1

all_ports.update(peer_ports)
all_ports.update(ca_ports)
all_ports.update(orderer_ports)
all_ports.update(explorer_ports)

return all_ports, peer_ports, ca_ports, orderer_ports, explorer_ports
return all_ports, peer_ports, ca_ports, orderer_ports

def _create_cluster(self, cluster, cid, mapped_ports, worker, config,
user_id, peer_ports, ca_ports, orderer_ports,
explorer_ports):
user_id, peer_ports, ca_ports, orderer_ports):
# start compose project, failed then clean and return
logger.debug("Start compose project with name={}".format(cid))
containers = self.cluster_agents[worker.type] \
Expand All @@ -233,8 +223,8 @@ def _create_cluster(self, cluster, cid, mapped_ports, worker, config,
service_urls = self.cluster_agents[worker.type]\
.get_services_urls(cid)
else:
service_urls = self.gen_service_urls(cid, peer_ports, ca_ports,
orderer_ports, explorer_ports)
service_urls = self.gen_service_urls(cid, peer_ports,
ca_ports, orderer_ports)
# update the service port table in db
for k, v in service_urls.items():
service_port = ServicePort(name=k, ip=v.split(":")[0],
Expand Down Expand Up @@ -296,7 +286,7 @@ def create(self, name, host_id, config, start_port=0,
ca_num = 2 if peer_num > 1 else 1

cid = uuid4().hex
mapped_ports, peer_ports, ca_ports, orderer_ports, explorer_ports = \
mapped_ports, peer_ports, ca_ports, orderer_ports = \
self.gen_ports_mapping(peer_num, ca_num, start_port, host_id)
if not mapped_ports:
logger.error("mapped_ports={}".format(mapped_ports))
Expand Down Expand Up @@ -328,8 +318,7 @@ def create(self, name, host_id, config, start_port=0,
mapped_ports, worker,
config, user_id,
peer_ports, ca_ports,
orderer_ports,
explorer_ports))
orderer_ports))
t.start()
return cid

Expand Down
2 changes: 1 addition & 1 deletion src/static/dashboard/src/routes/Chain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class Chain extends PureComponent {
<Menu.Item key="release" chain={chainItem}>
<FormattedMessage {...messages.button.release} />
</Menu.Item>
<Menu.Item key="delete" chain={chainItem}>
<Menu.Item disabled={chainItem.user_id !== ''} key="delete" chain={chainItem}>
<span className={styles['delete-button']}>
<FormattedMessage {...messages.button.delete} />
</span>
Expand Down

0 comments on commit d4c1909

Please sign in to comment.