IBM-Blockchain-Archive / ibm-container-service

IBM Blockchain Platform for Developers on IBM Container Service
Apache License 2.0
89 stars 73 forks source link

Error: Failed to save card: PeerAdmin@hlfv1 #98

Closed DazWilkin closed 6 years ago

DazWilkin commented 6 years ago

In full disclosure, I've not used Composer previously and was hoping that, by following through these scripts, it would work without issue. It doesn't.

I'm having issues getting the Peers to join the Channel (https://github.com/IBM-Blockchain/ibm-container-service/issues/97) so it's entirely possible that this subsequent step won't work until that issue is addressed. However, it doesn't appear immediately dependent.

The composer-card-import Pod|container fails with Error: Failed to save card: PeerAdmin@hlfv1

So getting on to the container and running the script step-by-step:

$ ls -la
drwxr-xr-x 1 composer composer 4096 Jun  6 21:09 .
drwxr-xr-x 1 root     root     4096 Dec 14 18:35 ..
-rw-r--r-- 1 composer composer  220 Aug 31  2015 .bash_logout
-rw-r--r-- 1 composer composer 3771 Aug 31  2015 .bashrc
drwxr-xr-x 5 root     root     4096 Jun  6 18:49 .composer
drwxr-xr-x 5 composer composer 4096 Dec 14 18:35 .npm-global
-rw------- 1 composer composer   34 Dec 14 18:35 .npmrc
-rw-r--r-- 1 composer composer  655 May 16  2017 .profile
drwxr-xr-x 2 root     root     4096 Dec 14 18:32 LICENSE

$ ls -la ./.composer
total 60
drwxr-xr-x 5 root     root      4096 Jun  6 18:49 .
drwxr-xr-x 1 composer composer  4096 Jun  6 21:09 ..
-rw-r--r-- 1 root     root         0 Jun  6 18:46 bootstrapped
drwxr-xr-x 4 root     root      4096 Jun  6 18:46 cas
-rw-r--r-- 1 root     root       392 Jun  6 18:49 channel1.tx
-rw-r--r-- 1 root     root      6891 Jun  6 18:46 configtx.yaml
drwxr-xr-x 4 root     root      4096 Jun  6 18:46 crypto-config
-rw-r--r-- 1 root     root        16 Jun  6 18:46 index.html
drwxr-xr-x 2 root     root     16384 Jun  6 18:46 lost+found
-rw-r--r-- 1 root     root      9070 Jun  6 18:46 orderer.block
-rw-r--r-- 1 root     root         0 Jun  6 18:49 status_channelcreate_complete
-rw-r--r-- 1 root     root         0 Jun  6 18:46 status_fabricca_complete
-rw-r--r-- 1 root     root         0 Jun  6 18:46 status_orderer_complete
-rw-r--r-- 1 root     root         0 Jun  6 18:47 status_org1peer1_complete
-rw-r--r-- 1 root     root         0 Jun  6 18:47 status_org2peer1_complete

$ echo $PWD
/home/composer

$ echo $K8S_PROFILE
{ "type": "hlfv1", "name": "hlfv1", "orderers": [ { "url": "grpc://ibm-blockchain-network-orderer:31010" } ], "ca": { "url": "http://ibm-blockchain-network-ca:30054", "name": "CA1" }, "peers": [ { "requestURL": "grpc://ibm-blockchain-network-org1peer1:30110", "eventURL": "grpc://ibm-blockchain-network-org1peer1:30111" } ], "channel": "channel1", "mspID": "Org1MSP", "timeout": 300 }

$ echo $K8S_PROFILE > connection.json

$ ls -l
drwxr-xr-x 2 root     root     4096 Dec 14 18:32 LICENSE
-rw-r--r-- 1 composer composer  385 Jun  6 20:23 connection.json

$ ls -l /shared/crypto-config/peerOrganizations
total 8
drwxr-xr-x 7 root root 4096 Jun  6 18:46 org1.example.com
drwxr-xr-x 7 root root 4096 Jun  6 18:46 org2.example.com

$ ls -l /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem
-rw-r--r-- 1 root root 790 Jun  6 18:46 /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem

$ ls -l /shared/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem
-rw-r--r-- 1 root root 790 Jun  6 18:46 /shared/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem

$ composer card create \
-f PeerAdmin.card \
-p connection.json \
-u PeerAdmin \
-r PeerAdmin \
-r ChannelAdmin \
-c /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem \
-k /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/key.pem

Successfully created business network card file to 
    Output file: PeerAdmin.card

Command succeeded

$ ls -l
total 16
drwxr-xr-x 2 root     root     4096 Dec 14 18:32 LICENSE
-rw-r--r-- 1 composer composer 2026 Jun  6 20:25 PeerAdmin.card
drwxr-xr-x 2 composer composer 4096 Jun  6 20:25 composer-logs
-rw-r--r-- 1 composer composer  385 Jun  6 20:23 connection.json

$ composer card import -f PeerAdmin.card
Error: Failed to save card: PeerAdmin@hlfv1
Command failed
vmorris commented 6 years ago

Not having the peer joined to the channel wouldn't cause the card to fail to import. I don't think it would cause that error, but can you try with -u admin in the card create? Also, what version of composer are you using?

vmorris commented 6 years ago

I'm also not seeing what version of Fabric you're using. If it's v1.1.0, you're connection profile's got to be a bit more substantial: https://hyperledger.github.io/composer/latest/reference/connectionprofile

DazWilkin commented 6 years ago

Thanks!

I'm using the Helm Chart from this repo and it uses:

toolsImage: ibmblockchain/fabric-tools:1.0.0
ordererImage: ibmblockchain/fabric-orderer:1.0.0
caImage: ibmblockchain/fabric-ca:1.0.0
peerImage: ibmblockchain/fabric-peer:1.0.0

and it includes:

composer --version
v0.16.2

The Deployment is created from this file which is simpler than the one you reference. I'll try create something more complete: https://github.com/IBM-Blockchain/ibm-container-service/blob/master/cs-offerings/kube-configs/composer-card-import.yaml

DazWilkin commented 6 years ago

IIUC, I tried using -u admin:

$ composer card create -u admin -p connection.json

Successfully created business network card file to 
    Output file: admin@hlfv1.card

Command succeeded

$ composer card import -f admin@hlfv1.card
Error: Failed to save card: admin@hlfv1
Command failed

$ ls -l
total 20
drwxr-xr-x 2 root     root     4096 Dec 14 18:32 LICENSE
-rw-r--r-- 1 composer composer 2022 Jun  6 22:54 PeerAdmin.card
-rw-r--r-- 1 composer composer  612 Jun  6 23:08 admin@hlfv1.card
drwxr-xr-x 2 composer composer 4096 Jun  6 22:42 composer-logs
-rw-r--r-- 1 composer composer  385 Jun  6 22:42 connection.json
vmorris commented 6 years ago

Hmm, you wouldn't want to try the more complicated profile for a fabric 1.0.0 network, but you could get a newer version of composer (stay on the 0.16.x level). Last I checked, it was 0.16.6.

DazWilkin commented 6 years ago

Solved!

I mixed up volume mounts between:

Helm Chart's blockchain-utils yaml's mountPath: /home/composer/

and

composer-card-import script's mountPath: /home/composer/.composer