Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Switch peers from using variable IPs to hostnames. #58

Merged
merged 2 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions qubernetes
Original file line number Diff line number Diff line change
Expand Up @@ -112,31 +112,6 @@ end
# create the output directory if it doesn't exist
`mkdir -p out`

sed_string = ""
sed_string_no_escape = ""

# make all services
# set the replacement string sed command which is run on the permissioned-nodes.json,
# as the service host IPs of the nodes are not known until they are deployed, and need
# to be properly set in the permissioned-nodes.json.
#PERM_NODE_JSON=$(echo $PERM_NODE_TMPL | sed \"s/%QUORUM_DEPLOYMENT_01_SERVICE_HOST%/$QUORUM_NODE01_SERVICE_HOST/g\" | sed \"s/\\$QUORUM_DEPLOYMENT_02_SERVICE_HOST/$QUORUM_NODE02_SERVICE_HOST/g\");
@nodes.each do |node|
set_node_template_vars(node)
# puts ("#{@Node_UserIdent}")
k8_service_host_var = ("#{@Node_UserIdent}".upcase + "_SERVICE_HOST").gsub("-", "_")
permission_node_host="#{@Node_UserIdent}".upcase + "_SERVICE_HOST"
# puts (k8_service_host_var)
sed_instruction = ' sed \"s/%' + permission_node_host + '%/$' + k8_service_host_var + '/g\"'
sed_instruction_no_escape = ' sed "s/%' + permission_node_host + '%/$' + k8_service_host_var + '/g"'
sed_string = sed_string + sed_instruction + " | "
sed_string_no_escape = sed_string_no_escape + sed_instruction_no_escape + " | "
end

# used/written inside each generated deployment file.
@Sed_Set_Node_Service_Host = sed_string[0...-2]
# used inside cofigMap script
@Sed_Set_Node_Service_Host_No_Escape = sed_string_no_escape[0...-2]

@base_template_path = "templates/k8s"
#puts (sed_string)

Expand Down
9 changes: 3 additions & 6 deletions templates/k8s/quorum-deployment.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,10 @@ spec:
CONFIG_TMPL=$(cat ${DDIR}/tessera-config${TESSERA_CONFIG_TYPE}.json.tmpl);


