简体   繁体   中英

hyperledger composer V 0.12 deploy fails

Working with Hyperledger Composer V0.12 invoking the deploy function using the following code, which returns a 'successful' result:

/**
 * Deploys a new BusinessNetworkDefinition to the Hyperledger Fabric. The connection must be connected for this method to succeed.
 * @param {express.req} req - the inbound request object from the client
 *  req.body.myArchive: _string - string name of object
 *  req.body.deployOptions: _object - string name of object
 * @param {express.res} res - the outbound response object for communicating back to client
 * @param {express.next} next - an express service to enable post processing prior to responding to the client
 * returns composerAdmin.connection - either an error or a connection object
 * @function
 */
exports.deploy = function(req, res, next) {

let newFile = path.join(path.dirname(require.main.filename),'network/dist',req.body.myArchive);
let archiveFile = fs.readFileSync(newFile);

let adminConnection = new composerAdmin.AdminConnection();

return BusinessNetworkDefinition.fromArchive(archiveFile)
    .then(function(archive) {
        adminConnection.connect(config.composer.connectionProfile, config.composer.adminID, config.composer.adminPW)
        .then(function(){
            adminConnection.deploy(archive)
                .then(function(){
                    console.log('business network '+req.body.myArchive+' deployed successful: ');
                    res.send({deploy: req.body.myArchive+' deploy succeeded'});
                })
                .catch(function(error){
                    console.log('business network '+req.body.myArchive+' deploy failed: ',error);
                    res.send({deploy: error});
                    });
            });
        });
};

However when I go through the following process:

  1. start docker images, deploy network using cli
  2. ping
  3. undeploy
  4. ping
  5. deploy
  6. ping

I get the following results:

[2] at: 08:10:36.058 Url is: /composer/admin/ping
network ping successful:  { version: '0.12.0', participant: null }
[3] at: 08:11:05.503 Url is: /composer/admin/undeploy
zerotoblockchain-network network undeploy successful 
[4] at: 08:11:25.186 Url is: /composer/admin/ping
(node:18241) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error trying to ping. Error: Error trying to query chaincode. Error: chaincode error (status: 500, message: Error: The business network has been undeployed)
[5] at: 08:11:34.393 Url is: /composer/admin/deploy
business network zerotoblockchain-network.bna deployed successful: 
[6] at: 08:11:44.211 Url is: /composer/admin/ping
(node:18241) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Error trying to ping. Error: Error trying to query chaincode. Error: chaincode error (status: 500, message: Error: The business network has been undeployed)

This indicates that the composer deploy function is not actually deploying the network, even though I appear to receive a successful completion message from the deploy service. Help, please?

When you undeploy a business network, all it does is mark the business network as unreachable. It remains deployed and still running. The reason for this is that currently Hyperledger fabric provides no mechanism for shutting down instantiated chaincode. So all we can do is mark it as unusable. The deploy API and command are the old way to get a business network up and running. The new way is the install/start combination. The reason that deploy reports successful is that it has to make decisions about errors reported back by both the install and start commands in order to continue to work in an expected manner in the Hyperledger Fabric way of doing things. So although it reports a success for deploying, it's really doing nothing because it is already deployed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM