Skip to content

Commit

Permalink
[CE-466] Genesis block not found in Orderer
Browse files Browse the repository at this point in the history
When creating Fabric cluster on Kubernetes agent with kafka
consensus type, the orderer pod will throw out an error about
"genesis.block not found", because the genesis block is called
"orderer.genesis.block", this patch is meant to correct that name.
This patch also disable the Explorer setup too.

CE-466 # done

Change-Id: I267d020a41fac28156bf5461563dca0554efcb1d
Signed-off-by: luke <jiahaochen1993@gmail.com>
  • Loading branch information
jiahaoc1993 committed Sep 6, 2018
1 parent 042637f commit 433822b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 47 deletions.
57 changes: 11 additions & 46 deletions src/agent/k8s/cluster_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ def _get_node_ip(self, node_name):
def _get_node_ip_of_service(self, service_name):
ret = self.corev1client.list_pod_for_all_namespaces(watch=False)

# The fabric-explorer service_name is different with it's pod
if "fabric-explorer" in service_name:
service_name = "fabric-explorer"

for i in ret.items:
if i.metadata.name.startswith(service_name):
return self._get_node_ip(i.spec.node_name)
Expand Down Expand Up @@ -214,13 +210,6 @@ def _get_service_external_port(self, namespace, ip):
value = r_template.format(_port)
results[name] = value

elif i.metadata.name.startswith("fabric-explorer"):
name = "dashboard"
for port in i.spec.ports:
_port = port.node_port
value = r_template.format(_port)
results[name] = value

else:
continue

Expand Down Expand Up @@ -499,11 +488,12 @@ def _deploy_cluster_resource(self, cluster_name,
cluster_ports,
nfsServer_ip)
else:
file_data = self._render_config_file("orderer0.ordererorg-kafka\
.tpl",
cluster_name,
cluster_ports,
nfsServer_ip)
file_data = self \
._render_config_file("orderer0.ordererorg-kafka.tpl",
cluster_name,
cluster_ports,
nfsServer_ip)

yaml_data = yaml.load_all(file_data)
self._deploy_k8s_resource(yaml_data)

Expand Down Expand Up @@ -548,31 +538,13 @@ def deploy_cluster(self, cluster_name, ports_index,

time.sleep(3)

# Disable explorer
# fabric explorer at last
# file_data = self._render_config_file("fabric-1-0-explorer.tpl",
# cluster_name, cluster_ports,
# nfsServer_ip)
# yaml_data = yaml.load_all(file_data)
# self._deploy_k8s_resource(yaml_data)

time.sleep(3)

return self._get_cluster_pods(cluster_name)

def _delete_cluster_resource(self, cluster_name,
cluster_ports, nfsServer_ip, consensus):
""" The order to delete the cluster is reverse to
create except for namespace
"""
file_data = self._render_config_file("fabric-1-0-explorer.tpl",
cluster_name, cluster_ports,
nfsServer_ip)
yaml_data = yaml.load_all(file_data)
self._delete_k8s_resource(yaml_data)

time.sleep(3)

current_path = os.path.dirname(__file__)
templates_path = os.path.join(current_path, "templates")
for (dir_path, dir_name, file_list) in os.walk(templates_path):
Expand Down Expand Up @@ -610,10 +582,11 @@ def _delete_cluster_resource(self, cluster_name,
cluster_ports,
nfsServer_ip)
else:
file_data = self._render_config_file("orderer0.ordererorg-kafka\
.tpl", cluster_name,
cluster_ports,
nfsServer_ip)
file_data = self. \
_render_config_file("orderer0.ordererorg-kafka.tpl",
cluster_name,
cluster_ports,
nfsServer_ip)

time.sleep(3)

Expand Down Expand Up @@ -652,12 +625,4 @@ def start_cluster(self, cluster_name, ports_index, nfsServer_ip,
self._deploy_cluster_resource(cluster_name, cluster_ports,
nfsServer_ip, consensus)
time.sleep(2)
# fabric explorer at last
file_data = self._render_config_file("fabric-1-0-explorer.tpl",
cluster_name,
cluster_ports,
nfsServer_ip)
yaml_data = yaml.load_all(file_data)
self._deploy_k8s_resource(yaml_data)
time.sleep(2)
return self._get_cluster_pods(cluster_name)
2 changes: 1 addition & 1 deletion src/agent/k8s/templates/orderer0.ordererorg-kafka.tpl
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
subPath: orderers/orderer.example.com/tls
- mountPath: /var/hyperledger/orderer/orderer.genesis.block
name: certificate
subPath: genesis.block
subPath: orderer.genesis.block
- mountPath: /var/hyperledger/production
name: certificate
subPath: orderers/orderer.example.com/production
Expand Down

0 comments on commit 433822b

Please sign in to comment.