echo \"<%= @Sed_Set_Node_Service_Host %>\";
CONFIG_WITH_OTHER_HOSTS=$(echo $CONFIG_TMPL | <%= @Sed_Set_Node_Service_Host %>) ;
CONFIG_WITH_ALL_HOSTS=$(echo $CONFIG_WITH_OTHER_HOSTS | sed \"s/%THIS_SERVICE_HOST%/$<%= @This_Host %>/g\");
PRIV_KEY=$(cat $DDIR/tm.key)
PUB_KEY=$(cat $DDIR/tm.pub)
CONFIG_FINAL=$(echo $CONFIG_WITH_ALL_HOSTS | sed \"s-%THIS_PRIV_KEY%-${PRIV_KEY}-g\" | sed \"s-%THIS_PUB_KEY%-${PUB_KEY}-g\");
CONFIG_FINAL_9_0=$(echo $CONFIG_WITH_ALL_HOSTS | sed \"s-%THIS_PRIV_KEY%-${DDIR}/tm.key-g\" | sed \"s-%THIS_PUB_KEY%-${DDIR}/tm.pub-g\");
CONFIG_FINAL=$(echo $CONFIG_TMPL | sed \"s-%THIS_PRIV_KEY%-${PRIV_KEY}-g\" | sed \"s-%THIS_PUB_KEY%-${PUB_KEY}-g\");
CONFIG_FINAL_9_0=$(echo $CONFIG_TMPL | sed \"s-%THIS_PRIV_KEY%-${DDIR}/tm.key-g\" | sed \"s-%THIS_PUB_KEY%-${DDIR}/tm.pub-g\");
if [[ \"${Tess_Ver_Second}\" -ge \"9\" ]]; then CONFIG_FINAL=${CONFIG_FINAL_9_0}; fi;
echo $CONFIG_FINAL > ${DDIR}/tessera-config-with-hosts.json;
cat ${DDIR}/tessera-config-with-hosts.json;
Expand Down Expand Up @@ -345,7 +342,7 @@ spec:
name: quorum-permissioned-config
items:
- key: permissioned-nodes.json
path: permissioned-nodes.json.tmpl
path: permissioned-nodes.json
- key: permissioned-update.sh
path: permissioned-update.sh
- name: genesis-config-persistent-storage
Expand Down
4 changes: 1 addition & 3 deletions templates/k8s/quorum-shared-config.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ data:

permissioned-update.sh: |
#!/bin/bash
PERM_NODE_TMPL=$(cat $QHOME/permission-nodes/permissioned-nodes.json.tmpl);
PERM_NODE_JSON=$(echo $PERM_NODE_TMPL | <%= @Sed_Set_Node_Service_Host_No_Escape %>);
echo $PERM_NODE_JSON > $QUORUM_DATA_DIR/permissioned-nodes.json;
cp $QUORUM_HOME/permission-nodes/permissioned-nodes.json $QUORUM_DATA_DIR/permissioned-nodes.json;
cp $QUORUM_DATA_DIR/permissioned-nodes.json $QUORUM_DATA_DIR/static-nodes.json;

---
Expand Down
13 changes: 7 additions & 6 deletions templates/quorum/permissioned-nodes.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ end
# The enode value is obtained from that file and set in the permissioned-nodes.json
-%>
[
<%- @nodes.each_with_index do |node, indexNode| -%>
<%- set_node_template_vars(node) -%>
<%- @Enode_File = @Key_Dir_Base + "/" + @Node_Key_Dir + "/enode" -%>
<%- File.readlines(@Enode_File).each do |line| @Enode = "#{line}".gsub(/\s+/, "") end -%>
"enode://<%= @Enode %>@%<%= "#{@Node_UserIdent}".upcase %>_SERVICE_HOST%:<%= @NodeP2P_ListenAddr%>?discport=0&raftport=<%= @Raft_Port%>"<%- if (indexNode != @nodes.size - 1) %>,<%- end %>
<% end -%>
<%- @nodes.each_with_index do |node, indexNode| -%>
<%- set_node_template_vars(node) -%>
<%- @Enode_File = @Key_Dir_Base + "/" + @Node_Key_Dir + "/enode" -%>
<%- File.readlines(@Enode_File).each do |line| @Enode = "#{line}".gsub(/\s+/, "") end -%>
<%- # use the service name / kube-dns to look up the nodes -%>
"enode://<%= @Enode %>@<%= "#{@Node_UserIdent}"%>:<%= @NodeP2P_ListenAddr%>?discport=0&raftport=<%= @Raft_Port%>"<%- if (indexNode != @nodes.size - 1) %>,<%- end %>
<% end -%>
]
6 changes: 3 additions & 3 deletions templates/quorum/tessera-config-9.0.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
{
"app":"ThirdParty",
"enabled": true,
"serverAddress": "http://%THIS_SERVICE_HOST%:<%= @Tm_3Party_Port %>",
"serverAddress": "http://<%= @Node_UserIdent %>:<%= @Tm_3Party_Port %>",
"cors": {
"allowedMethods": [
"GET",
Expand All @@ -45,7 +45,7 @@ end
{
"app":"P2P",
"enabled": true,
"serverAddress":"http://%THIS_SERVICE_HOST%:<%= @Tm_Port %>",
"serverAddress":"http://<%= @Node_UserIdent %>:<%= @Tm_Port %>",
"sslConfig": {
"tls": "OFF",
"generateKeyStoreIfNotExisted": true,
Expand All @@ -70,7 +70,7 @@ end
<%- @nodes.each_with_index do |node, indexNode| %>
<%= set_node_template_vars(node) -%>
{
"url": "http://%<%= "#{@Node_UserIdent}".upcase %>_SERVICE_HOST%:<%= @Tm_Port %>"
"url": "http://<%= @Node_UserIdent %>:<%= @Tm_Port %>"
}<%- if (indexNode != @nodes.size - 1) %>,<%- end %>

<% end -%>
Expand Down
6 changes: 3 additions & 3 deletions templates/quorum/tessera-config-enhanced.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end
"serverSocket":{
"type":"INET",
"port": <%= @Tm_3Party_Port %>,
"hostName": "http://%THIS_SERVICE_HOST%"
"hostName": "http://<%= @Node_UserIdent %>"
},
"communicationType" : "REST"
},
Expand All @@ -46,7 +46,7 @@ end
"serverSocket":{
"type":"INET",
"port": <%= @Tm_Port %>,
"hostName": "http://%THIS_SERVICE_HOST%",
"hostName": "http://<%= @Node_UserIdent %>",
"bindingAddress": "http://0.0.0.0:<%= @Tm_Port %>"
},
"sslConfig": {
Expand All @@ -73,7 +73,7 @@ end
<%- @nodes.each_with_index do |node, indexNode| %>
<%= set_node_template_vars(node) -%>
{
"url": "http://%<%= "#{@Node_UserIdent}".upcase %>_SERVICE_HOST%:<%= @Tm_Port %>"
"url": "http://<%= @Node_UserIdent %>:<%= @Tm_Port %>"
}<%- if (indexNode != @nodes.size - 1) %>,<%- end %>

<% end -%>
Expand Down
4 changes: 2 additions & 2 deletions templates/quorum/tessera-config.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
},
"server": {
"port": <%= @Tm_Port %>,
"hostName": "http://%THIS_SERVICE_HOST%",
"hostName": "http://<%= @Node_UserIdent %>",
"bindingAddress": "http://0.0.0.0:<%= @Tm_Port %>",
"sslConfig": {
"tls": "OFF",
Expand All @@ -46,7 +46,7 @@ end
<%- @nodes.each_with_index do |node, indexNode| %>
<%= set_node_template_vars(node) -%>
{
"url": "http://%<%= "#{@Node_UserIdent}".upcase %>_SERVICE_HOST%:<%= @Tm_Port %>"
"url": "http://%<%= @Node_UserIdent%>%:<%= @Tm_Port %>"
}<%- if (indexNode != @nodes.size - 1) %>,<%- end %>

<% end -%>
Expand Down
26 changes: 0 additions & 26 deletions testing/qversions-config/qubes-ibft-2.2.0.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions testing/qversions-config/qubes-ibft-2.3.0.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions testing/qversions-config/qubes-raft-2.2.0.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions testing/qversions-config/qubes-raft-2.3.0.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions testing/test-qnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ then
fi

## Test blockNumber for Public TX, should be > 1
echo "sleeping for 5 seconds to give block time to increase."
sleep 5
get_block_number $NAMESPACE
BLOCK_NUM=$?
echo "BLOCK_NUM: [$BLOCK_NUM]"
Expand Down