Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
1. removed temp folder after packaging
2. moved commit checks to commit operation

Signed-off-by: weihong-ou <weihong.ou@walmart.com>
  • Loading branch information
weihong-ou committed Jul 20, 2021
1 parent 0d4f257 commit ecaf8d4
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,9 @@ spec:
#chaincode path
CC_SRC_PATH="github.com/chaincode/${CHAINCODE_NAME}/${CHAINCODE_MAINDIR}"
echo "Sunsu: setting the dependencies start"
cd $GOPATH/src/$CC_SRC_PATH
echo "Sunsu: setting the dependencies"
GO111MODULE=on go mod vendor
cd $GOPATH/src/github.com/chaincode
echo "Sunsu: setting the dependencies end"
cd $GOPATH/src/github.com/chaincode
elif [ ${CC_RUNTIME_LANGUAGE} = "java" ]
then
## Copying desired chaincode to a location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@

############################################################################################
# This task commits the desired approved chaincode
# TODO: Chaincode to deploy to specified channels
- name: Commit chaincode
include_role:
name: "create/chaincode/commit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
VAULT_ADDR: "{{ vault.url }}"
VAULT_TOKEN: "{{ vault.root_token }}"
when:
- peer.name == first_peer_name
- peer.name == first_peer_name
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,24 @@
loop: "{{ item | json_query(channelcreator_query) }}"
loop_control:
loop_var: participant


############################################################################################
# This task only check for the first peer of the first creator listed
- name: "Waiting for chaincode to be commited on {{ peer.name }}"
include_role:
name: "{{ playbook_dir }}/../../shared/configuration/roles/check/helm_component"
vars:
channelcreator_query: "participants[?type=='creator']"
org_query: "organizations[?name=='{{participant.name}}']"
org: "{{ network | json_query(org_query) | first }}"
peer: "{{ org.services.peers | first}}"
kubernetes: "{{ org.k8s }}"
component_type: "Job"
namespace: "{{ org.name | lower }}-net"
component_name: "commitchaincode-{{ peer.chaincode.name }}-{{ peer.chaincode.version }}-{{ peer.chaincode.sequence }}"
loop: "{{ (item | json_query(channelcreator_query))[0:1] }}"
loop_control:
loop_var: participant
when:
- peer.chaincode is defined and '2.' in network.version
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
###########################################################################################
# This task is to create a temporary directory for packaging
- name: Creates temporary package folder
file:
state: directory
path: "tmp/package/{{ org_ns }}"

# This task copies the certificates used for the packaging to temp folder
- name: Copies the certificate to temp folder
shell: |
# Creates temp folder for packaging
mkdir -p tmp/package/{{ org_ns }}
# Copies certificates from ca-tools pod to temp folder
export CA_TOOL_CLI=$(KUBECONFIG={{ kubernetes.config_file }} kubectl get po -n {{ org_ns }} | grep "ca-tools" | awk '{print $1}');
KUBECONFIG={{ kubernetes.config_file }} kubectl cp {{ org_ns }}/${CA_TOOL_CLI}:crypto-config/peerOrganizations/{{ org_ns }}/users/{{ first_peer_name }}-chaincode@{{ org_ns }}/tls ./tmp/package/{{ org_ns }};
vars:
Expand Down Expand Up @@ -86,6 +87,7 @@
shell: |
PACKAGE_VAULT_ADDR={{ vault.secret_path | default('secret') }}/crypto/peerOrganizations/{{ org_ns }}/chaincode/{{ chaincode_name }}/package/v{{ chaincode_version }}
vault write ${PACKAGE_VAULT_ADDR} package-base64="$(cat ./tmp/package/{{ org_ns }}/{{ package_name }}.tgz | base64)"
rm -rf ./tmp/package
vars:
chaincode_name: "{{ peers[0].chaincode.name | lower }}"
chaincode_version: "{{ peers[0].chaincode.version }}"
Expand All @@ -94,6 +96,13 @@
VAULT_ADDR: "{{ vault.url }}"
VAULT_TOKEN: "{{ vault.root_token }}"

# This task delete the packaging temp directory
- name: Deletes the temp package directory
file:
path: "tmp/package/{{ org_ns }}"
state: absent
when: packagefile.stat.exists == true

# This task installs the external chaincode details
- name: Installs the external chaincode details
include_tasks: nested_main.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
############################################################################################
# This task fails the deployment if no commit indicator is found
# - name: Fail the deployment because no commit indicator is found
# fail:
# msg: "No commit indicators is found, {'committedpeer': {'orgnamespace': 'chaincodename-version'}}"
# when: committedpeer is not defined or committedpeer.keys() | length == 0

# This task check committed chaincode pods for all channels
- name: Commit chaincode
include_tasks: wait_for_commit_sub.yaml
vars:
participants: "{{ channel.participants }}"
loop: "{{ network['channels'] }}"
loop_control:
loop_var: channel
when: add_new_org == 'false' and '2.' in network.version

# This task deploys the external chaincode server
- name: Deploy the external chaincode server
include_tasks: nested_main.yaml
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
core_yaml:
initialize_from: file
tpl: {{ peer.core_yaml.tpl }}
{% if peer.core_yaml.tpl == False %}
{% if peer.core_yaml.tpl == false %}
base64: {{ core_yaml_file.stdout | b64encode }}
{% endif %}
{% if peer.core_yaml.configpath is defined %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
- name: Fetch current core.yaml from running peers
shell: |
export POD_NAME=$(KUBECONFIG={{ kubernetes.config_file }} kubectl get po -n {{ component_name }} | grep "{{ peer.name }}-0" | awk '{print $1}')
KUBECONFIG={{ kubernetes.config_file }} kubectl cp {{ component_name }}/${POD_NAME}:/etc/hyperledger/fabric/core.yaml -c {{ peer.name }} ../../../build/{{ peer.name }}-{{ item.name }}-core.yaml
KUBECONFIG={{ kubernetes.config_file }} kubectl cp {{ component_name }}/${POD_NAME}:/etc/hyperledger/fabric/core.yaml -c {{ peer.name }} ../../../build/{{ peer.name }}-{{ org_name }}-core.yaml
vars:
org_name: "{{ item.name }}"
loop_control:
loop_var: peer
loop: "{{ component_services.peers }}"
15 changes: 15 additions & 0 deletions platforms/hyperledger-fabric/releases/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Platform Releases
The Blockchain Automation Framework follows utilizes a [Gitops](https://www.weave.works/technologies/gitops/) approach for deploying and maintaining environment specific platform configurations. For each environment in which the components are deployed, you will maintain a separate sub-directory under this directory in the format...
```
└── releases
├── dev
│ └── org1
│ └── org1-database.yaml
└── stg
└── org1
└── org1-database.yaml
```

For more information, please read [the documentation](https://www.weave.works/technologies/gitops/) on the GitOps approach provided by Weave Works.
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ else # If User certificate exists
cp ${ORG_HOME}/chaincode/${CHAINCODE_NAME}/v${VERSION}/tls/signcerts/* ${ORG_CYPTO_FOLDER}/chaincode/${ORG_USER}/tls/client.crt
cp ${ORG_HOME}/chaincode/${CHAINCODE_NAME}/v${VERSION}/tls/tlscacerts/* ${ORG_CYPTO_FOLDER}/chaincode/${ORG_USER}/tls/ca.crt
fi
fi
fi

0 comments on commit ecaf8d4

Please sign in to comment.