sitalab / FlightChain

FlightChain is a reference project for the SITA Aviation Sandbox
https://www.developer.aero/Blockchain/Aviation-Blockchain-Sandbox
Apache License 2.0
5 stars 1 forks source link

Add script to Upgrade chaincode #2

Closed kosullivansita closed 5 years ago

kosullivansita commented 5 years ago

Right now, when changing the chaincode, the whole network needs to be brought down & restarted. We need to add an option to just upgrade the chaincode.

See some info here on this: http://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html#upgrade-and-invoke

It seems straightforward...

BTW - This script should go in the chaincode folder

sinead-kelly commented 5 years ago

Getting an error when upgrade script attempts to upgrade new chaincode

upgrading flightchain to version 1.1
2018-08-08 06:45:09.927 EDT [main] main -> ERRO 001 Fatal error when initializing core config : error when reading core config file: Unsupported Config Type ""

Online solutions suggest to export FABRIC_CFG_PATH but this hasn't worked

sinead-kelly commented 5 years ago

config error was caused by missing environment variable in docker exec command, fixed now.

sinead-kelly commented 5 years ago

peer upgrade not seeing chaincode despite same path given as used in the peer install command

upgrading flightchain to version 1.1
2018-08-10 08:38:31.321 UTC [chaincodeCmd] InitCmdFactory -> INFO 001 Get chain(mychannel) orderer endpoint: orderer.example.com:7050
2018-08-10 08:38:31.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default escc
2018-08-10 08:38:31.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default vscc
Error: Error endorsing chaincode: rpc error: code = Unknown desc = chaincode error (status: 500, message: could not find chaincode with name 'flightchain')
sinead-kelly commented 5 years ago

pulled latest from master as my local was out of date but now getting a different error:

Error: Error getting broadcast client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded

Orderer is up and running on port 7050

kosullivansita commented 5 years ago

@sinead-kelly - Can you update the deploy script to also take the channel name as a command line arg, so they are consistent with each other.

kosullivansita commented 5 years ago

Also - when I upgrade, I now see two instances of chaincode running, one for each version. Should the old version be removed ?

KOS:chaincode kosullivan$ docker ps
CONTAINER ID        IMAGE                                                                                                          COMMAND                  CREATED             STATUS              PORTS                                            NAMES
040a95ec0ad5        dev-peer0.sandbox.sita.aero-flightchain-1.3-839a992ff897d3af9e550d2aae45736c410686380b4ba523a214f24a3cc5051f   "/bin/sh -c 'cd /usr…"   21 minutes ago      Up 21 minutes                                                        dev-peer0.sandbox.sita.aero-flightchain-1.3
a8b818813b1d        dev-peer0.sandbox.sita.aero-flightchain-1.2-4d478f9cbc7d3916fa233362fe18f5feacded8461271baa26b2c77a43844f199   "/bin/sh -c 'cd /usr…"   13 days ago         Up 13 days                                                           dev-peer0.sandbox.sita.aero-flightchain-1.2
sinead-kelly commented 5 years ago

@kosullivansita according to the hyperledger docs "since multiple versions of a chaincode may be active simultaneously, the upgrade process doesn’t automatically remove the old versions, so user must manage this for the time being." So we'll have to remove old chaincodes ourselves

sinead-kelly commented 5 years ago

the upgrade transaction only affects one channel at a time, the channel to which the transaction is submitted. So if you want to upgrade a chaincode that is on multiple channels you will have to do it for each channel