IBM / blockchain-network-on-kubernetes

Demonstrates the steps involved in setting up your business network on Hyperledger Fabric using Kubernetes APIs on IBM Cloud Kubernetes Service.
https://developer.ibm.com/patterns/deploy-hyperledger-fabric-network-on-ibm-cloud/
Apache License 2.0
316 stars 183 forks source link

Not able to instantiate chaincode #41

Closed happilymarrieddad closed 5 years ago

happilymarrieddad commented 5 years ago

Hello everybody,

NOTE: The network works perfectly all the way through my API interacting with a working network in docker-compose. The network seems to work perfectly with no errors up until attempting to instantiate the chaincode.

I've been trying to build a kubernetes cluster with hyperledger and everything works great except I can't seem to instantiate my chaincode. At first it was saying there wasn't a /var/run/docker.sock available so I added a docker container via your example and now I'm getting the following errors

Docker Container

time="2019-05-06T06:12:47.167226478Z" level=warning msg="Your kernel does not support swap limit capabilities,or the cgroup is not mounted. Memory limited without swap."
time="2019-05-06T06:13:01.521766588Z" level=info msg="Attempting next endpoint for pull after error: failed to register layer: ApplyLayer exit status 1 stdout:  stderr: errno 524"
time="2019-05-06T06:13:02.803021651Z" level=info msg="Pull session cancelled"
time="2019-05-06T06:13:03.233898331Z" level=error msg="Not continuing with pull after error: context canceled"
time="2019-05-06T06:13:03.273022662Z" level=warning msg="could not write error response: write tcp 100.96.29.99:2375->100.96.24.40:52048: write: broken pipe"

Peer Container

2019-05-06 06:08:34.181 UTC [comm.grpc.server] 1 -> INFO 06c unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=100.96.29.104:39364 grpc.code=OK grpc.call_duration=14.250358185s
2019-05-06 06:12:47.083 UTC [endorser] callChaincode -> INFO 06d [mainchannel][ad343f9a] Entry chaincode: name:"lscc" 
2019-05-06 06:12:47.176 UTC [chaincode.platform.golang] GenerateDockerBuild -> INFO 06e building chaincode with ldflagsOpt: '-ldflags "-linkmode external -extldflags '-static'"'
2019-05-06 06:13:01.524 UTC [chaincode.platform] func1 -> ERRO 06f Failed to generate platform-specific docker build: Failed to pull hyperledger/fabric-ccenv:latest: failed to register layer: ApplyLayer exit status 1 stdout:  stderr: errno 524
2019-05-06 06:13:01.524 UTC [dockercontroller] deployImage -> ERRO 070 Error building image: Post http://dev-docker:2375/build?t=dev-org1-peer0-assets-0-8c640fcda93c23e81c240e2f05a89be99b81bfc3bdcdb03dd0a0f40319242665: Failed to generate platform-specific docker build: Failed to pull hyperledger/fabric-ccenv:latest: failed to register layer: ApplyLayer exit status 1 stdout:  stderr: errno 524
2019-05-06 06:13:01.524 UTC [dockercontroller] deployImage -> ERRO 071 Build Output:
********************

********************
2019-05-06 06:13:01.538 UTC [endorser] callChaincode -> INFO 072 [mainchannel][ad343f9a] Exit chaincode: name:"lscc"  (14455ms)
2019-05-06 06:13:01.538 UTC [endorser] SimulateProposal -> ERRO 073 [mainchannel][ad343f9a] failed to invoke chaincode name:"lscc" , error: Post http://dev-docker:2375/build?t=dev-org1-peer0-assets-0-8c640fcda93c23e81c240e2f05a89be99b81bfc3bdcdb03dd0a0f40319242665: Failed to generate platform-specific docker build: Failed to pull hyperledger/fabric-ccenv:latest: failed to register layer: ApplyLayer exit status 1 stdout:  stderr: errno 524

Command line where I'm running the command

root@dev-cli-org1-peer0-deployment-fcb494b55-5wwrm:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode instantiate -C mainchannel -n assets -v 0 -c '{"Args":[]}' -o dev-orderer0:7050 --tls --cafile=/etc/hyperledger/orderers/msp/tlscacerts/localhost-7300.pem
2019-05-06 06:12:47.080 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-05-06 06:12:47.080 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: Post http://dev-docker:2375/build?t=dev-org1-peer0-assets-0-8c640fcda93c23e81c240e2f05a89be99b81bfc3bdcdb03dd0a0f40319242665: Failed to generate platform-specific docker build: Failed to pull hyperledger/fabric-ccenv:latest: failed to register layer: ApplyLayer exit status 1 stdout:  stderr: errno 524

I'm assuming that it has something to do with either the cli container not being able to start a chaincode container and/or the docker container not being able to do it. Is there something I'm doing wrong? I can provide all the files but there are a ton and I didn't want to post all that here. I could really use some help here. Thanks!

happilymarrieddad commented 5 years ago

Oh, when I try to pull that image locally it pulls and builds just fine.

maheshwarishikha commented 5 years ago

Nick, is it working fine for you?

happilymarrieddad commented 5 years ago

@maheshwarishikha no, I can't get it to instantiate the chaincode for some reason.. very frustrating.

happilymarrieddad commented 5 years ago

Here is the dump from the peer

2019-05-08 22:48:09.263 UTC [gossip.discovery] handleMsgFromComm -> DEBU 5839 Exiting
2019-05-08 22:48:09.263 UTC [gossip.gossip] handleMessage -> DEBU 583a Exiting
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 583b Error starting chaincode sample: error trying to connect to local peer: context deadline exceeded2019-05-08 22:48:09.695 UTC [shim] userChaincodeStreamGetter -> ERRO 001 context deadline exceeded
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 583c error trying to connect to local peer
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 583d github.com/hyperledger/fabric/core/chaincode/shim.userChaincodeStreamGetter
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 583e     /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/chaincode.go:112
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 583f github.com/hyperledger/fabric/core/chaincode/shim.Start
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 5840     /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/chaincode.go:151
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 5841 main.main
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 5842     /chaincode/input/src/assets/assets.go:180
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 5843 runtime.main
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 5844     /opt/go/src/runtime/proc.go:201
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 5845 runtime.goexit
2019-05-08 22:48:09.696 UTC [peer.chaincode.dev-org1-peer0-assets-0] func2 -> INFO 5846     /opt/go/src/runtime/asm_amd64.s:1333
2019-05-08 22:48:09.748 UTC [dockercontroller] func2 -> INFO 5847 Container dev-org1-peer0-assets-0 has closed its IO channel
2019-05-08 22:48:09.921 UTC [chaincode] Launch -> DEBU 5848 stopping due to error while launching: container exited with 0
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:63
runtime.goexit
    /opt/go/src/runtime/asm_amd64.s:1333
chaincode registration failed
2019-05-08 22:48:09.921 UTC [container] lockContainer -> DEBU 5849 waiting for container(assets-0) lock
2019-05-08 22:48:09.921 UTC [container] lockContainer -> DEBU 584a got container (assets-0) lock
2019-05-08 22:48:09.921 UTC [dockercontroller] stopInternal -> DEBU 584b stopping container id=dev-org1-peer0-assets-0
2019-05-08 22:48:09.925 UTC [dockercontroller] stopInternal -> DEBU 584c stop container result error="Container not running: dev-org1-peer0-assets-0"
2019-05-08 22:48:09.925 UTC [dockercontroller] stopInternal -> DEBU 584d killing container id=dev-org1-peer0-assets-0
2019-05-08 22:48:09.926 UTC [dockercontroller] stopInternal -> DEBU 584e kill container result id=dev-org1-peer0-assets-0 error="API error (500): Cannot kill container dev-org1-peer0-assets-0: Container 16544a7a7727a712a50fa3e02576bc34caf1b50b787334057cccb33280a0e528 is not running"
2019-05-08 22:48:09.926 UTC [dockercontroller] stopInternal -> DEBU 584f removing container id=dev-org1-peer0-assets-0
2019-05-08 22:48:09.933 UTC [dockercontroller] stopInternal -> DEBU 5850 remove container result id=dev-org1-peer0-assets-0 error=null
2019-05-08 22:48:09.933 UTC [container] unlockContainer -> DEBU 5851 container lock deleted(assets-0)
2019-05-08 22:48:09.933 UTC [chaincode] Launch -> DEBU 5852 launch complete
2019-05-08 22:48:09.933 UTC [chaincode] Deregister -> DEBU 5853 deregister handler: assets:0
2019-05-08 22:48:09.933 UTC [endorser] callChaincode -> INFO 5854 [mainchannel][4a2f1493] Exit chaincode: name:"lscc"  (31330ms)
2019-05-08 22:48:09.933 UTC [endorser] SimulateProposal -> ERRO 5855 [mainchannel][4a2f1493] failed to invoke chaincode name:"lscc" , error: container exited with 0
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:63
runtime.goexit
    /opt/go/src/runtime/asm_amd64.s:1333
chaincode registration failed
2019-05-08 22:48:09.934 UTC [endorser] SimulateProposal -> DEBU 5856 [mainchannel][4a2f1493] Exit
2019-05-08 22:48:09.934 UTC [lockbasedtxmgr] Done -> DEBU 5857 Done with transaction simulation / query execution [4a2f14931ee90b34584f8e723f0851111c2c08e460e7459eb2141b76d104f217]
2019-05-08 22:48:09.934 UTC [endorser] func1 -> DEBU 5858 Exit: request from 100.96.35.73:54162
2019-05-08 22:48:09.934 UTC [comm.grpc.server] 1 -> INFO 5859 unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=100.96.35.73:54162 grpc.code=OK grpc.call_duration=31.331518586s
2019-05-08 22:48:09.936 UTC [grpc] infof -> DEBU 585a transport: loopyWriter.run returning. connection error: desc = "transport is closing"
2019-05-08 22:48:09.936 UTC [grpc] warningf -> DEBU 585b transport: http2Server.HandleStreams

I'm assuming that it can't connect to docker or something... very weird

happilymarrieddad commented 5 years ago

OK, I feel really dumb....

 - name: CORE_PEER_CHAINCODELISTENADDRESS
   value: "localhost:7052"

Notice anything.... wow... Everything is working as it should.

happilymarrieddad commented 5 years ago

Oh I forgot to put the "solution" if you can even say that...

 - name: CORE_PEER_CHAINCODELISTENADDRESS
   value: "0.0.0.0:7052"
maheshwarishikha commented 5 years ago

Glad to hear, it worked for you. Did you try using minikube and added in your environment? As for Kubernetes on Cloud it is not required.

happilymarrieddad commented 5 years ago

@maheshwarishikha yea I was doing it on AWS... I feel really dumb... it works perfectly now...

cmuCoppelia commented 5 years ago

I meet the same problem today. But I can't understand your solution, what does

happilymarrieddad commented 5 years ago

@seuviceversa hey man, yea it's in the config for the peer. I was using "localhost" instead of "0.0.0.0" for the address in that ENV variable

cmuCoppelia commented 5 years ago

Thanks a lot! I have fixed it. I changed the name of directory without updating that in the docker compose file.

sunlidong commented 5 years ago

what do it ?hi help me

maheshwarishikha commented 5 years ago

@sunlidong , Not sure what issue you are facing...please provide details. Please open a new issue for your error....if you update an already closed issue, then most likely it gets ignored. Thanks.

Chinna2204 commented 4 years ago

when I instantiated chaincode ...I got this error Error: could not assemble transaction, err proposal response was not successful, error code 500, msg chaincode registration failed: container exited with 0

pls help me to resolve it...thanks in advance

happilymarrieddad commented 4 years ago

@Chinna2204 can you please provide your setup? It's most likely either your docker.sock file isn't mounted or you don't have the chaincode listen address. Thanks!

sukhpreet0607 commented 1 year ago

Oh I forgot to put the "solution" if you can even say that...

 - name: CORE_PEER_CHAINCODELISTENADDRESS
   value: "0.0.0.0:7052"

can u eleborate your solution plssss