Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

cannt install node cc package #6

Closed
mtiger2k opened this issue Jun 29, 2020 · 16 comments · Fixed by #9
Closed

cannt install node cc package #6

mtiger2k opened this issue Jun 29, 2020 · 16 comments · Fixed by #9

Comments

@mtiger2k
Copy link

I tried demo, but failed to install node cc package.
Does it support node cc?

@djboris9
Copy link
Contributor

Hi @mtiger2k

Node should be supported as hlfabric-k8scc calls the HyperLedger code to get the build params and so on.
But at the time, it is only tested/used with Go.

Can you provide more information, what failed? (peer logs and some information about the enviroment/deployment)
Did you try some publicly available chaincode, so I can try to reproduce the error?

@mirioeggmann did you use it with node?

@mtiger2k
Copy link
Author

thanks for your reply.

I used public marbles02 javascript cc.

firstly, I run your fabcar.tar.gz and it succeed.
then I copy marbles02 to pod, and package it.
kubectl cp chaincodes/marbles02 $(kubectl get pod -l app=cli.peer0.org1.example.com -o jsonpath="{.items[0].metadata.name}"):/chaincodes peer lifecycle chaincode package marbles.tar.gz --path /chaincodes/marbles02/javascript/ --lang node --label marbles
then install it.
peer lifecycle chaincode install marbles.tar.gz

run kubectl describe pod xxx to see
Warning Failed 61s (x3 over 3m11s) kubelet, docker-desktop Failed to pull image "hyperledger/fabric-nodeenv:2.0.1": rpc error: code = Unknown desc = Error response from daemon: manifest for hyperledger/fabric-nodeenv:2.0.1 not found: manifest unknown: manifest unknown

And I checked docker hub, there is no 2.0.1 nodeenv.

So maybe you need to change nodeenv to latest 2.1.0, and rebuild it.

@djboris9
Copy link
Contributor

Yes, you are right, this is definitely an issue. I will update the image versions on master soon

@djboris9
Copy link
Contributor

Is it possible for you to try the new/latest version from master of postfinance/hlfabric-k8scc?

djurdjevicb@example.com # docker run --rm -ti postfinance/hlfabric-k8scc:latest@sha256:ab31ad659f23597c5f002bf3e69d249cb7e6b45fd76374a449042f8397102cb1 cat /opt/k8scc/k8scc.yaml
/etc/hyperledger/fabric/core.yaml: OK
patching file /etc/hyperledger/fabric/core.yaml
Running: cat /opt/k8scc/k8scc.yaml
---
images:
  golang: "hyperledger/fabric-ccenv:2.1.0"
  java: "hyperledger/fabric-javaenv:2.1.0"
  node: "hyperledger/fabric-nodeenv:2.1.0"
transfer_volume:
  path: "/var/lib/k8scc/transfer/"
  claim: "k8scc-transfer-pv"
builder:
  resources:
    memory_limit: "1G"
    cpu_limit: "0.5"
launcher:
  resources:
    memory_limit: "1G"
    cpu_limit: "0.5"
djurdjevicb@example.com #

@mirioeggmann
Copy link
Member

@djboris9 Hm no I actually haven't tried it with node or java yet, because we currently just run go-chaincode in our network. But I will add a sample for both node- and java-chaincode to the example/demo folder so we can make sure that it works for all supported languages.

@mtiger2k
Copy link
Author

mtiger2k commented Jun 30, 2020

I tried hlfabric-k8scc:latest, but failed at init step. the following is the error message:

Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction c860b7864cbf60590e091f7e74498529d86236a1c7e48c5195a4d30304ca5cf9: could not launch chaincode marbles:1954916fc6acd2d7745177675558f57ea139e139de7b349602e46c503d7f1665: chaincode registration failed: timeout expired while starting chaincode marbles:1954916fc6acd2d7745177675558f57ea139e139de7b349602e46c503d7f1665 for transaction"

And the following is the pod describe message:

Events:
  Type     Reason     Age                    From                     Message
  ----     ------     ----                   ----                     -------
  Normal   Scheduled  5m46s                  default-scheduler        Successfully assigned default/peer0.org2.example.com-6b9f49b8d6-p4gq6-cc-marbles-1954916f to docker-desktop
  Normal   Pulled     4m17s (x5 over 5m45s)  kubelet, docker-desktop  Container image "hyperledger/fabric-nodeenv:2.1.0" already present on machine
  Normal   Created    4m17s (x5 over 5m45s)  kubelet, docker-desktop  Created container chaincode
  Warning  Failed     4m16s (x5 over 5m45s)  kubelet, docker-desktop  Error: failed to start container "chaincode": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/chaincode/output/chaincode\": stat /chaincode/output/chaincode: no such file or directory": unknown
  Warning  BackOff    44s (x23 over 5m43s)   kubelet, docker-desktop  Back-off restarting failed container

Edited by @djboris9: Code block formatting

@mtiger2k
Copy link
Author

mtiger2k commented Jun 30, 2020

