Skip to content

Prometheus client library packages not found in chain code container spun by peer container #22

@pvrbharg

Description

@pvrbharg

Hi,

I am trying to custom instrument my sample chaincode example_cc using Prometheus client golang library. The program works correctly natively in non-container environment. It fails at run time when I try to containerize the change [specifically at the instantiate step - when peer container tries to build chaincode example_cc with shim into an image and start the image in its own dev chaincode container]. I have used Go Module dependency resolution. I am using go.mod and go.sum mechanisms to resolve dependencies. I am seeing the following errors:
++++
hlbcadmin@ubuntu:~/go/src/github.com/securekey/fabric-examples/fabric-cli/cmd/fabric-cli$ go run fabric-cli.go chaincode instantiate --cid orgchannel --ccp=github.com/securekey/example_cc --ccid ExampleCC --v v0 --args '{"Args":["A","1","B","2"]}' --policy "AND('Org1MSP.member','Org2MSP.member')" --config ../../test/fixtures/config/config_test_local.yaml
[fabriccli] 2019/06/12 13:06:05 UTC - chaincode.glob..func4 -> ERRO Error while running instantiateAction: error instantiating chaincode: sending deploy transaction proposal failed: Transaction processing for endorser [localhost:7051]:
Chaincode status Code: (500) UNKNOWN. Description: error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "chaincode/input/src/github.com/securekey/example_cc/example_cc.go:27:5: cannot find package "github.com/prometheus/client_golang/prometheus" in any of:
/opt/go/src/github.com/prometheus/client_golang/prometheus (from $GOROOT)
/chaincode/input/src/github.com/prometheus/client_golang/prometheus (from $GOPATH)
/opt/gopath/src/github.com/prometheus/client_golang/prometheus
chaincode/input/src/github.com/securekey/example_cc/example_cc.go:29:2: cannot find package "github.com/prometheus/client_golang/prometheus/promauto" in any of:
/opt/go/src/github.com/prometheus/client_golang/prometheus/promauto (from $GOROOT)
/chaincode/input/src/github.com/prometheus/client_golang/prometheus/promauto (from $GOPATH)
/opt/gopath/src/github.com/prometheus/client_golang/prometheus/promauto
chaincode/input/src/github.com/securekey/example_cc/example_cc.go:28:5: cannot find package "github.com/prometheus/client_golang/prometheus/promhttp" in any of:
/opt/go/src/github.com/prometheus/client_golang/prometheus/promhttp (from $GOROOT)
/chaincode/input/src/github.com/prometheus/client_golang/prometheus/promhttp (from $GOPATH)
/opt/gopath/src/github.com/prometheus/client_golang/prometheus/promhttp
"
++++

My question - where exactly should I stage my vendor folder with client library packages for Prometheus and how do I make the child container spun by peer with chaincode+shim in to find the Prometheus client packages?

I am willing to share my project as a zip file if that helps. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions