Closed jagpreetsinghsasan closed 1 year ago
Two more important stuff to work on this big issue.
Thanks @jagpreetsinghsasan for this detailed summary. I think automating the whole thing would not be necessary as this is not something an operator would do multiple times. If we can create a detailed Guide for readthedocs, that should complete this task.
Description
As a developer, I want to upgrade the existing Hyperledger Fabric 1.4.x deployment (done using Hyperledger Bevel) to Hyperledger Fabric 2.2.x deployment
Before you start reading the actual issue description :)
Its gonna be a loooooooong hands-on experience. 🙂😁👍
And this spike is must to list down the automation GH issues, which is needed once we verify that this spike works! (definitely what is written down will not be 100% accurate due to extra variables like kubernetes, ambassador and others)
I will try my best to mention each and every step in precise details here, but you can refer to the official guide anytime.
Here it goes!
The general trend of upgrading entities is like
Backup the data
Upgrade the binary
Restart the entity
So, lets divide the entire flow into these 2 segments and work on them accordingly.
Back-up of ledgers, MSPs etc etc..
THIS NEEDS MORE RESEARCH : The data needed to be backup are already present on pvc and if not, we need to migrate those data to pvc (If the migration is needed, the required shell script, which needs to be run in the pod container, shall also be created for the upcoming automation stories to work with.)
/var/hyperledger/production/orderer
for orderer node and/var/hyperledger/production
for peer node. (Note, this should be in order, as in, first the couchDB backup shall happen and then the peer ledger data backup shall happen, because if there is block height difference between these 2, peer can reconstruct the stateDB again)fabric-ca-server.db
fileFabric entity upgrade (the order of upgrade shall be retained and shall be done when the above backups are ready in pvc)
PRIOR FIXES REQUIRED: The entities such as Orderer, Peer, CA server, CA client and CouchDB shall have value files with their image versions mentioned. If not, we need to do those changes to the 1.4.x charts first. The basic idea being, once the pre-requisite data is backup, there should be just a git push of newly image version and flux shall deploy the new image on the existing pvc's
Upgrading Orderer nodes
The orderers should be upgraded one at a time (in a rolling fashion)
Upgrading peer nodes along with their couchDB
As we have both of these entities in the same pod, the upgrade shall happen something like this
CC_CONTAINERS=$(docker ps | grep dev-$PEER_CONTAINER | awk '{print $1}') if [ -n "$CC_CONTAINERS" ] ; then docker rm -f $CC_CONTAINERS ; fi
CC_IMAGES=$(docker images | grep dev-$PEER | awk '{print $1}') if [ -n "$CC_IMAGES" ] ; then docker rmi -f $CC_IMAGES ; fi
peer node upgrade-dbs
and after this the node shall start usingpeer node start..
cmdUpgrading the CA server
Upgrading the CA client
Channel upgrade (The most complicated part to be tested for automation) :smile:
We need to enable the new chaincode lifecycle process. In short, this will resuse almost all of the code written for updating channel config (just with new json blocks added to the exisitng channel config)
NOTE: Before upgrading the channel config, we need to make sure that the orderer endpoints are defined in both the system channel and in all application channels (this can be checked by fetching these channel blocks, decoding them and finding if the orderer endpoints exists). If orderer endpoints do not exist in them, then one should first upgrade all of these channels. The process of such an upgrade is exactly how we have upgraded the channel config in some playbooks such as add orderer playbook (https://github.com/hyperledger/bevel/blob/main/platforms/hyperledger-fabric/configuration/add-orderer-organization.yaml), add peer playbook(https://github.com/hyperledger/bevel/blob/main/platforms/hyperledger-fabric/configuration/add-peer.yaml) etc etc
Chaincode upgrade
Once the channels are upgraded, the chaincodes on them can be upgraded by running chaincode upgrade command with a newer version of the chaincode than what earlier is.
NOTE: The previous chaincode version shall not be taken as 1.0 as there might be changes done by the organizations later on. So a script to find out the current chaincode version is needed, as mentioned in the BACKUP section