and the following is pod logs:

2020-06-30 00:10:05.667 UTC [endorser] SimulateProposal -> ERRO 866 failed to invoke chaincode marbles, error: timeout expired while starting chaincode marbles:1954916fc6acd2d7745177675558f57ea139e139de7b349602e46c503d7f1665 for transaction
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch
	/go/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:130
github.com/hyperledger/fabric/internal/peer/node.custodianLauncherAdapter.Launch
	/go/src/github.com/hyperledger/fabric/internal/peer/node/start.go:181
github.com/hyperledger/fabric/core/chaincode/lifecycle.(*ChaincodeCustodian).Work
	/go/src/github.com/hyperledger/fabric/core/chaincode/lifecycle/custodian.go:102
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1373
chaincode registration failed
could not launch chaincode marbles:1954916fc6acd2d7745177675558f57ea139e139de7b349602e46c503d7f1665
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Launch
	/go/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:85
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Invoke
	/go/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:197
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Execute
	/go/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:155
github.com/hyperledger/fabric/core/endorser.(*SupportImpl).Execute
	/go/src/github.com/hyperledger/fabric/core/endorser/support.go:126
github.com/hyperledger/fabric/core/endorser.(*Endorser).callChaincode
	/go/src/github.com/hyperledger/fabric/core/endorser/endorser.go:119

Edited by @djboris9: Code block formatting

@mirioeggmann
Copy link
Member

I think the code line #L265 could be the problem because it always tries to run chaincode the following way: /chaincode/output/chaincode.

But in node it would probably be something like this: node /chaincode/output/marbles_chaincode.js.
(Based on the output generated by the marbles cc-builder)

/var/lib/k8scc/transfer/peer0.org1.example.com-8f676d88f-smltl422581043/output # ls -al
total 76
drwxrwxrwx    4 root     root          4096 Jun 30 11:43 .
drwx------    4 root     root          4096 Jun 30 11:43 ..
-rwxrwxrwx    1 root     root          1120 Jun 30 11:43 .gitignore
-rwxrwxrwx    1 root     root            44 Jun 30 11:43 k8scc_buildinfo.json
-rwxrwxrwx    1 root     root         19933 Jun 30 11:43 marbles_chaincode.js
drwxrwxrwx   86 root     root          4096 Jun 30 11:43 node_modules
-rwxrwxrwx    1 root     root         26890 Jun 30 11:43 package-lock.json
-rwxrwxrwx    1 root     root           318 Jun 30 11:43 package.json
drwxrwxrwx    3 root     root          4096 Jun 30 11:43 statedb

@djboris9
Copy link
Contributor

It depends on the platform as seen in dockercontroller.DockerVM.GetArgs. We will have to use a similar mechanism as with the build step, where we use the functions of hyperledger fabric to get the build string.

The easiest way should be to create a DockerVM struct and invoke GetArgs with the given platform, that we should pass through BuildInformation.

@mtiger2k The bug is confirmed :)

@mtiger2k
Copy link
Author

Great! Thanks for your effort.
So can this bug be fixed? Do you have plan to fix it?
Thanks.

djboris9 added a commit that referenced this issue Jun 30, 2020
@djboris9
Copy link
Contributor

I've already started some fixing and we will release a fixed version in the next few days

@mtiger2k
Copy link
Author

Thanks, this really helps.

@djboris9
Copy link
Contributor

djboris9 commented Jul 2, 2020

The bugs should be fixed now and are tested on our lab with the marble example. Can you please try out the master version (postfinance/hlfabric-k8scc:latest, make sure to pull the new image)?

@mtiger2k
Copy link
Author

mtiger2k commented Jul 3, 2020

I tested and it succeed, thanks.

The following is my test commands after commit.

`# init and invoke chaincode
peer chaincode invoke -o orderer-example-com:7050 --tls true --cafile /etc/hyperledger/organizations/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem -C mychannel -n marbles02_1 --peerAddresses peer0-org2-example-com:7051 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --peerAddresses peer0-org1-example-com:7051 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --isInit -c '{"function":"Init","Args":[]}'

invoke chaincode initMarble

peer chaincode invoke -o orderer-example-com:7050 --tls true --cafile /etc/hyperledger/organizations/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem -C mychannel -n marbles02_1 --peerAddresses peer0-org2-example-com:7051 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --peerAddresses peer0-org1-example-com:7051 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt -c '{"function":"initMarble","Args":["marble1","blue","35","tom"]}'

query chaincode readMarble

peer chaincode query -C mychannel -n marbles02_1 -c '{"function":"readMarble","Args":["marble1"]}'`

@mtiger2k
Copy link
Author

mtiger2k commented Jul 3, 2020

By the way, fabric 2.1.1 has be released, it would be better if you upgrade fabric. :)

@djboris9
Copy link
Contributor

djboris9 commented Jul 3, 2020

Fabric is now also updated and a new tag including the nodejs fixes is pushed: postfinance/hlfabric-k8scc:2.1.1-k8scc0.0.4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants